@ -59,35 +59,36 @@ 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 box1Me sh = new Box ( 1f , 1f , 1f ) ;
Box boxshape1 = new Box ( 1f , 1f , 1f ) ;
Geometry cubePlainGeo = new Geometry ( "My Textured Box" , box1Me sh ) ;
Geometry cube = new Geometry ( "My Textured Box" , boxshape1 ) ;
Material stlMat = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
cube . setLocalTranslation ( new Vector3f ( - 3f , 1 . 1f , 0f ) ) ;
Texture monkeyTex = assetManager . loadTexture ( "Interface/Logo/Monkey.jpg ") ;
Material mat_stl = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md ") ;
stlMat . setTexture ( "ColorMap" , monkeyTex ) ;
Texture tex_ml = assetManager . loadTexture ( "Interface/Logo/Monkey.jpg" ) ;
cubePlainGeo . setMaterial ( stlMat ) ;
mat_stl . setTexture ( "ColorMap" , tex_ml ) ;
cubePlainGeo . move ( new Vector3f ( - 3f , 1 . 1f , 0f ) ) ;
cube . setMaterial ( mat_stl ) ;
rootNode . attachChild ( cubePlainGeo ) ;
rootNode . attachChild ( cube ) ;
/** A translucent/transparent texture, similar to a window frame. */
/** A translucent/transparent texture, similar to a window frame. */
Box box3Me sh = new Box ( 1f , 1f , 0 . 01f ) ;
Box boxshape3 = new Box ( 1f , 1f , 0 . 01f ) ;
Geometry windowGeo = new Geometry ( "window frame" , box3Me sh ) ;
Geometry window_frame = new Geometry ( "window frame" , boxshape3 ) ;
Material ttMa t = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
Material ma t_ tt = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
ttMa t . setTexture ( "ColorMap" , assetManager . loadTexture ( "Textures/ColoredTex/Monkey.png" ) ) ;
ma t_ tt. setTexture ( "ColorMap" , assetManager . loadTexture ( "Textures/ColoredTex/Monkey.png" ) ) ;
ttMa t . getAdditionalRenderState ( ) . setBlendMode ( BlendMode . Alpha ) ; // activate transparency
ma t_ tt. getAdditionalRenderState ( ) . setBlendMode ( BlendMode . Alpha ) ; // activate transparency
windowGeo . setQueueBucket ( Bucket . Transparent ) ;
window_frame . setQueueBucket ( Bucket . Transparent ) ;
windowGeo . setMaterial ( ttMa t ) ;
window_frame . setMaterial ( ma t_ tt) ;
rootNode . attachChild ( windowGeo ) ;
rootNode . attachChild ( window_frame ) ;
/** A cube with its base color "bleeding" through a partially transparent texture */
Box box4Mesh = new Box ( 1f , 1f , 1f ) ;
/** A cube with its base color "leaking" through a partially transparent texture */
Geometry bleedCubeGeo = new Geometry ( "bleed-through colored cube" , box4Mesh ) ;
Box boxshape4 = new Box ( 1f , 1f , 1f ) ;
Material tlMat = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
Geometry cube_leak = new Geometry ( "Leak-through color cube" , boxshape4 ) ;
tlMat . setTexture ( "ColorMap" , assetManager . loadTexture ( "Textures/ColoredTex/Monkey.png" ) ) ;
cube_leak . setLocalTranslation ( new Vector3f ( 3f , - 1f , 0f ) ) ;
tlMat . setColor ( "Color" , new ColorRGBA ( 1f , 0f , 1f , 1f ) ) ; // purple
Material mat_tl = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
bleedCubeGeo . setMaterial ( tlMat ) ;
mat_tl . setTexture ( "ColorMap" , assetManager . loadTexture ( "Textures/ColoredTex/Monkey.png" ) ) ;
bleedCubeGeo . move ( new Vector3f ( 3f , - 1f , 0f ) ) ;
mat_tl . setColor ( "Color" , new ColorRGBA ( 1f , 0f , 1f , 1f ) ) ; // purple
rootNode . attachChild ( bleedCubeGeo ) ;
cube_leak . setMaterial ( mat_tl ) ;
//bleedCubeGeo.setMaterial((Material) assetManager.loadAsset( "Materials/BleedThrough.j3m"));
rootNode . attachChild ( cube_leak ) ;
// cube_leak.setMaterial((Material) assetManager.loadAsset( "Materials/LeakThrough.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 sphereMesh = new Sphere ( 32 , 32 , 2f ) ;
Sphere sphereMesh = new Sphere ( 32 , 32 , 2f ) ;