List of usage examples for javax.media.j3d GeometryArray COORDINATES
int COORDINATES
To view the source code for javax.media.j3d GeometryArray COORDINATES.
Click Source Link
From source file:FarbWurfelAsQuads.java
/** * Erstellung des ColorCube//w w w. j a v a2 s .c o m * * @return */ private QuadArray makeCube() { QuadArray plane = new QuadArray(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3); // Punkte und Farben Point3f pa = new Point3f(-1.0f, 1.0f, -1.0f); Point3f pb = new Point3f(-1.0f, -1.0f, -1.0f); Point3f pc = new Point3f(1.0f, -1.0f, -1.0f); Point3f pd = new Point3f(1.0f, 1.0f, -1.0f); Point3f pe = new Point3f(-1.0f, 1.0f, 1.0f); Point3f pf = new Point3f(-1.0f, -1.0f, 1.0f); Point3f pg = new Point3f(1.0f, -1.0f, 1.0f); Point3f ph = new Point3f(1.0f, 1.0f, 1.0f); // Coloreigenschaften Color3f red = new Color3f(1.0f, 0.0f, 0.0f); Color3f blue = new Color3f(0.0f, 0.0f, 1.0f); Color3f green = new Color3f(0.0f, 1.0f, 0.0f); Color3f cyan = new Color3f(0.0f, 1.0f, 1.0f); Color3f yellow = new Color3f(1.0f, 1.0f, 0.0f); Color3f magenta = new Color3f(1.0f, 0.0f, 1.0f); // 1. Seite plane.setCoordinate(0, pa); plane.setColor(0, red); plane.setCoordinate(1, pb); plane.setColor(1, red); plane.setCoordinate(2, pc); plane.setColor(2, red); plane.setCoordinate(3, pd); plane.setColor(3, red); // 2. Seite plane.setCoordinate(4, pe); plane.setColor(4, blue); plane.setCoordinate(5, pf); plane.setColor(5, blue); plane.setCoordinate(6, pg); plane.setColor(6, blue); plane.setCoordinate(7, ph); plane.setColor(7, blue); // 3. Seite plane.setCoordinate(8, pe); plane.setColor(8, green); plane.setCoordinate(9, pf); plane.setColor(9, green); plane.setCoordinate(10, pb); plane.setColor(10, green); plane.setCoordinate(11, pa); plane.setColor(11, green); // 4. Seite plane.setCoordinate(12, pd); plane.setColor(12, cyan); plane.setCoordinate(13, pc); plane.setColor(13, cyan); plane.setCoordinate(14, pg); plane.setColor(14, cyan); plane.setCoordinate(15, ph); plane.setColor(15, cyan); // 5. Seite plane.setCoordinate(16, pe); plane.setColor(16, yellow); plane.setCoordinate(17, pa); plane.setColor(17, yellow); plane.setCoordinate(18, pd); plane.setColor(18, yellow); plane.setCoordinate(19, ph); plane.setColor(19, yellow); // 6. Seite plane.setCoordinate(20, pf); plane.setColor(20, magenta); plane.setCoordinate(21, pb); plane.setColor(21, magenta); plane.setCoordinate(22, pc); plane.setColor(22, magenta); plane.setCoordinate(23, pg); plane.setColor(23, magenta); // ubergib den Wurfel return plane; }
From source file:KeyNavigatorApp.java
Shape3D createPyramid() { IndexedTriangleArray pyGeom = new IndexedTriangleArray(5, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 12);//from w w w. ja v a 2 s .c o m pyGeom.setCoordinate(0, new Point3f(0.0f, 0.7f, 0.0f)); pyGeom.setCoordinate(1, new Point3f(-0.4f, 0.0f, -0.4f)); pyGeom.setCoordinate(2, new Point3f(-0.4f, 0.0f, 0.4f)); pyGeom.setCoordinate(3, new Point3f(0.4f, 0.0f, 0.4f)); pyGeom.setCoordinate(4, new Point3f(0.4f, 0.0f, -0.4f)); pyGeom.setCoordinateIndex(0, 0); pyGeom.setCoordinateIndex(1, 1); pyGeom.setCoordinateIndex(2, 2); pyGeom.setCoordinateIndex(3, 0); pyGeom.setCoordinateIndex(4, 2); pyGeom.setCoordinateIndex(5, 3); pyGeom.setCoordinateIndex(6, 0); pyGeom.setCoordinateIndex(7, 3); pyGeom.setCoordinateIndex(8, 4); pyGeom.setCoordinateIndex(9, 0); pyGeom.setCoordinateIndex(10, 4); pyGeom.setCoordinateIndex(11, 1); Color3f c = new Color3f(0.6f, 0.5f, 0.55f); pyGeom.setColor(0, c); pyGeom.setColor(1, c); pyGeom.setColor(2, c); pyGeom.setColor(3, c); pyGeom.setColor(4, c); Shape3D pyramid = new Shape3D(pyGeom); return pyramid; }
From source file:KeyNavigatorApp.java
Shape3D createLand() { LineArray landGeom = new LineArray(44, GeometryArray.COORDINATES | GeometryArray.COLOR_3); float l = -50.0f; for (int c = 0; c < 44; c += 4) { landGeom.setCoordinate(c + 0, new Point3f(-50.0f, 0.0f, l)); landGeom.setCoordinate(c + 1, new Point3f(50.0f, 0.0f, l)); landGeom.setCoordinate(c + 2, new Point3f(l, 0.0f, -50.0f)); landGeom.setCoordinate(c + 3, new Point3f(l, 0.0f, 50.0f)); l += 10.0f;//w w w . j a v a 2 s. c o m } Color3f c = new Color3f(0.1f, 0.8f, 0.1f); for (int i = 0; i < 44; i++) landGeom.setColor(i, c); return new Shape3D(landGeom); }
From source file:LightScopeApp.java
Shape3D createLampShape() { Shape3D lamp = new Shape3D(); int stripCounts[] = { 10, 10 }; TriangleStripArray lampGeom = new TriangleStripArray(20, GeometryArray.COORDINATES | GeometryArray.NORMALS, stripCounts);/* w ww . ja v a 2 s. com*/ lampGeom.setCoordinate(0, new Point3f(-0.01f, 0.9f, 0.01f)); lampGeom.setCoordinate(1, new Point3f(-0.01f, 0.0f, 0.01f)); lampGeom.setCoordinate(2, new Point3f(0.01f, 0.9f, 0.01f)); lampGeom.setCoordinate(3, new Point3f(0.01f, 0.0f, 0.01f)); lampGeom.setCoordinate(4, new Point3f(0.01f, 0.9f, -0.01f)); lampGeom.setCoordinate(5, new Point3f(0.01f, 0.0f, -0.01f)); lampGeom.setCoordinate(6, new Point3f(-0.01f, 0.9f, -0.01f)); lampGeom.setCoordinate(7, new Point3f(-0.01f, 0.0f, -0.01f)); lampGeom.setCoordinate(8, new Point3f(-0.01f, 0.9f, 0.01f)); lampGeom.setCoordinate(9, new Point3f(-0.01f, 0.0f, 0.01f)); lampGeom.setCoordinate(10, new Point3f(-0.1f, 0.9f, 0.1f)); lampGeom.setCoordinate(11, new Point3f(-0.2f, 0.5f, 0.2f)); lampGeom.setCoordinate(12, new Point3f(0.1f, 0.9f, 0.1f)); lampGeom.setCoordinate(13, new Point3f(0.2f, 0.5f, 0.2f)); lampGeom.setCoordinate(14, new Point3f(0.1f, 0.9f, -0.1f)); lampGeom.setCoordinate(15, new Point3f(0.2f, 0.5f, -0.2f)); lampGeom.setCoordinate(16, new Point3f(-0.1f, 0.9f, -0.1f)); lampGeom.setCoordinate(17, new Point3f(-0.2f, 0.5f, -0.2f)); lampGeom.setCoordinate(18, new Point3f(-0.1f, 0.9f, 0.1f)); lampGeom.setCoordinate(19, new Point3f(-0.2f, 0.5f, 0.2f)); Vector3f norm = new Vector3f(-0.7f, 0.0f, 0.7f); lampGeom.setNormal(0, norm); lampGeom.setNormal(1, norm); norm.set(0.7f, 0.0f, 0.7f); lampGeom.setNormal(2, norm); lampGeom.setNormal(3, norm); norm.set(0.7f, 0.0f, -0.7f); lampGeom.setNormal(4, norm); lampGeom.setNormal(5, norm); norm.set(-0.7f, 0.0f, -0.7f); lampGeom.setNormal(6, norm); lampGeom.setNormal(7, norm); norm.set(-0.7f, 0.0f, 0.7f); lampGeom.setNormal(8, norm); lampGeom.setNormal(9, norm); norm.set(-0.7f, 0.0f, 0.7f); lampGeom.setNormal(10, norm); lampGeom.setNormal(11, norm); norm.set(0.7f, 0.0f, 0.7f); lampGeom.setNormal(12, norm); lampGeom.setNormal(13, norm); norm.set(0.7f, 0.0f, -0.7f); lampGeom.setNormal(14, norm); lampGeom.setNormal(15, norm); norm.set(-0.7f, 0.0f, -0.7f); lampGeom.setNormal(16, norm); lampGeom.setNormal(17, norm); norm.set(-0.7f, 0.0f, 0.7f); lampGeom.setNormal(18, norm); lampGeom.setNormal(19, norm); lamp.setGeometry(lampGeom); return lamp; }
From source file:BoundsTest.java
protected Group createPoints() { Group group = new Group(); final int kNumPoints = 200; final double kRadius = 10.0; Point3d points[] = new Point3d[kNumPoints]; for (int n = 0; n < kNumPoints; n++) { double randX = (java.lang.Math.random() * kRadius) - kRadius / 2; double randY = (java.lang.Math.random() * kRadius) - kRadius / 2; double randZ = (java.lang.Math.random() * kRadius) - kRadius / 2; points[n] = new Point3d(randX, randY, randZ); }/* w w w .j a va2 s . c om*/ PointArray pointArray = new PointArray(points.length, GeometryArray.COLOR_4 | GeometryArray.COORDINATES); pointArray.setCoordinates(0, points); Shape3D shapePoints = new Shape3D(pointArray, new Appearance()); group.addChild(shapePoints); return group; }
From source file:AxisClassDemoApp.java
private Geometry createGeometry() { // create line for X axis IndexedLineArray axisLines = new IndexedLineArray(18, GeometryArray.COORDINATES, 30); axisLines.setCoordinate(0, new Point3f(-1.0f, 0.0f, 0.0f)); axisLines.setCoordinate(1, new Point3f(1.0f, 0.0f, 0.0f)); axisLines.setCoordinate(2, new Point3f(0.9f, 0.1f, 0.1f)); axisLines.setCoordinate(3, new Point3f(0.9f, -0.1f, 0.1f)); axisLines.setCoordinate(4, new Point3f(0.9f, 0.1f, -0.1f)); axisLines.setCoordinate(5, new Point3f(0.9f, -0.1f, -0.1f)); axisLines.setCoordinate(6, new Point3f(0.0f, -1.0f, 0.0f)); axisLines.setCoordinate(7, new Point3f(0.0f, 1.0f, 0.0f)); axisLines.setCoordinate(8, new Point3f(0.1f, 0.9f, 0.1f)); axisLines.setCoordinate(9, new Point3f(-0.1f, 0.9f, 0.1f)); axisLines.setCoordinate(10, new Point3f(0.1f, 0.9f, -0.1f)); axisLines.setCoordinate(11, new Point3f(-0.1f, 0.9f, -0.1f)); axisLines.setCoordinate(12, new Point3f(0.0f, 0.0f, -1.0f)); axisLines.setCoordinate(13, new Point3f(0.0f, 0.0f, 1.0f)); axisLines.setCoordinate(14, new Point3f(0.1f, 0.1f, 0.9f)); axisLines.setCoordinate(15, new Point3f(-0.1f, 0.1f, 0.9f)); axisLines.setCoordinate(16, new Point3f(0.1f, -0.1f, 0.9f)); axisLines.setCoordinate(17, new Point3f(-0.1f, -0.1f, 0.9f)); axisLines.setCoordinateIndex(0, 0);/*from w w w. j ava2 s . c o m*/ axisLines.setCoordinateIndex(1, 1); axisLines.setCoordinateIndex(2, 2); axisLines.setCoordinateIndex(3, 1); axisLines.setCoordinateIndex(4, 3); axisLines.setCoordinateIndex(5, 1); axisLines.setCoordinateIndex(6, 4); axisLines.setCoordinateIndex(7, 1); axisLines.setCoordinateIndex(8, 5); axisLines.setCoordinateIndex(9, 1); axisLines.setCoordinateIndex(10, 6); axisLines.setCoordinateIndex(11, 7); axisLines.setCoordinateIndex(12, 8); axisLines.setCoordinateIndex(13, 7); axisLines.setCoordinateIndex(14, 9); axisLines.setCoordinateIndex(15, 7); axisLines.setCoordinateIndex(16, 10); axisLines.setCoordinateIndex(17, 7); axisLines.setCoordinateIndex(18, 11); axisLines.setCoordinateIndex(19, 7); axisLines.setCoordinateIndex(20, 12); axisLines.setCoordinateIndex(21, 13); axisLines.setCoordinateIndex(22, 14); axisLines.setCoordinateIndex(23, 13); axisLines.setCoordinateIndex(24, 15); axisLines.setCoordinateIndex(25, 13); axisLines.setCoordinateIndex(26, 16); axisLines.setCoordinateIndex(27, 13); axisLines.setCoordinateIndex(28, 17); axisLines.setCoordinateIndex(29, 13); return axisLines; }
From source file:PointTest.java
private BranchGroup createPoints(final int nPointSize, final int nNumPoints, boolean bAliased) { BranchGroup bg = new BranchGroup(); String szText = new String(); szText += (nNumPoints + "X, Size:" + nPointSize + ", aliased: " + bAliased); Font3D f3d = new Font3D(new Font("SansSerif", Font.PLAIN, 1), new FontExtrusion()); Text3D label3D = new Text3D(f3d, szText, new Point3f(-5, 0, 0)); Shape3D sh = new Shape3D(label3D); bg.addChild(sh);/*from w w w .ja v a2s . c om*/ PointArray pointArray = new PointArray(nNumPoints * nNumPoints, GeometryArray.COORDINATES | GeometryArray.COLOR_3); // create the PointArray that we will be rendering int nPoint = 0; final double factor = 1.0 / nNumPoints; for (int n = 0; n < nNumPoints; n++) { for (int i = 0; i < nNumPoints; i++) { Point3f point = new Point3f(n - nNumPoints / 2, i - nNumPoints / 2, 0.0f); pointArray.setCoordinate(nPoint, point); pointArray.setColor(nPoint++, new Color3f(0.5f, (float) (n * factor), (float) (i * factor))); } } // create the material for the points Appearance pointApp = new Appearance(); // enlarge the points pointApp.setPointAttributes(new PointAttributes(nPointSize, bAliased)); Shape3D pointShape = new Shape3D(pointArray, pointApp); bg.addChild(pointShape); return bg; }
From source file:AppearanceTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup zoomTg = new TransformGroup(); zoomTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); zoomTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // attach a navigation behavior to the position of the viewer KeyNavigatorBehavior key = new KeyNavigatorBehavior(zoomTg); key.setSchedulingBounds(createApplicationBounds()); key.setEnable(true);//from w w w .ja v a2s. c om objRoot.addChild(key); // create a TransformGroup to flip the hand onto its end and enlarge it. TransformGroup objTrans1 = new TransformGroup(); Transform3D tr = new Transform3D(); objTrans1.getTransform(tr); tr.setEuler(new Vector3d(0.5 * Math.PI, 0.6, 0)); objTrans1.setTransform(tr); // Set up the global lights Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f); Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f); Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); AmbientLight aLgt = new AmbientLight(alColor); aLgt.setInfluencingBounds(getApplicationBounds()); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(getApplicationBounds()); objRoot.addChild(aLgt); objRoot.addChild(lgt1); int nScale = 50; Box box = new Box(nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, m_Appearance); Shape3D frontFace = box.getShape(Box.LEFT); // create a new left face so we can // assign per-vertex colors GeometryArray geometry = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR_4 | GeometryArray.TEXTURE_COORDINATE_2); nScale = 40; final float[] verts = { // left face -1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale }; final float[] colors = { // left face 1, 0, 0, 0, 0, 1, 0, 0.2f, 0, 0, 1, 0.8f, 0, 0, 0, 1, }; float[] tcoords = { // left 1, 0, 1, 1, 0, 1, 0, 0 }; Vector3f normalVector = new Vector3f(-1.0f, 0.0f, 0.0f); geometry.setColors(0, colors, 0, 4); for (int n = 0; n < 4; n++) geometry.setNormal(n, normalVector); geometry.setTextureCoordinates(0, tcoords, 0, 4); geometry.setCoordinates(0, verts); frontFace.setGeometry(geometry); // connect the scenegraph objTrans1.addChild(box); zoomTg.addChild(objTrans1); objRoot.addChild(zoomTg); return objRoot; }
From source file:IntersectTest.java
RandomColorTetrahedron() { super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3); Point3f verts[] = new Point3f[4]; Color3f colors[] = new Color3f[4]; verts[0] = new Point3f(0.5f, 0.5f, 0.5f); verts[1] = new Point3f(0.5f, -0.5f, -0.5f); verts[2] = new Point3f(-0.5f, -0.5f, 0.5f); verts[3] = new Point3f(-0.5f, 0.5f, -0.5f); colors[0] = new Color3f(1.0f, 0.0f, 0.0f); colors[1] = new Color3f(0.0f, 1.0f, 0.0f); colors[2] = new Color3f(0.0f, 0.0f, 1.0f); Point3f pnts[] = new Point3f[12]; Color3f clrs[] = new Color3f[12]; pnts[0] = verts[2];//w w w. j a v a 2 s. co m clrs[0] = colors[(int) (Math.random() * 3.0)]; pnts[1] = verts[1]; clrs[1] = colors[(int) (Math.random() * 3.0)]; pnts[2] = verts[0]; clrs[2] = colors[(int) (Math.random() * 3.0)]; pnts[3] = verts[3]; clrs[3] = colors[(int) (Math.random() * 3.0)]; pnts[4] = verts[2]; clrs[4] = colors[(int) (Math.random() * 3.0)]; pnts[5] = verts[0]; clrs[5] = colors[(int) (Math.random() * 3.0)]; pnts[6] = verts[1]; clrs[6] = colors[(int) (Math.random() * 3.0)]; pnts[7] = verts[2]; clrs[7] = colors[(int) (Math.random() * 3.0)]; pnts[8] = verts[3]; clrs[8] = colors[(int) (Math.random() * 3.0)]; pnts[9] = verts[1]; clrs[9] = colors[(int) (Math.random() * 3.0)]; pnts[10] = verts[3]; clrs[10] = colors[(int) (Math.random() * 3.0)]; pnts[11] = verts[0]; clrs[11] = colors[(int) (Math.random() * 3.0)]; setCoordinates(0, pnts); setColors(0, clrs); }
From source file:IntersectTest.java
RandomColorCube() { super(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3); Point3f verts[] = new Point3f[8]; Color3f colors[] = new Color3f[3]; verts[0] = new Point3f(0.5f, 0.5f, 0.5f); verts[1] = new Point3f(-0.5f, 0.5f, 0.5f); verts[2] = new Point3f(-0.5f, -0.5f, 0.5f); verts[3] = new Point3f(0.5f, -0.5f, 0.5f); verts[4] = new Point3f(0.5f, 0.5f, -0.5f); verts[5] = new Point3f(-0.5f, 0.5f, -0.5f); verts[6] = new Point3f(-0.5f, -0.5f, -0.5f); verts[7] = new Point3f(0.5f, -0.5f, -0.5f); colors[0] = new Color3f(1.0f, 0.0f, 0.0f); colors[1] = new Color3f(0.0f, 1.0f, 0.0f); colors[2] = new Color3f(0.0f, 0.0f, 1.0f); Point3f pnts[] = new Point3f[24]; Color3f clrs[] = new Color3f[24]; pnts[0] = verts[0];/*from w w w . j a v a 2 s. c o m*/ clrs[0] = colors[(int) (Math.random() * 3.0)]; pnts[1] = verts[3]; clrs[1] = colors[(int) (Math.random() * 3.0)]; pnts[2] = verts[7]; clrs[2] = colors[(int) (Math.random() * 3.0)]; pnts[3] = verts[4]; clrs[3] = colors[(int) (Math.random() * 3.0)]; pnts[4] = verts[1]; clrs[4] = colors[(int) (Math.random() * 3.0)]; pnts[5] = verts[5]; clrs[5] = colors[(int) (Math.random() * 3.0)]; pnts[6] = verts[6]; clrs[6] = colors[(int) (Math.random() * 3.0)]; pnts[7] = verts[2]; clrs[7] = colors[(int) (Math.random() * 3.0)]; pnts[8] = verts[0]; clrs[8] = colors[(int) (Math.random() * 3.0)]; pnts[9] = verts[4]; clrs[9] = colors[(int) (Math.random() * 3.0)]; pnts[10] = verts[5]; clrs[10] = colors[(int) (Math.random() * 3.0)]; pnts[11] = verts[1]; clrs[11] = colors[(int) (Math.random() * 3.0)]; pnts[12] = verts[3]; clrs[12] = colors[(int) (Math.random() * 3.0)]; pnts[13] = verts[2]; clrs[13] = colors[(int) (Math.random() * 3.0)]; pnts[14] = verts[6]; clrs[14] = colors[(int) (Math.random() * 3.0)]; pnts[15] = verts[7]; clrs[15] = colors[(int) (Math.random() * 3.0)]; pnts[16] = verts[0]; clrs[16] = colors[(int) (Math.random() * 3.0)]; pnts[17] = verts[1]; clrs[17] = colors[(int) (Math.random() * 3.0)]; pnts[18] = verts[2]; clrs[18] = colors[(int) (Math.random() * 3.0)]; pnts[19] = verts[3]; clrs[19] = colors[(int) (Math.random() * 3.0)]; pnts[20] = verts[7]; clrs[20] = colors[(int) (Math.random() * 3.0)]; pnts[21] = verts[6]; clrs[21] = colors[(int) (Math.random() * 3.0)]; pnts[22] = verts[5]; clrs[22] = colors[(int) (Math.random() * 3.0)]; pnts[23] = verts[4]; clrs[23] = colors[(int) (Math.random() * 3.0)]; setCoordinates(0, pnts); setColors(0, clrs); }