List of usage examples for javax.media.j3d Shape3D ALLOW_APPEARANCE_WRITE
int ALLOW_APPEARANCE_WRITE
To view the source code for javax.media.j3d Shape3D ALLOW_APPEARANCE_WRITE.
Click Source Link
From source file:ImageComponentByReferenceTest.java
public BranchGroup createSceneGraph() { objRoot = new BranchGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(Group.ALLOW_CHILDREN_WRITE); objRoot.addChild(objTrans);//from w w w . j av a 2 s.co m BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); app.setCapability(Appearance.ALLOW_TEXTURE_WRITE); textureCube = new Box(0.4f, 0.4f, 0.4f, Box.GENERATE_TEXTURE_COORDS | Box.GENERATE_NORMALS, app); boxShape = textureCube.getShape(Box.FRONT); boxShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); objTrans.addChild(textureCube); checkBoard = new TiledImage(); TextureLoader texLoader = new TextureLoader(texImage, this); ImageComponent2D oneImage = texLoader.getImage(); bImage1 = oneImage.getImage(); int index = 0; image[index++] = new ImageComponent2D(oneImage.getFormat(), (RenderedImage) bImage1, false, true); image[index++] = new ImageComponent2D(oneImage.getFormat(), (RenderedImage) bImage1, true, true); image[index++] = new ImageComponent2D(oneImage.getFormat(), (RenderedImage) bImage1, false, false); image[index++] = new ImageComponent2D(oneImage.getFormat(), (RenderedImage) bImage1, true, false); createRaster(objRoot); image[index++] = new ImageComponent2D(ImageComponent.FORMAT_RGBA, checkBoard, false, true); image[index++] = new ImageComponent2D(ImageComponent.FORMAT_RGBA, checkBoard, true, true); image[index++] = new ImageComponent2D(ImageComponent.FORMAT_RGBA, checkBoard, false, false); image[index++] = new ImageComponent2D(ImageComponent.FORMAT_RGBA, checkBoard, true, false); texOne = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image[2].getWidth(), image[2].getHeight()); texOne.setCapability(Texture.ALLOW_IMAGE_WRITE); texOne.setImage(0, image[2]); app.setTexture(texOne); texCheckBoard = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image[4].getWidth(), image[4].getHeight()); texCheckBoard.setCapability(Texture.ALLOW_IMAGE_WRITE); objRoot.compile(); return objRoot; }
From source file:BooksDemo.java
public void createScene() { BufferedImage image = new BufferedImage(xpanel.getWidth(), xpanel.getHeight(), BufferedImage.TYPE_INT_RGB); getContentPane().paint(image.getGraphics()); BufferedImage subImage = new BufferedImage(CANVAS3D_WIDTH, CANVAS3D_HEIGHT, BufferedImage.TYPE_INT_RGB); ((Graphics2D) subImage.getGraphics()).drawImage(image, null, -c3d.getX(), -c3d.getY()); Background bg = new Background(new ImageComponent2D(ImageComponent2D.FORMAT_RGB, subImage)); BoundingSphere bounds = new BoundingSphere(); bounds.setRadius(100.0);/* w w w. ja va 2 s . c om*/ bg.setApplicationBounds(bounds); BranchGroup objRoot = new BranchGroup(); objRoot.addChild(bg); TransformGroup objTg = new TransformGroup(); objTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D yAxis = new Transform3D(); rotor1Alpha = new Alpha(1, 400); rotator1 = new RotationInterpolator(rotor1Alpha, objTg, yAxis, (float) Math.PI * 1.0f, (float) Math.PI * 2.0f); rotator1.setSchedulingBounds(bounds); textures.put("pages_top", createTexture("pages_top.jpg")); textures.put("pages", createTexture("amazon.jpg")); textures.put("amazon", createTexture("amazon.jpg")); textures.put("cover1", createTexture("cover1.jpg")); textures.put("cover2", createTexture("cover2.jpg")); textures.put("cover3", createTexture("cover3.jpg")); book = new com.sun.j3d.utils.geometry.Box(0.5f, 0.7f, 0.15f, com.sun.j3d.utils.geometry.Box.GENERATE_TEXTURE_COORDS, new Appearance()); book.getShape(book.TOP).setAppearance((Appearance) textures.get("pages_top")); book.getShape(book.RIGHT).setAppearance((Appearance) textures.get("pages")); book.getShape(book.LEFT).setAppearance((Appearance) textures.get("amazon")); book.getShape(book.FRONT).setAppearance((Appearance) textures.get("cover1")); book.getShape(book.BACK).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); book.getShape(book.FRONT).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // book.getShape(book.LEFT).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // book.getShape(book.RIGHT).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); objTg.addChild(book); objTg.addChild(rotator1); Transform3D spin = new Transform3D(); Transform3D tempspin = new Transform3D(); spin.rotX(Math.PI / 8.0d); tempspin.rotY(Math.PI / 7.0d); spin.mul(tempspin); TransformGroup objTrans = new TransformGroup(spin); objTrans.addChild(objTg); objRoot.addChild(objTrans); SimpleUniverse u = new SimpleUniverse(c3d); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(objRoot); View view = u.getViewer().getView(); view.setSceneAntialiasingEnable(true); }
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. j av a 2 s . c om // 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:PickTest.java
private Group createObject(int index, double scale, double xpos, double ypos) { Shape3D shape = null;//ww w.j a va2 s.c om Geometry geom = null; // Create a transform group node to scale and position the object. Transform3D t = new Transform3D(); t.set(scale, new Vector3d(xpos, ypos, 0.0)); TransformGroup objTrans = new TransformGroup(t); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); // Create a second 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); Appearance appearance = new Appearance(); switch (index) { case 0: geom = new GullCG(); break; case 1: geom = new TetrahedronTA(); break; case 2: geom = new OctahedronTFA(); break; case 3: geom = new IcosahedronTSA(); break; case 4: geom = new CubeIQA(); break; case 5: geom = new TetrahedronITA(); break; case 6: geom = new OctahedronITFA(); break; case 7: geom = new IcosahedronITSA(); break; case 8: geomMorph[0] = new ColorPyramidUp(); geomMorph[1] = new ColorCube(); geomMorph[2] = new ColorPyramidDown(); break; case 9: geom = new TetrahedronLA(); break; case 10: geom = new TetrahedronILA(); break; case 11: geom = new TetrahedronLSA(); break; case 12: geom = new TetrahedronILSA(); break; case 13: geom = new TetrahedronPA(); break; case 14: geom = new TetrahedronIPA(); break; // TODO: other geo types, Text3D? case 15: geom = new TetrahedronTA(); break; } Material m = new Material(); if (index == 8) { m.setLightingEnable(false); appearance.setMaterial(m); morph = new Morph((GeometryArray[]) geomMorph, appearance); morph.setCapability(Morph.ALLOW_WEIGHTS_READ); morph.setCapability(Morph.ALLOW_WEIGHTS_WRITE); PickTool.setCapabilities(morph, PickTool.INTERSECT_FULL); spinTg.addChild(morph); } else { // Geometry picking require this to be set. if (index == 0) m.setLightingEnable(true); else m.setLightingEnable(false); appearance.setMaterial(m); if ((index == 13) || (index == 14)) { PointAttributes pa = new PointAttributes(); pa.setPointSize(4.0f); appearance.setPointAttributes(pa); } shape = new Shape3D(geom, appearance); shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); shape.setCapability(Shape3D.ENABLE_PICK_REPORTING); PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL); spinTg.addChild(shape); } // add it to the scene graph. objTrans.addChild(spinTg); return objTrans; }
From source file:BehaviorTest.java
public WakeupCondition restart(Shape3D shape3D, int nElapsedTime, int nNumFrames, ExplosionListener listener) { System.out.println("Will explode after: " + nElapsedTime / 1000 + " secs."); m_Shape3D = shape3D;//from www . j a va 2 s . co m m_nElapsedTime = nElapsedTime; m_nNumFrames = nNumFrames; m_nFrameNumber = 0; // create the WakeupCriterion for the behavior m_InitialWakeupCondition = new WakeupOnElapsedTime(m_nElapsedTime); m_Listener = listener; // save the GeometryArray that we are modifying m_GeometryArray = (GeometryArray) m_Shape3D.getGeometry(); if (m_Shape3D.isLive() == false && m_Shape3D.isCompiled() == false) { // set the capability bits that the behavior requires m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ); m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POINT_ATTRIBUTES_WRITE); m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE); m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE); m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TEXTURE_WRITE); m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ); m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE); m_GeometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ); } // make a copy of the object's original appearance m_Appearance = new Appearance(); m_Appearance = (Appearance) m_Shape3D.getAppearance().cloneNodeComponent(true); // allocate an array for the model coordinates m_CoordinateArray = new float[3 * m_GeometryArray.getVertexCount()]; // make a copy of the models original coordinates m_OriginalCoordinateArray = new float[3 * m_GeometryArray.getVertexCount()]; m_GeometryArray.getCoordinates(0, m_OriginalCoordinateArray); // start (or restart) the behavior setEnable(true); return m_InitialWakeupCondition; }
From source file:ExBackgroundImage.java
public Arch(double startPhi, double endPhi, int nPhi, double startTheta, double endTheta, int nTheta, double startPhiRadius, double endPhiRadius, double startPhiThickness, double endPhiThickness, Appearance app) {//from w w w. j a va2 s . c om double theta, phi, radius, radius2, thickness; double x, y, z; double[] xyz = new double[3]; float[] norm = new float[3]; float[] tex = new float[3]; // Compute some values for our looping double deltaTheta = (endTheta - startTheta) / (double) (nTheta - 1); double deltaPhi = (endPhi - startPhi) / (double) (nPhi - 1); double deltaTexX = 1.0 / (double) (nTheta - 1); double deltaTexY = 1.0 / (double) (nPhi - 1); double deltaPhiRadius = (endPhiRadius - startPhiRadius) / (double) (nPhi - 1); double deltaPhiThickness = (endPhiThickness - startPhiThickness) / (double) (nPhi - 1); boolean doThickness = true; if (startPhiThickness == 0.0 && endPhiThickness == 0.0) doThickness = false; // Create geometry int vertexCount = nTheta * nPhi; if (doThickness) vertexCount *= 2; int indexCount = (nTheta - 1) * (nPhi - 1) * 4; // Outer surface if (doThickness) { indexCount *= 2; // plus inner surface indexCount += (nPhi - 1) * 4 * 2; // plus left & right edges } IndexedQuadArray polys = new IndexedQuadArray(vertexCount, GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.TEXTURE_COORDINATE_2, indexCount); // // Compute coordinates, normals, and texture coordinates // theta = startTheta; tex[0] = 0.0f; int index = 0; for (int i = 0; i < nTheta; i++) { phi = startPhi; radius = startPhiRadius; thickness = startPhiThickness; tex[1] = 0.0f; for (int j = 0; j < nPhi; j++) { norm[0] = (float) (Math.cos(phi) * Math.cos(theta)); norm[1] = (float) (Math.sin(phi)); norm[2] = (float) (-Math.cos(phi) * Math.sin(theta)); xyz[0] = radius * norm[0]; xyz[1] = radius * norm[1]; xyz[2] = radius * norm[2]; polys.setCoordinate(index, xyz); polys.setNormal(index, norm); polys.setTextureCoordinate(index, tex); index++; if (doThickness) { radius2 = radius - thickness; xyz[0] = radius2 * norm[0]; xyz[1] = radius2 * norm[1]; xyz[2] = radius2 * norm[2]; norm[0] *= -1.0f; norm[1] *= -1.0f; norm[2] *= -1.0f; polys.setCoordinate(index, xyz); polys.setNormal(index, norm); polys.setTextureCoordinate(index, tex); index++; } phi += deltaPhi; radius += deltaPhiRadius; thickness += deltaPhiThickness; tex[1] += deltaTexY; } theta += deltaTheta; tex[0] += deltaTexX; } // // Compute coordinate indexes // (also used as normal and texture indexes) // index = 0; int phiRow = nPhi; int phiCol = 1; if (doThickness) { phiRow += nPhi; phiCol += 1; } int[] indices = new int[indexCount]; // Outer surface int n; for (int i = 0; i < nTheta - 1; i++) { for (int j = 0; j < nPhi - 1; j++) { n = i * phiRow + j * phiCol; indices[index + 0] = n; indices[index + 1] = n + phiRow; indices[index + 2] = n + phiRow + phiCol; indices[index + 3] = n + phiCol; index += 4; } } // Inner surface if (doThickness) { for (int i = 0; i < nTheta - 1; i++) { for (int j = 0; j < nPhi - 1; j++) { n = i * phiRow + j * phiCol; indices[index + 0] = n + 1; indices[index + 1] = n + phiCol + 1; indices[index + 2] = n + phiRow + phiCol + 1; indices[index + 3] = n + phiRow + 1; index += 4; } } } // Edges if (doThickness) { for (int j = 0; j < nPhi - 1; j++) { n = j * phiCol; indices[index + 0] = n; indices[index + 1] = n + phiCol; indices[index + 2] = n + phiCol + 1; indices[index + 3] = n + 1; index += 4; } for (int j = 0; j < nPhi - 1; j++) { n = (nTheta - 1) * phiRow + j * phiCol; indices[index + 0] = n; indices[index + 1] = n + 1; indices[index + 2] = n + phiCol + 1; indices[index + 3] = n + phiCol; index += 4; } } polys.setCoordinateIndices(0, indices); polys.setNormalIndices(0, indices); polys.setTextureCoordinateIndices(0, indices); // // Build a shape // arch = new Shape3D(); arch.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); arch.setGeometry(polys); arch.setAppearance(app); addChild(arch); }
From source file:CuboidTest.java
/** * Constructs a Cuboid of a given dimension, flags, and appearance. * // w ww.ja v a2 s. c o m * @param xdim * X-dimension size. * @param ydim * Y-dimension size. * @param zdim * Z-dimension size. * @param primflags * primitive flags. * @param ap * Appearance */ public Cuboid(float xdim, float ydim, float zdim, int primflags, Appearance ap) { int i; double sign; xDim = xdim; yDim = ydim; zDim = zdim; flags = primflags; //Depending on whether normal inward bit is set. if ((flags & GENERATE_NORMALS_INWARD) != 0) sign = -1.0; else sign = 1.0; TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(ALLOW_CHILDREN_READ); this.addChild(objTrans); Shape3D shape[] = new Shape3D[6]; for (i = FRONT; i <= BOTTOM; i++) { OldGeomBuffer gbuf = new OldGeomBuffer(4); gbuf.begin(OldGeomBuffer.QUAD_STRIP); for (int j = 0; j < 2; j++) { gbuf.normal3d((double) normals[i].x * sign, (double) normals[i].y * sign, (double) normals[i].z * sign); gbuf.texCoord2d(tcoords[i * 8 + j * 2], tcoords[i * 8 + j * 2 + 1]); gbuf.vertex3d((double) verts[i * 12 + j * 3] * xdim, (double) verts[i * 12 + j * 3 + 1] * ydim, (double) verts[i * 12 + j * 3 + 2] * zdim); } for (int j = 3; j > 1; j--) { gbuf.normal3d((double) normals[i].x * sign, (double) normals[i].y * sign, (double) normals[i].z * sign); gbuf.texCoord2d(tcoords[i * 8 + j * 2], tcoords[i * 8 + j * 2 + 1]); gbuf.vertex3d((double) verts[i * 12 + j * 3] * xdim, (double) verts[i * 12 + j * 3 + 1] * ydim, (double) verts[i * 12 + j * 3 + 2] * zdim); } gbuf.end(); shape[i] = new Shape3D(gbuf.getGeom(flags)); numVerts = gbuf.getNumVerts(); numTris = gbuf.getNumTris(); if ((flags & ENABLE_APPEARANCE_MODIFY) != 0) { (shape[i]).setCapability(Shape3D.ALLOW_APPEARANCE_READ); (shape[i]).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); } objTrans.addChild(shape[i]); } if (ap == null) { setAppearance(); } else setAppearance(ap); }
From source file:ExBackgroundImage.java
private void rebuild() { // Build a shape if (shape == null) { shape = new Shape3D(); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); shape.setAppearance(mainAppearance); addChild(shape);//w ww .j ava 2 s . co m } else { shape.setAppearance(mainAppearance); } if (xDimension < 2 || zDimension < 2 || heights == null || heights.length < 4) { tristrip = null; shape.setGeometry(null); return; } // Create a list of coordinates, one per grid row/column double[] coordinates = new double[xDimension * zDimension * 3]; double x, z; int n = 0, k = 0; z = ((double) (zDimension - 1)) * zSpacing / 2.0; // start at front edge for (int i = 0; i < zDimension; i++) { x = -((double) (xDimension - 1)) * xSpacing / 2.0;// start at left // edge for (int j = 0; j < xDimension; j++) { coordinates[n++] = x; coordinates[n++] = heights[k++]; coordinates[n++] = z; x += xSpacing; } z -= zSpacing; } // Create a list of normals, one per grid row/column float[] normals = new float[xDimension * zDimension * 3]; Vector3f one = new Vector3f(0.0f, 0.0f, 0.0f); Vector3f two = new Vector3f(0.0f, 0.0f, 0.0f); Vector3f norm = new Vector3f(0.0f, 0.0f, 0.0f); n = 0; k = 0; for (int i = 0; i < zDimension - 1; i++) { for (int j = 0; j < xDimension - 1; j++) { // Vector to right in X one.set((float) xSpacing, (float) (heights[k + 1] - heights[k]), 0.0f); // Vector back in Z two.set(0.0f, (float) (heights[k + xDimension] - heights[k]), (float) -zSpacing); // Cross them to get the normal norm.cross(one, two); normals[n++] = norm.x; normals[n++] = norm.y; normals[n++] = norm.z; k++; } // Last normal in row is a copy of the previous one normals[n] = normals[n - 3]; // X normals[n + 1] = normals[n - 2]; // Y normals[n + 2] = normals[n - 1]; // Z n += 3; k++; } // Last row of normals is a copy of the previous row for (int j = 0; j < xDimension; j++) { normals[n] = normals[n - xDimension * 3]; // X normals[n + 1] = normals[n - xDimension * 3 + 1]; // Y normals[n + 2] = normals[n - xDimension * 3 + 2]; // Z n += 3; } // Create a list of texture coordinates, one per grid row/column float[] texcoordinates = new float[xDimension * zDimension * 2]; float deltaS = 1.0f / (float) (xDimension - 1); float deltaT = 1.0f / (float) (zDimension - 1); float s = 0.0f; float t = 0.0f; n = 0; for (int i = 0; i < zDimension; i++) { s = 0.0f; for (int j = 0; j < xDimension; j++) { texcoordinates[n++] = s; texcoordinates[n++] = t; s += deltaS; } t += deltaT; } // Create a list of triangle strip indexes. Each strip goes // down one row (X direction) of the elevation grid. int[] indexes = new int[xDimension * (zDimension - 1) * 2]; int[] stripCounts = new int[zDimension - 1]; n = 0; k = 0; for (int i = 0; i < zDimension - 1; i++) { stripCounts[i] = xDimension * 2; for (int j = 0; j < xDimension; j++) { indexes[n++] = k + xDimension; indexes[n++] = k; k++; } } // Create geometry for collection of triangle strips, one // strip per row of the elevation grid tristrip = new IndexedTriangleStripArray(coordinates.length, GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.TEXTURE_COORDINATE_2, indexes.length, stripCounts); tristrip.setCoordinates(0, coordinates); tristrip.setNormals(0, normals); tristrip.setTextureCoordinates(0, texcoordinates); tristrip.setCoordinateIndices(0, indexes); tristrip.setNormalIndices(0, indexes); tristrip.setTextureCoordinateIndices(0, indexes); // Set the geometry for the shape shape.setGeometry(tristrip); }
From source file:ExSpotLight.java
public AnnotationLine(float x, float y, float z, float x2, float y2, float z2) { float[] coord = new float[3]; float[] texcoord = new float[2]; // Build a shape shape = new Shape3D(); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // Create geometry for a 2-vertex straight line line = new LineArray(2, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2); line.setCapability(GeometryArray.ALLOW_COLOR_WRITE); // Starting point coord[0] = x;/*from w ww .java2 s .c o m*/ coord[1] = y; coord[2] = z; texcoord[0] = 0.0f; texcoord[1] = 0.0f; line.setCoordinate(0, coord); line.setTextureCoordinate(0, texcoord); // Ending point coord[0] = x2; coord[1] = y2; coord[2] = z2; texcoord[0] = 1.0f; texcoord[1] = 0.0f; line.setCoordinate(1, coord); line.setTextureCoordinate(1, texcoord); shape.setGeometry(line); // Create an appearance mainAppearance = new Appearance(); mainAppearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE); mainAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); lineAttributes = new LineAttributes(); lineAttributes.setLineWidth(lineWidth); mainAppearance.setLineAttributes(lineAttributes); coloringAttributes = new ColoringAttributes(); coloringAttributes.setColor(lineColor); coloringAttributes.setShadeModel(ColoringAttributes.SHADE_FLAT); mainAppearance.setColoringAttributes(coloringAttributes); addChild(shape); }
From source file:FourByFour.java
public Cube(Appearance appearance) { QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES | QuadArray.NORMALS | QuadArray.TEXTURE_COORDINATE_2); quadArray.setCoordinates(0, verts);/* www . jav a 2 s .c o m*/ quadArray.setNormals(0, normals); shape3D = new Shape3D(quadArray, appearance); shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ); shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ); shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); }