List of usage examples for javax.media.j3d Material setSpecularColor
public void setSpecularColor(Color3f color)
From source file:Licht.java
/** * Wurfeldarstellung// w w w . ja va2 s . co m * * @return Appearance */ private Appearance makeAppearance() { Appearance a = new Appearance(); Material mat = new Material(); mat.setShininess(50.0f); mat.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f)); mat.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f)); a.setMaterial(mat); return a; }
From source file:BasicConstruct.java
/** * Adds a box to the universe//from ww w. j av a2s. co m * * @param x * The x dimension of the box * @param y * The y dimension of the box * @param z * The z dimension of the box */ public void addBox(float x, float y, float z, Color3f diffuse, Color3f spec) { // Add a box with the given dimension // First setup an appearance for the box Appearance app = new Appearance(); Material mat = new Material(); mat.setDiffuseColor(diffuse); mat.setSpecularColor(spec); mat.setShininess(5.0f); app.setMaterial(mat); Box box = new Box(x, y, z, app); // Create a TransformGroup and make it the parent of the box TransformGroup tg = new TransformGroup(); tg.addChild(box); // Then add it to the rootBranchGroup rootBranchGroup.addChild(tg); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); MouseRotate myMouseRotate = new MouseRotate(); myMouseRotate.setTransformGroup(tg); myMouseRotate.setSchedulingBounds(new BoundingSphere()); rootBranchGroup.addChild(myMouseRotate); MouseTranslate myMouseTranslate = new MouseTranslate(); myMouseTranslate.setTransformGroup(tg); myMouseTranslate.setSchedulingBounds(new BoundingSphere()); rootBranchGroup.addChild(myMouseTranslate); MouseZoom myMouseZoom = new MouseZoom(); myMouseZoom.setTransformGroup(tg); myMouseZoom.setSchedulingBounds(new BoundingSphere()); rootBranchGroup.addChild(myMouseZoom); }
From source file:SpotLightApp.java
Appearance createMatAppear(Color3f dColor, Color3f sColor, float shine) { Appearance appear = new Appearance(); Material material = new Material(); material.setDiffuseColor(dColor);// ww w. jav a 2 s . c o m material.setSpecularColor(sColor); material.setShininess(shine); appear.setMaterial(material); return appear; }
From source file:AlternateAppearanceScopeTest.java
public SphereGroup(float radius, float xSpacing, float ySpacing, int xCount, int yCount, Appearance app, boolean overrideflag) { if (app == null) { app = new Appearance(); Material material = new Material(); material.setDiffuseColor(new Color3f(0.8f, 0.8f, 0.8f)); material.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f)); material.setShininess(0.0f);// w w w. ja va 2 s .c o m app.setMaterial(material); } double xStart = -xSpacing * (double) (xCount - 1) / 2.0; double yStart = -ySpacing * (double) (yCount - 1) / 2.0; Sphere sphere = null; TransformGroup trans = null; Transform3D t3d = new Transform3D(); Vector3d vec = new Vector3d(); double x, y = yStart, z = 0.0; shapes = new Shape3D[xCount * yCount]; for (int i = 0; i < yCount; i++) { x = xStart; for (int j = 0; j < xCount; j++) { vec.set(x, y, z); t3d.setTranslation(vec); trans = new TransformGroup(t3d); addChild(trans); sphere = new Sphere(radius, // sphere radius Primitive.GENERATE_NORMALS, // generate normals 16, // 16 divisions radially app); // it's appearance trans.addChild(sphere); x += xSpacing; shapes[numShapes] = sphere.getShape(); if (overrideflag) shapes[numShapes].setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE); numShapes++; } y += ySpacing; } }
From source file:ExSpotLight.java
public SphereGroup(float radius, float xSpacing, float ySpacing, int xCount, int yCount, Appearance app) { if (app == null) { app = new Appearance(); Material material = new Material(); material.setDiffuseColor(new Color3f(0.8f, 0.8f, 0.8f)); material.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f)); material.setShininess(0.0f);/* w w w.j a v a 2s .c o m*/ app.setMaterial(material); } double xStart = -xSpacing * (double) (xCount - 1) / 2.0; double yStart = -ySpacing * (double) (yCount - 1) / 2.0; Sphere sphere = null; TransformGroup trans = null; Transform3D t3d = new Transform3D(); Vector3d vec = new Vector3d(); double x, y = yStart, z = 0.0; for (int i = 0; i < yCount; i++) { x = xStart; for (int j = 0; j < xCount; j++) { vec.set(x, y, z); t3d.setTranslation(vec); trans = new TransformGroup(t3d); addChild(trans); sphere = new Sphere(radius, // sphere radius Primitive.GENERATE_NORMALS, // generate normals 16, // 16 divisions radially app); // it's appearance trans.addChild(sphere); x += xSpacing; } y += ySpacing; } }