List of usage examples for javax.media.j3d Appearance Appearance
public Appearance()
From source file:BehaviorTest.java
public void addBehaviorToParentGroup(Group nodeParentGroup) { nodeParentGroup.addChild(this); m_TransformGroup = new TransformGroup(); m_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); m_BoundsSwitch = new Switch(); m_BoundsSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); Appearance app = new Appearance(); PolygonAttributes polyAttrbutes = new PolygonAttributes(); polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE); polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE); app.setPolygonAttributes(polyAttrbutes); m_BoundsSwitch.addChild(new Sphere(1, app)); ColorCube cube = new ColorCube(); cube.setAppearance(app);/*from w w w .j a v a 2 s.c o m*/ Group g = new Group(); g.addChild(cube); m_BoundsSwitch.addChild(g); m_BoundsSwitch.setWhichChild(Switch.CHILD_NONE); m_TransformGroup.addChild(m_BoundsSwitch); nodeParentGroup.addChild(m_TransformGroup); }
From source file:SwingTest.java
/** * Create a BranchGroup that contains a Sphere. The user data for the * BranchGroup is set so the BranchGroup can be identified. *//*from www . j a v a2s. co m*/ protected BranchGroup createSphere() { BranchGroup bg = new BranchGroup(); bg.setCapability(BranchGroup.ALLOW_DETACH); Appearance app = new Appearance(); Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); bg.addChild(new com.sun.j3d.utils.geometry.Sphere(1, app)); bg.setUserData("Sphere"); return bg; }
From source file:ExBackgroundImage.java
public TowerScene(Component observer) { BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Add a few lights AmbientLight ambient = new AmbientLight(); ambient.setEnable(true);/* w w w. j ava2 s . c o m*/ ambient.setColor(new Color3f(0.2f, 0.2f, 0.2f)); ambient.setInfluencingBounds(worldBounds); addChild(ambient); DirectionalLight dir1 = new DirectionalLight(); dir1.setEnable(true); dir1.setColor(new Color3f(1.0f, 0.15f, 0.15f)); dir1.setDirection(new Vector3f(0.8f, -0.35f, -0.5f)); dir1.setInfluencingBounds(worldBounds); addChild(dir1); DirectionalLight dir2 = new DirectionalLight(); dir2.setEnable(true); dir2.setColor(new Color3f(0.15f, 0.15f, 1.0f)); dir2.setDirection(new Vector3f(-0.7f, -0.35f, 0.5f)); dir2.setInfluencingBounds(worldBounds); addChild(dir2); // Load textures TextureLoader texLoader = new TextureLoader("moon5.jpg", observer); Texture moon = texLoader.getTexture(); if (moon == null) System.err.println("Cannot load moon5.jpg texture"); else { moon.setBoundaryModeS(Texture.WRAP); moon.setBoundaryModeT(Texture.WRAP); moon.setMinFilter(Texture.NICEST); moon.setMagFilter(Texture.NICEST); moon.setMipMapMode(Texture.BASE_LEVEL); moon.setEnable(true); } texLoader = new TextureLoader("stonebrk2.jpg", observer); Texture stone = texLoader.getTexture(); if (stone == null) System.err.println("Cannot load stonebrk2.jpg texture"); else { stone.setBoundaryModeS(Texture.WRAP); stone.setBoundaryModeT(Texture.WRAP); stone.setMinFilter(Texture.NICEST); stone.setMagFilter(Texture.NICEST); stone.setMipMapMode(Texture.BASE_LEVEL); stone.setEnable(true); } // // Build a rough terrain // Appearance moonApp = new Appearance(); Material moonMat = new Material(); moonMat.setAmbientColor(0.5f, 0.5f, 0.5f); moonMat.setDiffuseColor(1.0f, 1.0f, 1.0f); moonMat.setSpecularColor(0.0f, 0.0f, 0.0f); moonApp.setMaterial(moonMat); TextureAttributes moonTexAtt = new TextureAttributes(); moonTexAtt.setTextureMode(TextureAttributes.MODULATE); moonTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); moonApp.setTextureAttributes(moonTexAtt); if (moon != null) moonApp.setTexture(moon); CraterGrid grid = new CraterGrid(50, 50, // grid dimensions 1.0, 1.0, // grid spacing 4.0, // height exageration factor craters, // grid elevations moonApp); // grid appearance addChild(grid); // // Build several towers on the terrain // SharedGroup tower = new SharedGroup(); Appearance towerApp = new Appearance(); Material towerMat = new Material(); towerMat.setAmbientColor(0.6f, 0.6f, 0.6f); towerMat.setDiffuseColor(1.0f, 1.0f, 1.0f); towerMat.setSpecularColor(0.0f, 0.0f, 0.0f); towerApp.setMaterial(towerMat); Transform3D tr = new Transform3D(); tr.setScale(new Vector3d(4.0, 4.0, 1.0)); TextureAttributes towerTexAtt = new TextureAttributes(); towerTexAtt.setTextureMode(TextureAttributes.MODULATE); towerTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); towerTexAtt.setTextureTransform(tr); towerApp.setTextureAttributes(towerTexAtt); if (stone != null) towerApp.setTexture(stone); Arch towerShape = new Arch(0.0, // start Phi 1.571, // end Phi 2, // nPhi 0.0, // start Theta Math.PI * 2.0, // end Theta 5, // nTheta 3.0, // start radius 8.0, // end radius 0.0, // start phi thickness 0.0, // end phi thickness towerApp); // appearance tower.addChild(towerShape); // Place towers Matrix3f rot = new Matrix3f(); rot.setIdentity(); TransformGroup tg = new TransformGroup(new Transform3D(rot, new Vector3d(2.0, -3.0, -8.0), 1.0)); tg.addChild(new Link(tower)); addChild(tg); tg = new TransformGroup(new Transform3D(rot, new Vector3d(-1.0, -3.0, -6.0), 0.5)); tg.addChild(new Link(tower)); addChild(tg); tg = new TransformGroup(new Transform3D(rot, new Vector3d(5.0, -3.0, -6.0), 0.75)); tg.addChild(new Link(tower)); addChild(tg); tg = new TransformGroup(new Transform3D(rot, new Vector3d(1.0, -3.0, -3.0), 0.35)); tg.addChild(new Link(tower)); addChild(tg); }
From source file:PlatformTest.java
ViewerAvatar createViewerAvatar(String szText, Color3f objColor) { ViewerAvatar viewerAvatar = new ViewerAvatar(); // rotate the Cone so that it is lying down and // points sharp-end towards the Viewer's field of view. TransformGroup tg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setEuler(new Vector3d(Math.PI / 2.0, Math.PI, 0)); tg.setTransform(t3d);/*w ww. j a va 2 s . c o m*/ // create appearance and material for the Cone Appearance app = new Appearance(); Color3f black = new Color3f(0.4f, 0.2f, 0.1f); app.setMaterial(new Material(objColor, black, objColor, black, 90.0f)); // create the Primitive and add to the parent BranchGroup tg.addChild(new Cone(1, 3, Primitive.GENERATE_NORMALS, app)); viewerAvatar.addChild(tg); return viewerAvatar; }
From source file:ViewProj.java
public BranchGroup createVWorldViewSG() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); objRoot.setCapability(BranchGroup.ALLOW_DETACH); // setup a transform group to hold the scaled scene TransformGroup objTrans = new TransformGroup(); objRoot.addChild(objTrans);//from ww w. java 2 s .com // get the eye point, field of view and clip distances float fov = (float) view.getFieldOfView(); // figure out the angle factors to find points along the edges // of the FOV // X = fovSpreadX * (Y - eyeVW.y) + eyeVW.x; float fovSpreadX = (float) Math.tan(fov / 2); // Z = fovSpreadZ * (X - eyeVW.x) + eyeVW.z; float fovSpreadZ = 1.0f / fovSpreadX; //System.out.println("fovSpreadX = " + fovSpreadX); //System.out.println("fovSpreadZ = " + fovSpreadZ); Transform3D vpTransform = new Transform3D(); viewingPlatform.getViewPlatformTransform().getTransform(vpTransform); Vector3f vpTranslation = new Vector3f(); vpTransform.get(vpTranslation); eyePtVW.set(vpTranslation); eyePtVW.negate(); // get the eye point in our 2D coord system. Point3f eyePt = new Point3f(0.0f, eyePtVW.z, 0.1f); float frontClipDist = (float) view.getFrontClipDistance(); float backClipDist = (float) view.getBackClipDistance(); // set up the clip plane lines Point3f[] cpPoints = new Point3f[5]; cpPoints[0] = new Point3f(frontClipDist * fovSpreadX, eyePtVW.z + frontClipDist, 0.1f); cpPoints[1] = new Point3f(cpPoints[0]); cpPoints[1].x *= -1; Point3f backLeft = new Point3f(-backClipDist * fovSpreadX, eyePtVW.z + backClipDist, 0.1f); cpPoints[2] = backLeft; Point3f backRight = new Point3f(backLeft); backRight.x *= -1; cpPoints[3] = backRight; cpPoints[4] = cpPoints[0]; //for (int i = 0; i < 4; i++) { // System.out.println("cpPoints[" + i + "] = " + cpPoints[i]); //} int[] cpLength = new int[1]; cpLength[0] = 5; LineStripArray cpLines = new LineStripArray(5, LineArray.COORDINATES, cpLength); cpLines.setCoordinates(0, cpPoints); Appearance cpApp = new Appearance(); ColoringAttributes cpCa = new ColoringAttributes(blue, ColoringAttributes.SHADE_FLAT); cpApp.setColoringAttributes(cpCa); Shape3D cpShape = new Shape3D(cpLines, cpApp); objTrans.addChild(cpShape); // get the limits of the space float minY = eyePt.y; float maxY = backLeft.y; float minX = backLeft.x; float maxX = backRight.x; // figure out the X and Y extents and offsets float deltaX = maxX - minX; float deltaY = maxY - minY; float offsetX = -(maxX + minX) / 2.0f; float offsetY = -(maxY + minY) / 2.0f; float gridSize = Math.max(deltaX, deltaY); // scale the grid slightly to give a border around the edge gridSize *= 1.1f; //System.out.println("offsetX = " + offsetX); //System.out.println("offsetY = " + offsetY); // Scale the view to fit -1 to 1 Transform3D trans = new Transform3D(); trans.set(new Vector3f(offsetX, offsetY, 0.0f), 2.0f / gridSize); objTrans.setTransform(trans); // figure out a grid step that is a multiple of 10 which keeps the // number of steps less than 30. float gridStep = 1.0f; while ((gridSize / gridStep) > 30.0) { gridStep *= 10; } int gridNumSteps = (int) Math.ceil(gridSize / gridStep) + 1; // allocate the grid points array, four points for each step (x and y) // with a couple extra points for the extra grid points added // below int gridNumPoints = 4 * (gridNumSteps + 4); Point3f[] gridPts = new Point3f[gridNumPoints]; for (int i = 0; i < gridNumPoints; i++) { gridPts[i] = new Point3f(); } // find the grid limits. Add a step on each side to make sure // the grid is larger than the view float gridMinY = gridStepFloor(minY, gridStep) - gridStep; float gridMaxY = gridStepCeil(maxY, gridStep) + gridStep; float gridMinX = gridStepFloor(minX, gridStep) - gridStep; float gridMaxX = gridStepCeil(maxX, gridStep) + gridStep; //System.out.println("gridMinY = " + gridMinY); //System.out.println("gridMaxY = " + gridMaxY); //System.out.println("gridMinX = " + gridMinX); //System.out.println("gridMaxX = " + gridMaxX); // set up the background grid Appearance bgApp = new Appearance(); ColoringAttributes bgCa = new ColoringAttributes(); bgCa.setColor(grey); LineAttributes bgLa = new LineAttributes(); bgApp.setColoringAttributes(bgCa); // clear out the clip grid point list numClipGridPts = 0; // set up the vertical lines int numPts = 0; for (float x = gridMinX; x <= gridMaxX; x += gridStep) { gridPts[numPts].x = x; gridPts[numPts].y = gridMinY; gridPts[numPts].z = -0.2f; gridPts[numPts + 1].x = x; gridPts[numPts + 1].y = gridMaxY; gridPts[numPts + 1].z = -0.2f; numPts += 2; // try to add a line to the clipped grid // find the intersection of the clipped line with the FOV sides // this is a distance relative to the eye float clipZ = fovSpreadZ * Math.abs(x - eyePtVW.x); if (clipZ < frontClipDist) { // clip to front clip plane clipZ = frontClipDist; } if (clipZ < backClipDist) { // clip to back clip plane // line is not clipped clipGridPtsVW[numClipGridPts].x = x; clipGridPtsVW[numClipGridPts].y = clipZ + eyePtVW.z; clipGridPtsVW[numClipGridPts].z = -0.1f; clipGridPtsVW[numClipGridPts + 1].x = x; clipGridPtsVW[numClipGridPts + 1].y = backClipDist + eyePtVW.z; clipGridPtsVW[numClipGridPts + 1].z = -0.1f; numClipGridPts += 2; } } LineArray vertLa = new LineArray(numPts, LineArray.COORDINATES); vertLa.setCoordinates(0, gridPts, 0, numPts); Shape3D vertShape = new Shape3D(vertLa, bgApp); objTrans.addChild(vertShape); // set up the horizontal lines numPts = 0; for (float y = gridMinY; y <= gridMaxY; y += gridStep) { gridPts[numPts].x = gridMinX; gridPts[numPts].y = y; gridPts[numPts++].z = -0.2f; gridPts[numPts].x = gridMaxX; gridPts[numPts].y = y; gridPts[numPts++].z = -0.2f; // try to add a line to the clipped grid // find the intersection of the clipped line with the FOV sides // this is a distance relative to the eye float clipDist = (y - eyePtVW.z); if ((clipDist > frontClipDist) && (clipDist < backClipDist)) { float clipX = fovSpreadX * clipDist; clipGridPtsVW[numClipGridPts].x = -clipX; clipGridPtsVW[numClipGridPts].y = y; clipGridPtsVW[numClipGridPts].z = -0.1f; clipGridPtsVW[numClipGridPts + 1].x = clipX; clipGridPtsVW[numClipGridPts + 1].y = y; clipGridPtsVW[numClipGridPts + 1].z = -0.1f; numClipGridPts += 2; } } LineArray horizLa = new LineArray(numPts, LineArray.COORDINATES); horizLa.setCoordinates(0, gridPts, 0, numPts); Shape3D horizShape = new Shape3D(horizLa, bgApp); objTrans.addChild(horizShape); // draw the clipped grid. if (numClipGridPts > 0) { LineArray clipLa = new LineArray(numClipGridPts, LineArray.COORDINATES); clipLa.setCoordinates(0, clipGridPtsVW, 0, numClipGridPts); Appearance clipGridApp = new Appearance(); ColoringAttributes clipCa = new ColoringAttributes(black, ColoringAttributes.SHADE_FLAT); clipGridApp.setColoringAttributes(clipCa); LineAttributes clipGridLa = new LineAttributes(); Shape3D clipShape = new Shape3D(clipLa, clipGridApp); objTrans.addChild(clipShape); } // set up the coordinate system Appearance coordSysApp = new Appearance(); LineAttributes coordSysLa = new LineAttributes(); coordSysLa.setLineWidth(3.0f); coordSysApp.setLineAttributes(coordSysLa); ColoringAttributes coordSysCa = new ColoringAttributes(grey, ColoringAttributes.SHADE_FLAT); coordSysApp.setColoringAttributes(coordSysCa); Point3f[] coordSysPts = new Point3f[4]; coordSysPts[0] = new Point3f(gridMinX, 0, -0.5f); coordSysPts[1] = new Point3f(gridMaxX, 0, -0.5f); coordSysPts[2] = new Point3f(0, gridMinY, -0.5f); coordSysPts[3] = new Point3f(0, gridMaxY, -0.5f); LineArray coordSysLines = new LineArray(4, LineArray.COORDINATES); coordSysLines.setCoordinates(0, coordSysPts); Shape3D coordSysShape = new Shape3D(coordSysLines, coordSysApp); objTrans.addChild(coordSysShape); // set up the circle Appearance circleApp = new Appearance(); ColoringAttributes circleCa = new ColoringAttributes(); circleCa.setColor(red); circleApp.setColoringAttributes(circleCa); PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(PolygonAttributes.CULL_NONE); circleApp.setPolygonAttributes(pa); int step = 360 / (numCirclePts - 1); for (int deg = 0; deg < 360; deg += step) { double angle = Math.toRadians(deg); circlePtsVW[deg / 10].x = sphereRadius * (float) Math.sin(angle); circlePtsVW[deg / 10].y = sphereRadius * (float) Math.cos(angle); circlePtsVW[deg / 10].z = -0.3f; } circlePtsVW[numCirclePts - 1].set(circlePtsVW[0]); int[] lineStripLength = new int[1]; lineStripLength[0] = numCirclePts; //LineStripArray circleLineStrip = new LineStripArray(numCirclePts, // LineArray.COORDINATES, lineStripLength); TriangleFanArray circleLineStrip = new TriangleFanArray(numCirclePts, LineArray.COORDINATES, lineStripLength); circleLineStrip.setCoordinates(0, circlePtsVW); Shape3D circleShape = new Shape3D(circleLineStrip, circleApp); objTrans.addChild(circleShape); return objRoot; }
From source file:SplineAnim.java
public BranchGroup createSceneGraph() { // Colors for lights and objects Color3f aColor = new Color3f(0.2f, 0.2f, 0.2f); Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); Color3f coneColor = new Color3f(0.9f, 0.1f, 0.1f); Color3f sphereColor = new Color3f(0.1f, 0.7f, 0.9f); Color3f bgColor = new Color3f(0.0f, 0.0f, 0.0f); Color3f lightColor = new Color3f(1.0f, 1.0f, 1.0f); // Root of the branch grsph BranchGroup root = new BranchGroup(); // Create transforms such that all objects appears in the scene sceneTransform = new Transform3D(); sceneTransform.setScale(0.14f);/*www.j a va 2 s .c om*/ Transform3D yrot = new Transform3D(); yrot.rotY(-Math.PI / 5.0d); sceneTransform.mul(yrot); sceneTransformGroup = new TransformGroup(sceneTransform); sceneTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); sceneTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); root.addChild(sceneTransformGroup); // Create bounds for the background and lights bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0f); // Set up the background Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); sceneTransformGroup.addChild(bg); // Create the transform group node for the lights lightTransform1 = new Transform3D(); lightTransform2 = new Transform3D(); Vector3d lightPos1 = new Vector3d(0.0, 0.0, 2.0); Vector3d lightPos2 = new Vector3d(1.0, 0.0, -2.0); lightTransform1.set(lightPos1); lightTransform2.set(lightPos2); light1TransformGroup = new TransformGroup(lightTransform1); light2TransformGroup = new TransformGroup(lightTransform2); sceneTransformGroup.addChild(light1TransformGroup); sceneTransformGroup.addChild(light2TransformGroup); // Create lights AmbientLight ambLight = new AmbientLight(aColor); Light dirLight1; Light dirLight2; Vector3f lightDir1 = new Vector3f(lightPos1); Vector3f lightDir2 = new Vector3f(lightPos2); lightDir1.negate(); lightDir2.negate(); dirLight1 = new DirectionalLight(lightColor, lightDir1); dirLight2 = new DirectionalLight(lightColor, lightDir2); // Set the influencing bounds ambLight.setInfluencingBounds(bounds); dirLight1.setInfluencingBounds(bounds); dirLight2.setInfluencingBounds(bounds); // Add the lights into the scene graph sceneTransformGroup.addChild(ambLight); sceneTransformGroup.addChild(dirLight1); sceneTransformGroup.addChild(dirLight2); // Create a cone and add it to the scene graph. objTransform = new Transform3D(); objTransformGroup = new TransformGroup(objTransform); objTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); sceneTransformGroup.addChild(objTransformGroup); Material m = new Material(coneColor, eColor, coneColor, sColor, 100.0f); Appearance a = new Appearance(); m.setLightingEnable(true); a.setMaterial(m); Cone cone = new Cone(0.4f, 1.0f); cone.setAppearance(a); objTransformGroup.addChild(cone); // Create transform groups for each knot point // knot point 0 Transform3D t3dKnot = new Transform3D(); t3dKnot.set(pos0); TransformGroup k0TransformGroup = new TransformGroup(t3dKnot); sceneTransformGroup.addChild(k0TransformGroup); // knot point 1 t3dKnot = new Transform3D(); t3dKnot.set(pos1); TransformGroup k1TransformGroup = new TransformGroup(t3dKnot); sceneTransformGroup.addChild(k1TransformGroup); // knot point 2 t3dKnot = new Transform3D(); t3dKnot.set(pos2); TransformGroup k2TransformGroup = new TransformGroup(t3dKnot); sceneTransformGroup.addChild(k2TransformGroup); // knot point 3 t3dKnot = new Transform3D(); t3dKnot.set(pos3); TransformGroup k3TransformGroup = new TransformGroup(t3dKnot); sceneTransformGroup.addChild(k3TransformGroup); // knot point 4 t3dKnot = new Transform3D(); t3dKnot.set(pos4); TransformGroup k4TransformGroup = new TransformGroup(t3dKnot); sceneTransformGroup.addChild(k4TransformGroup); // knot point 5 t3dKnot = new Transform3D(); t3dKnot.set(pos5); TransformGroup k5TransformGroup = new TransformGroup(t3dKnot); sceneTransformGroup.addChild(k5TransformGroup); // Create spheres for each knot point's transform group ColoringAttributes sphereColorAttr = new ColoringAttributes(); sphereColorAttr.setColor(sphereColor); Appearance sphereAppearance = new Appearance(); sphereAppearance.setColoringAttributes(sphereColorAttr); k0TransformGroup.addChild(new Sphere(0.10f, sphereAppearance)); k1TransformGroup.addChild(new Sphere(0.10f, sphereAppearance)); k2TransformGroup.addChild(new Sphere(0.10f, sphereAppearance)); k3TransformGroup.addChild(new Sphere(0.10f, sphereAppearance)); k4TransformGroup.addChild(new Sphere(0.10f, sphereAppearance)); k5TransformGroup.addChild(new Sphere(0.10f, sphereAppearance)); return root; }
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);/*w ww. jav a2 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:J3dSwingFrame.java
/** * Construct the default appearance./*w ww . j a va2 s .com*/ */ private void constructAppearance() { appearance = new Appearance(); TextureAttributes tex_attr = new TextureAttributes(); tex_attr.setTextureMode(TextureAttributes.DECAL); tex_attr.setPerspectiveCorrectionMode(TextureAttributes.FASTEST); appearance.setTextureAttributes(tex_attr); ColoringAttributes col_attr = new ColoringAttributes(); col_attr.setShadeModel(ColoringAttributes.SHADE_GOURAUD); appearance.setColoringAttributes(col_attr); PolygonAttributes rend_attr = new PolygonAttributes(); rend_attr.setCullFace(PolygonAttributes.CULL_NONE); // uncomment this if you want it to display in line draw mode // rend_attr.setPolygonMode(PolygonAttributes.POLYGON_LINE); appearance.setPolygonAttributes(rend_attr); Material mat = new Material(); // Color3f col = new Color3f(1, 0, 0); // mat.setEmissiveColor(col); appearance.setMaterial(mat); setAppearance(appearance); }
From source file:SplineInterpolatorTest.java
public Group createLand(Group g) { Land land = new Land(this, g, ComplexObject.GEOMETRY | ComplexObject.TEXTURE); Group hiResGroup = land.createObject(new Appearance(), new Vector3d(), new Vector3d(LAND_WIDTH, 1, LAND_LENGTH), "boston.gif", null, null); Appearance app = new Appearance(); app.setColoringAttributes(new ColoringAttributes(WATER_COLOR_RED / 255f, WATER_COLOR_GREEN / 255f, WATER_COLOR_BLUE / 255f, ColoringAttributes.FASTEST)); Land base = new Land(this, hiResGroup, ComplexObject.GEOMETRY); base.createObject(app, new Vector3d(0, -5, 0), new Vector3d(4 * LAND_WIDTH, 1, 4 * LAND_LENGTH), null, null, null);/* ww w . j a v a 2 s .c o m*/ return hiResGroup; }
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. ja va 2 s .co 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; }