helloworld: updated depricated Box() constructor and object names

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10709 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
roo..li 12 years ago
parent 9fb93e8f7a
commit a457d2d922
  1. 80
      engine/src/test/jme3test/helloworld/HelloMaterial.java

@ -59,50 +59,52 @@ public class HelloMaterial extends SimpleApplication {
public void simpleInitApp() { public void simpleInitApp() {
/** A simple textured cube -- in good MIP map quality. */ /** A simple textured cube -- in good MIP map quality. */
Box boxshape1 = new Box(new Vector3f(-3f,1.1f,0f), 1f,1f,1f); Box box1Mesh = new Box(1f,1f,1f);
Geometry cube = new Geometry("My Textured Box", boxshape1); Geometry cubePlainGeo = new Geometry("My Textured Box", box1Mesh);
Material mat_stl = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); Material stlMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
Texture tex_ml = assetManager.loadTexture("Interface/Logo/Monkey.jpg"); Texture monkeyTex = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
mat_stl.setTexture("ColorMap", tex_ml); stlMat.setTexture("ColorMap", monkeyTex);
cube.setMaterial(mat_stl); cubePlainGeo.setMaterial(stlMat);
rootNode.attachChild(cube); cubePlainGeo.move(new Vector3f(-3f,1.1f,0f));
rootNode.attachChild(cubePlainGeo);
/** A translucent/transparent texture, similar to a window frame. */ /** A translucent/transparent texture, similar to a window frame. */
Box boxshape3 = new Box(new Vector3f(0f,0f,0f), 1f,1f,0.01f); Box box3Mesh = new Box(1f,1f,0.01f);
Geometry window_frame = new Geometry("window frame", boxshape3); Geometry windowGeo = new Geometry("window frame", box3Mesh);
Material mat_tt = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); Material ttMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_tt.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png")); ttMat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
mat_tt.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); // activate transparency ttMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); // activate transparency
window_frame.setQueueBucket(Bucket.Transparent); windowGeo.setQueueBucket(Bucket.Transparent);
window_frame.setMaterial(mat_tt); windowGeo.setMaterial(ttMat);
rootNode.attachChild(window_frame); rootNode.attachChild(windowGeo);
/** A cube with its base color "leaking" through a partially transparent texture */ /** A cube with its base color "bleeding" through a partially transparent texture */
Box boxshape4 = new Box(new Vector3f(3f,-1f,0f), 1f,1f,1f); Box box4Mesh = new Box(1f,1f,1f);
Geometry cube_leak = new Geometry("Leak-through color cube", boxshape4); Geometry bleedCubeGeo = new Geometry("bleed-through colored cube", box4Mesh);
Material mat_tl = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); Material tlMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_tl.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png")); tlMat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
mat_tl.setColor("Color", new ColorRGBA(1f,0f,1f, 1f)); // purple tlMat.setColor("Color", new ColorRGBA(1f,0f,1f, 1f)); // purple
cube_leak.setMaterial(mat_tl); bleedCubeGeo.setMaterial(tlMat);
rootNode.attachChild(cube_leak); bleedCubeGeo.move(new Vector3f(3f,-1f,0f));
// cube_leak.setMaterial((Material) assetManager.loadAsset( "Materials/LeakThrough.j3m")); rootNode.attachChild(bleedCubeGeo);
//bleedCubeGeo.setMaterial((Material) assetManager.loadAsset( "Materials/BleedThrough.j3m"));
/** A bumpy rock with a shiny light effect. To make bumpy objects you must create a NormalMap. */ /** A bumpy rock with a shiny light effect. To make bumpy objects you must create a NormalMap. */
Sphere rock = new Sphere(32,32, 2f); Sphere sphereMesh = new Sphere(32,32, 2f);
Geometry shiny_rock = new Geometry("Shiny rock", rock); Geometry shinyRockGeo = new Geometry("Shiny rock", sphereMesh);
rock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres sphereMesh.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres
TangentBinormalGenerator.generate(rock); // for lighting effect TangentBinormalGenerator.generate(sphereMesh); // for lighting effect
Material mat_lit = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); Material litMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat_lit.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/Pond/Pond.jpg")); litMat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/Pond/Pond.jpg"));
mat_lit.setTexture("NormalMap", assetManager.loadTexture("Textures/Terrain/Pond/Pond_normal.png")); litMat.setTexture("NormalMap", assetManager.loadTexture("Textures/Terrain/Pond/Pond_normal.png"));
mat_lit.setBoolean("UseMaterialColors",true); litMat.setBoolean("UseMaterialColors",true);
mat_lit.setColor("Specular",ColorRGBA.White); litMat.setColor("Specular",ColorRGBA.White);
mat_lit.setColor("Diffuse",ColorRGBA.White); litMat.setColor("Diffuse",ColorRGBA.White);
mat_lit.setFloat("Shininess", 5f); // [0,128] litMat.setFloat("Shininess", 64f); // [0,128]
shiny_rock.setMaterial(mat_lit); shinyRockGeo.setMaterial(litMat);
shiny_rock.setLocalTranslation(0,2,-2); // Move it a bit shinyRockGeo.setLocalTranslation(0,2,-2); // Move it a bit
shiny_rock.rotate(1.6f, 0, 0); // Rotate it a bit shinyRockGeo.rotate(1.6f, 0, 0); // Rotate it a bit
rootNode.attachChild(shiny_rock); rootNode.attachChild(shinyRockGeo);
/** Must add a light to make the lit object visible! */ /** Must add a light to make the lit object visible! */
DirectionalLight sun = new DirectionalLight(); DirectionalLight sun = new DirectionalLight();

Loading…
Cancel
Save