本文整理了Java中com.jme3.scene.Spatial.setMaterial()
方法的一些代码示例,展示了Spatial.setMaterial()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spatial.setMaterial()
方法的具体详情如下:
包路径:com.jme3.scene.Spatial
类名称:Spatial
方法名:setMaterial
[英]Applies the given material to the Spatial, this will propagate the material down to the geometries in the scene graph.
[中]将给定材质应用于空间,这会将材质向下传播到场景图中的几何体。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void onAction(String name, boolean value, float tpf) {
if (name.equals("use_water") && value) {
if (!useWater) {
useWater = true;
waterPlane.setMaterial(waterProcessor.getMaterial());
} else {
useWater = false;
waterPlane.setMaterial(mat);
}
} else if (name.equals("lightup") && value) {
lightPos.y++;
} else if (name.equals("lightdown") && value) {
lightPos.y--;
} else if (name.equals("lightleft") && value) {
lightPos.x--;
} else if (name.equals("lightright") && value) {
lightPos.x++;
} else if (name.equals("lightforward") && value) {
lightPos.z--;
} else if (name.equals("lightback") && value) {
lightPos.z++;
}
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void setMaterial(Material mat){
for (int i = 0; i < children.size(); i++){
children.get(i).setMaterial(mat);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified character.
*
* @param debugAppState which app state (not null, alias created)
* @param body the character to visualize (not null, alias created)
*/
public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) {
super(debugAppState);
this.body = body;
myShape = body.getCollisionShape();
oldScale.set(myShape.getScale());
this.geom = DebugShapeFactory.getDebugShape(myShape);
this.geom.setName(body.toString());
geom.setMaterial(debugAppState.DEBUG_PINK);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified ghost object.
*
* @param debugAppState which app state (not null, alias created)
* @param body which object to visualize (not null, alias created)
*/
public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) {
super(debugAppState);
this.body = body;
myShape = body.getCollisionShape();
oldScale.set(myShape.getScale());
this.geom = DebugShapeFactory.getDebugShape(myShape);
this.geom.setName(body.toString());
geom.setMaterial(debugAppState.DEBUG_YELLOW);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified body.
*
* @param debugAppState which app state (not null, alias created)
* @param body which body to visualize (not null, alias created)
*/
public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) {
super(debugAppState);
this.body = body;
myShape = body.getCollisionShape();
oldScale.set(myShape.getScale());
this.geom = DebugShapeFactory.getDebugShape(myShape);
this.geom.setName(body.toString());
geom.setMaterial(debugAppState.DEBUG_BLUE);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified ghost object.
*
* @param debugAppState which app state (not null, alias created)
* @param body which object to visualize (not null, alias created)
*/
public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) {
super(debugAppState);
this.body = body;
myShape = body.getCollisionShape();
oldScale.set(myShape.getScale());
this.geom = DebugShapeFactory.getDebugShape(myShape);
this.geom.setName(body.toString());
geom.setMaterial(debugAppState.DEBUG_YELLOW);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified character.
*
* @param debugAppState which app state (not null, alias created)
* @param body the character to visualize (not null, alias created)
*/
public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) {
super(debugAppState);
this.body = body;
myShape = body.getCollisionShape();
oldScale.set(myShape.getScale());
this.geom = DebugShapeFactory.getDebugShape(myShape);
this.geom.setName(body.toString());
geom.setMaterial(debugAppState.DEBUG_PINK);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Instantiate an enabled control to visualize the specified body.
*
* @param debugAppState which app state (not null, alias created)
* @param body which body to visualize (not null, alias created)
*/
public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) {
super(debugAppState);
this.body = body;
myShape = body.getCollisionShape();
oldScale.set(myShape.getScale());
this.geom = DebugShapeFactory.getDebugShape(myShape);
this.geom.setName(body.toString());
geom.setMaterial(debugAppState.DEBUG_BLUE);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) return;
Material mat;
if (isLit){
mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m");
debugTangents.setCullHint(CullHint.Inherit);
}else{
mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("NormalMap", assetManager.loadTexture("Models/TangentBugs/test_normal.png"));
debugTangents.setCullHint(CullHint.Always);
}
isLit = !isLit;
badModel.setMaterial(mat);
}
}, "space");
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
signpost.setLocalTranslation(12, 3.5f, 30);
signpost.setLocalScale(4);
signpost.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(signpost);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupSignpost(){
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
signpost.setLocalTranslation(12, 3.5f, 30);
signpost.setLocalScale(4);
signpost.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(signpost);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupRobotGuy(){
Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m");
model.getChild(0).setMaterial(mat);
// model.setAnimation("Walk");
model.setLocalTranslation(30, 10.5f, 30);
model.setLocalScale(2);
model.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(model);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupSignpost(){
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
// mat.setBoolean("VertexLighting", true);
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
signpost.setLocalTranslation(12, 3.5f, 30);
signpost.setLocalScale(4);
signpost.setShadowMode(ShadowMode.CastAndReceive);
TangentBinormalGenerator.generate(signpost);
rootNode.attachChild(signpost);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Material matSp = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
TangentBinormalGenerator.generate(signpost);
signpost.setMaterial(matSp);
signpost.rotate(0, FastMath.HALF_PI, 0);
signpost.setLocalTranslation(12, 23.5f, 30);
signpost.setLocalScale(4);
signpost.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(signpost);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
TangentBinormalGenerator.generate(signpost);
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
signpost.setLocalTranslation(12, 23.5f, 30);
signpost.setLocalScale(4);
signpost.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(signpost);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
// mat.setBoolean("VertexLighting", true);
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
signpost.setLocalTranslation(12, 3.5f, 30);
signpost.setLocalScale(4);
signpost.setShadowMode(ShadowMode.CastAndReceive);
TangentBinormalGenerator.generate(signpost);
rootNode.attachChild(signpost);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void initialize(){
super.initialize();
System.out.println("Initialize");
RootNodeState state = new RootNodeState();
viewPort.attachScene(state.getRootNode());
stateManager.attach(state);
Spatial model = assetManager.loadModel("Models/Teapot/Teapot.obj");
model.scale(3);
model.setMaterial(assetManager.loadMaterial("Interface/Logo/Logo.j3m"));
state.getRootNode().attachChild(model);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
inputManager,
audioRenderer,
guiViewPort);
niftyDisplay.getNifty().fromXml("Interface/Nifty/HelloJme.xml", "start");
guiViewPort.addProcessor(niftyDisplay);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleInitApp() {
initInput();
initScene();
//create processor
waterProcessor = new SimpleWaterProcessor(assetManager);
waterProcessor.setReflectionScene(sceneNode);
waterProcessor.setDebug(true);
viewPort.addProcessor(waterProcessor);
waterProcessor.setLightPosition(lightPos);
//create water quad
//waterPlane = waterProcessor.createWaterGeometry(100, 100);
waterPlane=(Spatial) assetManager.loadModel("Models/WaterTest/WaterTest.mesh.xml");
waterPlane.setMaterial(waterProcessor.getMaterial());
waterPlane.setLocalScale(40);
waterPlane.setLocalTranslation(-5, 0, 5);
rootNode.attachChild(waterPlane);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleInitApp() {
Quad quadMesh = new Quad(1, 1);
Geometry sphere = new Geometry("Rock Ball", quadMesh);
Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
sphere.setMaterial(mat);
TangentBinormalGenerator.generate(sphere);
rootNode.attachChild(sphere);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
pl = new PointLight();
pl.setColor(ColorRGBA.White);
pl.setPosition(new Vector3f(0f, 0f, 4f));
rootNode.addLight(pl);
// DirectionalLight dl = new DirectionalLight();
// dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
// dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
// rootNode.addLight(dl);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleInitApp() {
Sphere sphMesh = new Sphere(32, 32, 1);
sphMesh.setTextureMode(Sphere.TextureMode.Projected);
sphMesh.updateGeometry(32, 32, 1, false, false);
TangentBinormalGenerator.generate(sphMesh);
Geometry sphere = new Geometry("Rock Ball", sphMesh);
Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
sphere.setMaterial(mat);
rootNode.attachChild(sphere);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
pl = new PointLight();
pl.setColor(ColorRGBA.White);
pl.setPosition(new Vector3f(0f, 0f, 4f));
rootNode.addLight(pl);
// DirectionalLight dl = new DirectionalLight();
// dl.setDirection(new Vector3f(1,-1,1).normalizeLocal());
// dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
// rootNode.addLight(dl);
}
内容来源于网络,如有侵权,请联系作者删除!