本文整理汇总了Java中com.jme3.material.MaterialList类的典型用法代码示例。如果您正苦于以下问题:Java MaterialList类的具体用法?Java MaterialList怎么用?Java MaterialList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MaterialList类属于com.jme3.material包,在下文中一共展示了MaterialList类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMtlLib
import com.jme3.material.MaterialList; //导入依赖的package包/类
protected void loadMtlLib(String name) throws IOException{
if (!name.toLowerCase().endsWith(".mtl"))
throw new IOException("Expected .mtl file! Got: " + name);
matList = (MaterialList) assetManager.loadAsset(key.getFolder() + name);
if (matList != null){
// create face lists for every material
for (String matName : matList.keySet()){
matFaces.put(matName, new ArrayList<Face>());
}
}else{
logger.log(Level.WARNING, "Can't find MTL file. " +
"Using default material for OBJ.");
}
}
示例2: load
import com.jme3.material.MaterialList; //导入依赖的package包/类
public MaterialList load(AssetManager assetManager, MaterialExtensionSet matExts, Scanner scan) throws IOException{
this.assetManager = assetManager;
this.matExts = matExts;
this.scan = scan;
list = new MaterialList();
if (scan.hasNext("import")){
scan.nextLine(); // skip this line
}
toploop: while (scan.hasNext()){
while (!scan.hasNext("material")){
if (!scan.hasNext())
break toploop;
scan.next();
}
Material material = readExtendingMaterial();
list.put(matName, material);
}
return list;
}
示例3: load
import com.jme3.material.MaterialList; //导入依赖的package包/类
public MaterialList load(AssetManager assetManager, AssetKey key, MaterialExtensionSet matExts,
List<Statement> statements) throws IOException{
this.assetManager = assetManager;
this.matExts = matExts;
this.key = key;
list = new MaterialList();
for (Statement statement : statements){
if (statement.getLine().startsWith("import")){
// ignore
continue;
}else if (statement.getLine().startsWith("material")){
Material material = readExtendingMaterial(statement);
list.put(matName, material);
List<String> matAliases = matExts.getNameMappings(matName);
if(matAliases != null){
for (String string : matAliases) {
list.put(string, material);
}
}
}
}
return list;
}
示例4: loadMtlLib
import com.jme3.material.MaterialList; //导入依赖的package包/类
protected void loadMtlLib(String name) throws IOException{
if (!name.toLowerCase().endsWith(".mtl"))
throw new IOException("Expected .mtl file! Got: " + name);
// NOTE: Cut off any relative/absolute paths
name = new File(name).getName();
try {
matList = (MaterialList) assetManager.loadAsset(key.getFolder() + name);
} catch (AssetNotFoundException ex){
throw new AssetNotFoundException("Cannot find material " + name + " for model " + key.getName());
}
if (matList != null){
// create face lists for every material
for (String matName : matList.keySet()){
matFaces.put(matName, new ArrayList<Face>());
}
}else{
logger.log(Level.WARNING, "Can't find MTL file. " +
"Using default material for OBJ.");
}
}
示例5: load
import com.jme3.material.MaterialList; //导入依赖的package包/类
@SuppressWarnings("empty-statement")
public Object load(AssetInfo info){
this.assetManager = info.getManager();
folderName = info.getKey().getFolder();
InputStream in = info.openStream();
scan = new Scanner(in);
scan.useLocale(Locale.US);
matList = new MaterialList();
while (readLine());
if (matName != null){
// still have a material in the vars
createMaterial();
resetMaterial();
}
MaterialList list = matList;
reset();
try{
in.close();
}catch (IOException ex){
}
return list;
}
示例6: startElement
import com.jme3.material.MaterialList; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, Attributes attribs) throws SAXException {
if (qName.equals("externals")) {
checkTopNode("scene");
// Has an externals block, create material list.
materialList = new MaterialList();
} else if (qName.equals("item")) {
checkTopNode("externals");
if (!attribs.getValue("type").equals("material")) {
// This is not a material external. Ignore it.
ignoreItem = true;
}
} else if (qName.equals("file")) {
checkTopNode("item");
if (!ignoreItem) {
String materialPath = attribs.getValue("name");
String materialName = new File(materialPath).getName();
String matFile = folderName + materialName;
try {
MaterialList loadedMaterialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(matFile));
materialList.putAll(loadedMaterialList);
} catch (AssetNotFoundException ex) {
logger.log(Level.WARNING, "Cannot locate material file: {0}", matFile);
}
}
}
elementStack.push(qName);
}
示例7: load
import com.jme3.material.MaterialList; //导入依赖的package包/类
@SuppressWarnings("empty-statement")
public Object load(AssetInfo info) throws IOException{
reset();
this.assetManager = info.getManager();
folderName = info.getKey().getFolder();
matList = new MaterialList();
InputStream in = null;
try {
in = info.openStream();
scan = new Scanner(in);
scan.useLocale(Locale.US);
while (readLine());
} finally {
if (in != null){
in.close();
}
}
if (matName != null){
// still have a material in the vars
createMaterial();
resetMaterial();
}
MaterialList list = matList;
return list;
}
示例8: simpleInitApp
import com.jme3.material.MaterialList; //导入依赖的package包/类
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
flyCam.setMoveSpeed(100);
setupKeys();
this.cam.setFrustumFar(2000);
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White.clone().multLocal(2));
dl.setDirection(new Vector3f(-1, -1, -1).normalize());
rootNode.addLight(dl);
AmbientLight am = new AmbientLight();
am.setColor(ColorRGBA.White.mult(2));
rootNode.addLight(am);
// load the level from zip or http zip
if (useHttp) {
assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/quake3level.zip", HttpZipLocator.class.getName());
} else {
assetManager.registerLocator("quake3level.zip", ZipLocator.class.getName());
}
// create the geometry and attach it
MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material");
OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
gameLevel = (Node) assetManager.loadAsset(key);
gameLevel.setLocalScale(0.1f);
// add a physics control, it will generate a MeshCollisionShape based on the gameLevel
gameLevel.addControl(new RigidBodyControl(0));
player = new PhysicsCharacter(new SphereCollisionShape(5), .01f);
player.setJumpSpeed(20);
player.setFallSpeed(30);
player.setGravity(30);
player.setPhysicsLocation(new Vector3f(60, 10, -60));
rootNode.attachChild(gameLevel);
getPhysicsSpace().addAll(gameLevel);
getPhysicsSpace().add(player);
}
示例9: OgreMeshKey
import com.jme3.material.MaterialList; //导入依赖的package包/类
public OgreMeshKey(String name, MaterialList materialList){
super(name);
this.materialList = materialList;
}
示例10: getMaterialList
import com.jme3.material.MaterialList; //导入依赖的package包/类
public MaterialList getMaterialList() {
return materialList;
}
示例11: simpleInitApp
import com.jme3.material.MaterialList; //导入依赖的package包/类
public void simpleInitApp() {
// this.flyCam.setMoveSpeed(2000);
// this.cam.setFrustumFar(10000);
MeshLoader.AUTO_INTERLEAVE = false;
// mat = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
// mat.setColor("Color", ColorRGBA.White);
// mat2 = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
assetManager.registerLocator("quake3level.zip", "com.jme3.asset.plugins.ZipLocator");
MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material");
OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
Spatial scene = assetManager.loadModel(key);
// Spatial scene = assetManager.loadModel("Models/Teapot/teapot.obj");
// scene.scale(3);
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(new Vector3f(-1, -1, -1).normalize());
rootNode.addLight(dl);
DirectionalLight dl2 = new DirectionalLight();
dl2.setColor(ColorRGBA.White);
dl2.setDirection(new Vector3f(1, -1, 1).normalize());
rootNode.addLight(dl2);
// generate octree
// tree = new Octree(scene, 20000);
tree = new Octree(scene, 50);
tree.construct();
ArrayList<Geometry> globalGeomList = new ArrayList<Geometry>();
tree.createFastOctnodes(globalGeomList);
tree.generateFastOctnodeLinks();
for (Geometry geom : globalGeomList){
geom.addLight(dl);
geom.addLight(dl2);
geom.updateGeometricState();
}
globalGeoms = globalGeomList.toArray(new Geometry[0]);
fastRoot = tree.getFastRoot();
octBox = tree.getBound();
viewPort.addProcessor(this);
}
示例12: setMaterialList
import com.jme3.material.MaterialList; //导入依赖的package包/类
public void setMaterialList(MaterialList materialList){
this.materialList = materialList;
}