List of usage examples for javax.media.j3d TextureAttributes TextureAttributes
public TextureAttributes()
From source file:PictureBall.java
public PictureBall() { // Create the universe SimpleUniverse universe = new SimpleUniverse(); // Create a structure to contain objects BranchGroup group = new BranchGroup(); // Set up colors Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); Color3f red = new Color3f(0.7f, .15f, .15f); // Set up the texture map TextureLoader loader = new TextureLoader("K:\\3d\\Arizona.jpg", "LUMINANCE", new Container()); Texture texture = loader.getTexture(); texture.setBoundaryModeS(Texture.WRAP); texture.setBoundaryModeT(Texture.WRAP); texture.setBoundaryColor(new Color4f(0.0f, 1.0f, 0.0f, 0.0f)); // Set up the texture attributes //could be REPLACE, BLEND or DECAL instead of MODULATE TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); Appearance ap = new Appearance(); ap.setTexture(texture);//from w w w .j av a 2 s . c o m ap.setTextureAttributes(texAttr); //set up the material ap.setMaterial(new Material(red, black, red, black, 1.0f)); // Create a ball to demonstrate textures int primflags = Primitive.GENERATE_NORMALS + Primitive.GENERATE_TEXTURE_COORDS; Sphere sphere = new Sphere(0.5f, primflags, ap); group.addChild(sphere); // Create lights Color3f light1Color = new Color3f(1f, 1f, 1f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); group.addChild(light1); AmbientLight ambientLight = new AmbientLight(new Color3f(.5f, .5f, .5f)); ambientLight.setInfluencingBounds(bounds); group.addChild(ambientLight); // look towards the ball universe.getViewingPlatform().setNominalViewingTransform(); // add the group of objects to the Universe universe.addBranchGraph(group); }
From source file:TextureImage.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);/*from www.j a v a2s. c o m*/ // Create appearance object for textured cube Appearance app = new Appearance(); Texture tex = new TextureLoader(texImage, this).getTexture(); app.setTexture(tex); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); app.setTextureAttributes(texAttr); // Create textured cube and add it to the scene graph. Box textureCube = new Box(0.4f, 0.4f, 0.4f, Box.GENERATE_TEXTURE_COORDS, app); objTrans.addChild(textureCube); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:TextureTransformTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); // create the rotation interpolator to rotate the scene RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(createApplicationBounds()); objTrans.addChild(rotator);//from w w w .jav a 2s. c o m // create the box final int nScale = 50; Appearance app = new Appearance(); Box box = new Box(nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, app); // load the texture image TextureLoader texLoader = new TextureLoader("texture.gif", this); app.setTexture(texLoader.getTexture()); // set the texture attributes and ensure we // can write to the Transform for the texture attributes m_TextureAttributes = new TextureAttributes(); m_TextureAttributes.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE); app.setTextureAttributes(m_TextureAttributes); // connect all the elements objTrans.addChild(box); objRoot.addChild(objTrans); objRoot.addChild(createRotator()); return objRoot; }
From source file:MultiTextureTest.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create a Transformgroup to scale all objects so they // appear in the scene. TransformGroup objScale = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setScale(0.4);/*from www. ja va 2 s . co m*/ objScale.setTransform(t3d); objRoot.addChild(objScale); TransformGroup objTrans = new TransformGroup(); //write-enable for behaviors objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objScale.addChild(objTrans); Appearance ap = new Appearance(); // load textures TextureAttributes texAttr1 = new TextureAttributes(); texAttr1.setTextureMode(TextureAttributes.DECAL); TextureAttributes texAttr2 = new TextureAttributes(); texAttr2.setTextureMode(TextureAttributes.MODULATE); TextureLoader tex = new TextureLoader(stoneImage, new String("RGB"), this); if (tex == null) return null; stoneTex = tex.getTexture(); tex = new TextureLoader(skyImage, new String("RGB"), this); if (tex == null) return null; skyTex = tex.getTexture(); lightTex = createLightMap(); textureUnitState[0] = new TextureUnitState(stoneTex, texAttr1, null); textureUnitState[0].setCapability(TextureUnitState.ALLOW_STATE_WRITE); textureUnitState[1] = new TextureUnitState(lightTex, texAttr2, null); textureUnitState[1].setCapability(TextureUnitState.ALLOW_STATE_WRITE); ap.setTextureUnitState(textureUnitState); //Create a Box Box BoxObj = new Box(1.5f, 1.5f, 0.8f, Box.GENERATE_NORMALS | Box.GENERATE_TEXTURE_COORDS, ap, 2); // add it to the scene graph. objTrans.addChild(BoxObj); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); //Shine it with two lights. Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f); Color3f lColor2 = new Color3f(0.2f, 0.2f, 0.1f); Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f); Vector3f lDir2 = new Vector3f(0.0f, 0.0f, -1.0f); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); DirectionalLight lgt2 = new DirectionalLight(lColor2, lDir2); lgt1.setInfluencingBounds(bounds); lgt2.setInfluencingBounds(bounds); objScale.addChild(lgt1); objScale.addChild(lgt2); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:SimpleTexture.java
/** * This defines the appearance with a texture. The texture is loaded from an * external file./* w ww. ja v a 2 s . c o m*/ * * @return Appearance that uses the texture. */ protected Appearance DefineAppearance() { //Load the texture from the external image file TextureLoader textLoad = new TextureLoader("housebrick.jpg", this); //Access the image from the loaded texture ImageComponent2D textImage = textLoad.getImage(); //Create a two dimensional texture Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB, textImage.getWidth(), textImage.getHeight()); //Set the texture from the image loaded texture.setImage(0, textImage); //Create the appearance that will use the texture Appearance app = new Appearance(); app.setTexture(texture); //Define how the texture will be mapped onto the surface //by creating the appropriate texture attributes TextureAttributes textAttr = new TextureAttributes(); textAttr.setTextureMode(TextureAttributes.REPLACE); app.setTextureAttributes(textAttr); app.setMaterial(new Material()); return app; }
From source file:OrientedTest.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objScale = new TransformGroup(); Transform3D textMat = new Transform3D(); // Assuming uniform size chars, set scale to fit string in view textMat.setScale(1.2 / sl);/*from w ww . j a v a 2s . c o m*/ objScale.setTransform(textMat); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objTrans); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Appearance apText = new Appearance(); Material m = new Material(); m.setLightingEnable(true); apText.setMaterial(m); Appearance apEarth = new Appearance(); Material mm = new Material(); mm.setLightingEnable(true); apEarth.setMaterial(mm); Appearance apStone = new Appearance(); apStone.setMaterial(mm); // create 3D text Font3D f3d = new Font3D(new Font(fontName, Font.PLAIN, 2), new FontExtrusion()); Text3D txt = new Text3D(f3d, textString, new Point3f(-sl / 2.0f, 3.0f, 0.0f)); OrientedShape3D textShape = new OrientedShape3D(); textShape.setGeometry(txt); textShape.setAppearance(apText); textShape.setAlignmentAxis(0.0f, 1.0f, 0.0f); objScale.addChild(textShape); // Create a simple shape leaf node, add it to the scene graph. Transform3D cubeMat = new Transform3D(); TransformGroup cubeTrans = new TransformGroup(cubeMat); cubeMat.set(new Vector3d(0.9, 0.0, -1.0)); cubeTrans.setTransform(cubeMat); cubeTrans.addChild(new ColorCube(0.3)); objTrans.addChild(cubeTrans); TextureLoader stoneTex = new TextureLoader(stoneImage, new String("RGB"), this); if (stoneTex != null) apStone.setTexture(stoneTex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); apStone.setTextureAttributes(texAttr); Transform3D coneMat = new Transform3D(); TransformGroup coneTrans = new TransformGroup(coneMat); coneMat.set(new Vector3d(0.0, 0.0, 0.0)); coneTrans.setTransform(coneMat); coneTrans.addChild(new Cone(.2f, 0.8f, Cone.GENERATE_NORMALS | Cone.GENERATE_TEXTURE_COORDS, apStone)); objTrans.addChild(coneTrans); TextureLoader earthTex = new TextureLoader(earthImage, new String("RGB"), this); if (earthTex != null) apEarth.setTexture(earthTex.getTexture()); apEarth.setTextureAttributes(texAttr); Transform3D cylinderMat = new Transform3D(); TransformGroup cylinderTrans = new TransformGroup(cylinderMat); cylinderMat.set(new Vector3d(-0.9, 0.5, -1.0)); cylinderTrans.setTransform(cylinderMat); cylinderTrans.addChild( new Cylinder(.35f, 2.0f, Cylinder.GENERATE_NORMALS | Cylinder.GENERATE_TEXTURE_COORDS, apEarth)); objTrans.addChild(cylinderTrans); objTrans.addChild(objScale); // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objRoot.addChild(bgNode); // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objRoot.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); objRoot.addChild(light2); apText.setMaterial(mm); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:ExTexture.java
public Group buildScene() { // Get the current menu choices for appearance attributes int textureMode = ((Integer) modes[currentMode].value).intValue(); Color3f color = (Color3f) colors[currentColor].value; Color3f blendColor = (Color3f) colors[currentBlendColor].value; // Turn on the example headlight setHeadlightEnable(true);/*from w w w . ja v a 2 s. c o m*/ // Default to examine navigation setNavigationType(Examine); // Disable scene graph compilation for this example setCompilable(false); // Create the scene group Group scene = new Group(); // BEGIN EXAMPLE TOPIC // Set up a basic material Material mat = new Material(); mat.setAmbientColor(0.2f, 0.2f, 0.2f); mat.setDiffuseColor(1.0f, 1.0f, 1.0f); mat.setSpecularColor(0.0f, 0.0f, 0.0f); mat.setLightingEnable(true); // Set up the texturing attributes with an initial // texture mode, texture transform, and blend color texatt = new TextureAttributes(); texatt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); texatt.setTextureMode(textureMode); texatt.setTextureTransform(new Transform3D()); // Identity texatt.setTextureBlendColor(blendColor.x, blendColor.y, blendColor.z, 0.5f); // Enable changing these while the node component is live texatt.setCapability(TextureAttributes.ALLOW_MODE_WRITE); texatt.setCapability(TextureAttributes.ALLOW_BLEND_COLOR_WRITE); texatt.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE); // Create an appearance using these attributes app = new Appearance(); app.setMaterial(mat); app.setTextureAttributes(texatt); app.setTexture(tex); // And enable changing these while the node component is live app.setCapability(Appearance.ALLOW_TEXTURE_WRITE); app.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE); // Build a shape and enable changing its appearance shape = new Shape3D(buildGeometry(), app); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // END EXAMPLE TOPIC // Create some dummy appearance and tex attribute node components // In response to menu choices, we quickly switch the shape to // use one of these, then diddle with the main appearance or // tex attribute, then switch the shape back. This effectively // makes the appearance or tex attributes we want to change // become un-live during a change. We have to do this approach // because some texture features have no capability bits to set // to allow changes while live. dummyApp = new Appearance(); dummyAtt = new TextureAttributes(); scene.addChild(shape); return scene; }
From source file:SimpleTextureGen.java
/** * This defines the appearance for the shape using a texture. It uses a * TextureLoader to load the texture image from an external file and a * TexCoordGeneration to define the texture coordinates. * // w ww . ja v a 2 s .c o m * @return Appearance that uses a texture. */ protected Appearance DefineAppearance() { //This is used to automatically define the texture coordinates. //The coordinates are generated in object coordinates, but by //commented out the line with 'OBJECT_LINEAR' and uncommenting //the line 'EYE_LINEAR' the program will use eye coordinates. TexCoordGeneration textCoorder = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, //TexCoordGeneration.EYE_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_2); //Load the texture from the external image file TextureLoader textLoad = new TextureLoader("housebrick.jpg", this); //Access the image from the loaded texture ImageComponent2D textImage = textLoad.getImage(); //Create a two dimensional texture Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB, textImage.getWidth(), textImage.getHeight()); //Set the texture from the image loaded texture.setImage(0, textImage); //Create the appearance that will use the texture Appearance app = new Appearance(); app.setTexture(texture); //Pass the coordinate generator to the appearance app.setTexCoordGeneration(textCoorder); //Define how the texture will be mapped onto the surface //by creating the appropriate texture attributes TextureAttributes textAttr = new TextureAttributes(); textAttr.setTextureMode(TextureAttributes.REPLACE); app.setTextureAttributes(textAttr); app.setMaterial(new Material()); return app; }
From source file:OrientedPtTest.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objScale = new TransformGroup(); Transform3D textMat = new Transform3D(); // Assuming uniform size chars, set scale to fit string in view textMat.setScale(1.2 / sl);//from w w w. ja v a2s . c o m objScale.setTransform(textMat); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objTrans); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Appearance apText = new Appearance(); Material m = new Material(); m.setLightingEnable(true); apText.setMaterial(m); Appearance apEarth = new Appearance(); Material mm = new Material(); mm.setLightingEnable(true); apEarth.setMaterial(mm); Appearance apStone = new Appearance(); apStone.setMaterial(mm); // create 3D text Font3D f3d = new Font3D(new Font(fontName, Font.PLAIN, 2), new FontExtrusion()); Point3f textPt = new Point3f(-sl / 2.0f, 3.0f, 0.0f); Text3D txt = new Text3D(f3d, textString, textPt); OrientedShape3D textShape = new OrientedShape3D(); textShape.setGeometry(txt); textShape.setAppearance(apText); textShape.setAlignmentMode(OrientedShape3D.ROTATE_ABOUT_POINT); // text is centered around 0, 3, 0. Make it rotate around 0,5,0 Point3f rotationPt = new Point3f(0.0f, 5.0f, 0.0f); textShape.setRotationPoint(rotationPt); objScale.addChild(textShape); // also add a small Sphere at the rotation point to // show that we are rotating around the right point Sphere sphere = new Sphere(0.2f); TransformGroup sphereGroup = new TransformGroup(); Transform3D sphereXform = new Transform3D(); sphereXform.set(new Vector3f(rotationPt)); sphereGroup.setTransform(sphereXform); sphereGroup.addChild(sphere); objScale.addChild(sphereGroup); // Create a simple shape leaf node, add it to the scene graph. Transform3D cubeMat = new Transform3D(); TransformGroup cubeTrans = new TransformGroup(cubeMat); cubeMat.set(new Vector3d(0.9, 0.0, -1.0)); cubeTrans.setTransform(cubeMat); cubeTrans.addChild(new ColorCube(0.3)); objTrans.addChild(cubeTrans); TextureLoader stoneTex = new TextureLoader(stoneImage, new String("RGB"), this); if (stoneTex != null) apStone.setTexture(stoneTex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.REPLACE); apStone.setTextureAttributes(texAttr); Transform3D coneMat = new Transform3D(); TransformGroup coneTrans = new TransformGroup(coneMat); coneMat.set(new Vector3d(0.0, 0.0, 0.0)); coneTrans.setTransform(coneMat); coneTrans.addChild(new Cone(.2f, 0.8f, Cone.GENERATE_NORMALS | Cone.GENERATE_TEXTURE_COORDS, apStone)); objTrans.addChild(coneTrans); TextureLoader earthTex = new TextureLoader(earthImage, new String("RGB"), this); if (earthTex != null) apEarth.setTexture(earthTex.getTexture()); apEarth.setTextureAttributes(texAttr); Transform3D cylinderMat = new Transform3D(); TransformGroup cylinderTrans = new TransformGroup(cylinderMat); cylinderMat.set(new Vector3d(-0.9, 0.5, -1.0)); cylinderTrans.setTransform(cylinderMat); cylinderTrans.addChild( new Cylinder(.35f, 2.0f, Cylinder.GENERATE_NORMALS | Cylinder.GENERATE_TEXTURE_COORDS, apEarth)); objTrans.addChild(cylinderTrans); objTrans.addChild(objScale); // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objRoot.addChild(bgNode); // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objRoot.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); objRoot.addChild(light2); apText.setMaterial(mm); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:AppearanceTest.java
private Appearance createAppearance(int idx) { Appearance app = new Appearance(); // Globally used colors Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); switch (idx) { // Unlit solid case 0: {/*from ww w. ja v a 2s. c o m*/ // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.2f, 0.4f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); break; } // Unlit wire frame case 1: { // Set up the coloring properties Color3f objColor = new Color3f(0.5f, 0.0f, 0.2f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_LINE); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); break; } // Unlit points case 2: { // Set up the coloring properties Color3f objColor = new Color3f(0.2f, 0.2f, 1.0f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_POINT); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up point attributes PointAttributes pta = new PointAttributes(); pta.setPointSize(5.0f); app.setPointAttributes(pta); break; } // Lit solid case 3: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } // Texture mapped, lit solid case 4: { // Set up the texture map TextureLoader tex = new TextureLoader(texImage, this); app.setTexture(tex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); app.setTextureAttributes(texAttr); // Set up the material properties app.setMaterial(new Material(white, black, white, black, 1.0f)); break; } // Transparent, lit solid case 5: { // Set up the transparency properties TransparencyAttributes ta = new TransparencyAttributes(); ta.setTransparencyMode(ta.BLENDED); ta.setTransparency(0.6f); app.setTransparencyAttributes(ta); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up the material properties Color3f objColor = new Color3f(0.7f, 0.8f, 1.0f); app.setMaterial(new Material(objColor, black, objColor, black, 1.0f)); break; } // Lit solid, no specular case 6: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); break; } // Lit solid, specular only case 7: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(black, black, black, white, 80.0f)); break; } // Another lit solid with a different color case 8: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.8f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } default: { ColoringAttributes ca = new ColoringAttributes(); ca.setColor(new Color3f(0.0f, 1.0f, 0.0f)); app.setColoringAttributes(ca); } } return app; }