List of usage examples for javax.media.j3d ColoringAttributes setColor
public void setColor(Color3f color)
From source file:Erscheinungsbild.java
/** * Wurfeldarstellung// w w w .ja v a 2s. c om * * @return Appearance */ private Appearance makeAppearance() { Appearance a = new Appearance(); ColoringAttributes c = new ColoringAttributes(); c.setColor(new Color3f(0.0f, 1.0f, 0.0f)); a.setColoringAttributes(c); return a; }
From source file:PickWorld.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); Color3f gray = new Color3f(0.4f, 0.4f, 0.4f); idx = idx % 5;// www . j a v a 2 s .com switch (idx) { // Lit solid case 0: { // Set up the material properties Color3f objColor = new Color3f(0.0f, 0.8f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } // Lit solid, specular only case 1: { // Set up the material properties Color3f objColor = new Color3f(0.0f, 0.4f, 0.2f); app.setMaterial(new Material(black, black, objColor, white, 80.0f)); break; } case 2: { // Set up the texture map TextureLoader tex = new TextureLoader("apimage.jpg", this); app.setTexture(tex.getTexture()); // Set up the material properties app.setMaterial(new Material(gray, black, gray, white, 1.0f)); break; } // Texture mapped, lit solid case 3: { // Set up the texture map TextureLoader tex = new TextureLoader("earth.jpg", this); app.setTexture(tex.getTexture()); // Set up the material properties app.setMaterial(new Material(gray, black, gray, white, 1.0f)); break; } // Another lit solid with a different color case 4: { // Set up the material properties Color3f objColor = new Color3f(1.0f, 1.0f, 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; }
From source file:ConicWorld.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); idx = idx % 5;//from w ww . j a va 2 s . co m switch (idx) { // Lit solid case 0: { // 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; } // Lit solid, no specular case 1: { // Set up the material properties Color3f objColor = new Color3f(0.0f, 0.8f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } // Lit solid, specular only case 2: { // Set up the material properties Color3f objColor = new Color3f(0.0f, 0.8f, 0.8f); app.setMaterial(new Material(black, black, objColor, white, 80.0f)); break; } // Texture mapped, lit solid case 3: { // Set up the texture map TextureLoader tex = new TextureLoader(texImage, this); app.setTexture(tex.getTexture()); // Set up the material properties app.setMaterial(new Material(white, black, white, black, 1.0f)); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); app.setTextureAttributes(texAttr); break; } // Another lit solid with a different color case 4: { // Set up the material properties Color3f objColor = new Color3f(1.0f, 1.0f, 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; }
From source file:PickText3DBounds.java
public BranchGroup createSceneGraph(Canvas3D canvas) { Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); Transform3D t;//from w w w .j a va 2s. c om // 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); objScale.setTransform(t3d); objRoot.addChild(objScale); // Create a bounds for the background and lights BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Set up the background Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); objScale.addChild(bg); Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); Appearance a = new Appearance(); m.setLightingEnable(true); a.setMaterial(m); Font3D f3d = new Font3D(new Font("TestFont", Font.PLAIN, 1), new FontExtrusion()); Text3D txt = new Text3D(f3d, new String("TEXT3D"), new Point3f(-2.0f, 0.0f, 0.0f)); // txt.setCapability(Geometry.ALLOW_INTERSECT); Shape3D s3D = new Shape3D(); s3D.setGeometry(txt); s3D.setAppearance(a); // Create a transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. TransformGroup spinTg = new TransformGroup(); spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); spinTg.setCapability(TransformGroup.ENABLE_PICK_REPORTING); spinTg.addChild(s3D); objScale.addChild(spinTg); // Create the transform group node for the each light and initialize // it to the identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add them to the root // of the subgraph. // Create transformations for the positional lights t = new Transform3D(); Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0); t.set(lPos1); TransformGroup l1Trans = new TransformGroup(t); l1Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); l1Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); l1Trans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objScale.addChild(l1Trans); t = new Transform3D(); Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0); t.set(lPos2); TransformGroup l2Trans = new TransformGroup(t); l2Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); l2Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); l2Trans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objScale.addChild(l2Trans); // Create Geometry for point lights ColoringAttributes caL1 = new ColoringAttributes(); ColoringAttributes caL2 = new ColoringAttributes(); caL1.setColor(lColor1); caL2.setColor(lColor2); Appearance appL1 = new Appearance(); Appearance appL2 = new Appearance(); appL1.setColoringAttributes(caL1); appL2.setColoringAttributes(caL2); l1Trans.addChild(new Sphere(0.05f, Sphere.GENERATE_NORMALS, 15, appL1)); l2Trans.addChild(new Sphere(0.05f, Sphere.GENERATE_NORMALS, 15, appL2)); // Create lights AmbientLight aLgt = new AmbientLight(alColor); Light lgt1; Light lgt2; Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f); Point3f atten = new Point3f(1.0f, 0.0f, 0.0f); lgt1 = new PointLight(lColor1, lPoint, atten); lgt2 = new PointLight(lColor2, lPoint, atten); // Set the influencing bounds aLgt.setInfluencingBounds(bounds); lgt1.setInfluencingBounds(bounds); lgt2.setInfluencingBounds(bounds); // Add the lights into the scene graph objScale.addChild(aLgt); l1Trans.addChild(lgt1); l2Trans.addChild(lgt2); PickRotateBehavior behavior1 = new PickRotateBehavior(objRoot, canvas, bounds); behavior1.setMode(PickTool.BOUNDS); objRoot.addChild(behavior1); PickZoomBehavior behavior2 = new PickZoomBehavior(objRoot, canvas, bounds); behavior2.setMode(PickTool.BOUNDS); objRoot.addChild(behavior2); PickTranslateBehavior behavior3 = new PickTranslateBehavior(objRoot, canvas, bounds); behavior3.setMode(PickTool.BOUNDS); objRoot.addChild(behavior3); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:PickText3DGeometry.java
public BranchGroup createSceneGraph(Canvas3D canvas) { Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); Transform3D t;// ww w . ja v a 2 s. co m // 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); objScale.setTransform(t3d); objRoot.addChild(objScale); // Create a bounds for the background and lights BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Set up the background Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); objScale.addChild(bg); Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); Appearance a = new Appearance(); m.setLightingEnable(true); a.setMaterial(m); Font3D f3d = new Font3D(new Font("TestFont", Font.PLAIN, 1), new FontExtrusion()); Text3D text3D = new Text3D(f3d, new String("TEXT3D"), new Point3f(-2.0f, 0.7f, 0.0f)); text3D.setCapability(Geometry.ALLOW_INTERSECT); Shape3D s3D1 = new Shape3D(); s3D1.setGeometry(text3D); s3D1.setAppearance(a); // Create a transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. TransformGroup spinTg1 = new TransformGroup(); spinTg1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); spinTg1.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); spinTg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING); spinTg1.addChild(s3D1); objScale.addChild(spinTg1); Text3D pick = new Text3D(f3d, new String("Pick me"), new Point3f(-2.0f, -0.7f, 0.0f)); pick.setCapability(Geometry.ALLOW_INTERSECT); Shape3D s3D2 = new Shape3D(); s3D2.setGeometry(pick); s3D2.setAppearance(a); // Create a transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. TransformGroup spinTg2 = new TransformGroup(); spinTg2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); spinTg2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); spinTg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING); spinTg2.addChild(s3D2); objScale.addChild(spinTg2); // Create the transform group node for the each light and initialize // it to the identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add them to the root // of the subgraph. // Create transformations for the positional lights t = new Transform3D(); Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0); t.set(lPos1); TransformGroup l1Trans = new TransformGroup(t); l1Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); l1Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); l1Trans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objScale.addChild(l1Trans); t = new Transform3D(); Vector3d lPos2 = new Vector3d(0.5, 1.2, 2.0); t.set(lPos2); TransformGroup l2Trans = new TransformGroup(t); l2Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); l2Trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); l2Trans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objScale.addChild(l2Trans); // Create Geometry for point lights ColoringAttributes caL1 = new ColoringAttributes(); ColoringAttributes caL2 = new ColoringAttributes(); caL1.setColor(lColor1); caL2.setColor(lColor2); Appearance appL1 = new Appearance(); Appearance appL2 = new Appearance(); appL1.setColoringAttributes(caL1); appL2.setColoringAttributes(caL2); l1Trans.addChild(new Sphere(0.05f, Sphere.GENERATE_NORMALS | Sphere.ENABLE_GEOMETRY_PICKING, 15, appL1)); l2Trans.addChild(new Sphere(0.05f, Sphere.GENERATE_NORMALS | Sphere.ENABLE_GEOMETRY_PICKING, 15, appL2)); // Create lights AmbientLight aLgt = new AmbientLight(alColor); Light lgt1; Light lgt2; Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f); Point3f atten = new Point3f(1.0f, 0.0f, 0.0f); lgt1 = new PointLight(lColor1, lPoint, atten); lgt2 = new PointLight(lColor2, lPoint, atten); // Set the influencing bounds aLgt.setInfluencingBounds(bounds); lgt1.setInfluencingBounds(bounds); lgt2.setInfluencingBounds(bounds); // Add the lights into the scene graph objScale.addChild(aLgt); l1Trans.addChild(lgt1); l2Trans.addChild(lgt2); PickRotateBehavior behavior1 = new PickRotateBehavior(objRoot, canvas, bounds); behavior1.setMode(PickTool.GEOMETRY); behavior1.setTolerance(0.0f); objRoot.addChild(behavior1); PickZoomBehavior behavior2 = new PickZoomBehavior(objRoot, canvas, bounds); behavior2.setMode(PickTool.GEOMETRY); behavior2.setTolerance(0.0f); objRoot.addChild(behavior2); PickTranslateBehavior behavior3 = new PickTranslateBehavior(objRoot, canvas, bounds); behavior3.setMode(PickTool.GEOMETRY); behavior3.setTolerance(0.0f); objRoot.addChild(behavior3); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:SphereMotion.java
public BranchGroup createSceneGraph(SimpleUniverse u) { Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); Transform3D t;//from ww w .j av a2 s . c o m // 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); objScale.setTransform(t3d); objRoot.addChild(objScale); // Create a bounds for the background and lights BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Set up the background Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); objScale.addChild(bg); // Create a Sphere object, generate one copy of the sphere, // and add it into the scene graph. Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); Appearance a = new Appearance(); m.setLightingEnable(true); a.setMaterial(m); Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 80, a); objScale.addChild(sph); // Create the transform group node for the each light and initialize // it to the identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add them to the root // of the subgraph. TransformGroup l1RotTrans = new TransformGroup(); l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objScale.addChild(l1RotTrans); TransformGroup l2RotTrans = new TransformGroup(); l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objScale.addChild(l2RotTrans); // Create transformations for the positional lights t = new Transform3D(); Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0); t.set(lPos1); TransformGroup l1Trans = new TransformGroup(t); l1RotTrans.addChild(l1Trans); t = new Transform3D(); Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0); t.set(lPos2); TransformGroup l2Trans = new TransformGroup(t); l2RotTrans.addChild(l2Trans); // Create Geometry for point lights ColoringAttributes caL1 = new ColoringAttributes(); ColoringAttributes caL2 = new ColoringAttributes(); caL1.setColor(lColor1); caL2.setColor(lColor2); Appearance appL1 = new Appearance(); Appearance appL2 = new Appearance(); appL1.setColoringAttributes(caL1); appL2.setColoringAttributes(caL2); l1Trans.addChild(new Sphere(0.05f, appL1)); l2Trans.addChild(new Sphere(0.05f, appL2)); // Create lights AmbientLight aLgt = new AmbientLight(alColor); Light lgt1 = null; Light lgt2 = null; Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f); Point3f atten = new Point3f(1.0f, 0.0f, 0.0f); Vector3f lDirect1 = new Vector3f(lPos1); Vector3f lDirect2 = new Vector3f(lPos2); lDirect1.negate(); lDirect2.negate(); switch (lightType) { case DIRECTIONAL_LIGHT: lgt1 = new DirectionalLight(lColor1, lDirect1); lgt2 = new DirectionalLight(lColor2, lDirect2); break; case POINT_LIGHT: lgt1 = new PointLight(lColor1, lPoint, atten); lgt2 = new PointLight(lColor2, lPoint, atten); break; case SPOT_LIGHT: lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1, 25.0f * (float) Math.PI / 180.0f, 10.0f); lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2, 25.0f * (float) Math.PI / 180.0f, 10.0f); break; } // Set the influencing bounds aLgt.setInfluencingBounds(bounds); lgt1.setInfluencingBounds(bounds); lgt2.setInfluencingBounds(bounds); // Add the lights into the scene graph objScale.addChild(aLgt); l1Trans.addChild(lgt1); l2Trans.addChild(lgt2); // 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 rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator1 = new RotationInterpolator(rotor1Alpha, l1RotTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator1.setSchedulingBounds(bounds); l1RotTrans.addChild(rotator1); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into the // scene graph. Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 1000, 0, 0, 0, 0, 0); RotationInterpolator rotator2 = new RotationInterpolator(rotor2Alpha, l2RotTrans, yAxis, 0.0f, 0.0f); bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator2.setSchedulingBounds(bounds); l2RotTrans.addChild(rotator2); // Create a position interpolator and attach it to the view // platform TransformGroup vpTrans = u.getViewingPlatform().getViewPlatformTransform(); Transform3D axisOfTranslation = new Transform3D(); Alpha transAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 5000, 0, 0, 5000, 0, 0); axisOfTranslation.rotY(-Math.PI / 2.0); PositionInterpolator translator = new PositionInterpolator(transAlpha, vpTrans, axisOfTranslation, 2.0f, 3.5f); translator.setSchedulingBounds(bounds); objScale.addChild(translator); // Let 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 w ww .j a v a 2 s . co 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; }
From source file:TickTockPicking.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: {/*w w w.j a 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(1.0f, 0.4f, 0.0f); 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(1.0f, 1.0f, 0.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; }
From source file:HiResCoordTest.java
private TransformGroup createSun() { TransformGroup objTrans = new TransformGroup(); Appearance app = new Appearance(); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(new Color3f(1, 1, 0)); app.setColoringAttributes(ca);// ww w .jav a 2 s .c o m objTrans.addChild(createLabel("Sun", m_SunRadius * 1.1f, m_SunRadius * 1.1f, 0)); objTrans.addChild(new Sphere(m_SunRadius, app)); return objTrans; }
From source file:HiResCoordTest.java
private TransformGroup createPlanet(String szName, Color3f color, Transform3D t3d, String szTexture) { TransformGroup objTrans = new TransformGroup(t3d); Appearance app = new Appearance(); if (szTexture != null) { TextureLoader tex = new TextureLoader(szTexture, this); app.setTexture(tex.getTexture()); } else {//w w w .j a v a2 s . c o m ColoringAttributes ca = new ColoringAttributes(); ca.setColor(color); app.setColoringAttributes(ca); } objTrans.addChild(createLabel(szName, 1.2f, 1.2f, 0)); objTrans.addChild(new Sphere(1.0f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS, app)); return objTrans; }