List of usage examples for javax.media.j3d GeometryArray COLOR_3
int COLOR_3
To view the source code for javax.media.j3d GeometryArray COLOR_3.
Click Source Link
From source file:IntersectTest.java
public void processStimulus(Enumeration criteria) { WakeupCriterion wakeup;/*from w w w .j a va2s. co m*/ AWTEvent[] event; int eventId; while (criteria.hasMoreElements()) { wakeup = (WakeupCriterion) criteria.nextElement(); if (wakeup instanceof WakeupOnAWTEvent) { event = ((WakeupOnAWTEvent) wakeup).getAWTEvent(); for (int i = 0; i < event.length; i++) { eventId = event[i].getID(); if (eventId == MouseEvent.MOUSE_PRESSED) { int x = ((MouseEvent) event[i]).getX(); int y = ((MouseEvent) event[i]).getY(); pickCanvas.setShapeLocation(x, y); Point3d eyePos = pickCanvas.getStartPosition(); pickResult = pickCanvas.pickAllSorted(); // Use this to do picking benchmarks /* * long start = System.currentTimeMillis(); for (int * l=0;l <3;l++) { if (l == 0) System.out.print * ("BOUNDS: "); if (l == 1) System.out.print * ("GEOMETRY: "); if (l == 2) System.out.print * ("GEOMETRY_INTERSECT_INFO: "); * * for (int k=0;k <1000;k++) { if (l == 0) { * pickCanvas.setMode(PickTool.BOUNDS); pickResult = * pickCanvas.pickAllSorted(); } if (l == 1) { * pickCanvas.setMode(PickTool.GEOMETRY); pickResult = * pickCanvas.pickAllSorted(); } if (l == 2) { * pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO); * pickResult = pickCanvas.pickAllSorted(); } } long * delta = System.currentTimeMillis() - start; * System.out.println ("\t"+delta+" ms / 1000 picks"); } */ if (pickResult != null) { // Get closest intersection results PickIntersection pi = pickResult[0].getClosestIntersection(eyePos); GeometryArray curGeomArray = pi.getGeometryArray(); // Position sphere at intersection point Vector3d v = new Vector3d(); Point3d intPt = pi.getPointCoordinatesVW(); v.set(intPt); spht3.setTranslation(v); sphTrans[0].setTransform(spht3); // Position sphere at closest vertex Point3d closestVert = pi.getClosestVertexCoordinatesVW(); v.set(closestVert); spht3.setTranslation(v); sphTrans[1].setTransform(spht3); Point3d[] ptw = pi.getPrimitiveCoordinatesVW(); Point3d[] pt = pi.getPrimitiveCoordinates(); int[] coordidx = pi.getPrimitiveCoordinateIndices(); Point3d ptcoord = new Point3d(); for (int k = 0; k < pt.length; k++) { v.set(ptw[k]); spht3.setTranslation(v); sphTrans[k + 2].setTransform(spht3); } // Get interpolated color (if available) Color4f iColor4 = null; Color3f iColor = null; Vector3f iNormal = null; if (curGeomArray != null) { int vf = curGeomArray.getVertexFormat(); if (((vf & (GeometryArray.COLOR_3 | GeometryArray.COLOR_4)) != 0) && (null != (iColor4 = pi.getPointColor()))) { iColor = new Color3f(iColor4.x, iColor4.y, iColor4.z); // Change the point's color redlook.setMaterial(new Material(iColor, new Color3f(0.0f, 0.0f, 0.0f), iColor, new Color3f(1.0f, 1.0f, 1.0f), 50.0f)); } if (((vf & GeometryArray.NORMALS) != 0) && (null != (iNormal = pi.getPointNormal()))) { System.out.println("Interpolated normal: " + iNormal); } } System.out.println("============="); System.out.println("Coordinates of intersection pt:" + intPt); System.out.println("Coordinates of vertices: "); for (int k = 0; k < pt.length; k++) { System.out.println(k + ":" + ptw[k].x + " " + ptw[k].y + " " + ptw[k].z); } System.out.println("Closest vertex: " + closestVert); if (iColor != null) { System.out.println("Interpolated color: " + iColor); } if (iNormal != null) { System.out.println("Interpolated normal: " + iNormal); } } } } } } wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED)); }
From source file:AppearanceExplorer.java
Shape3D createTriangleArray() { Point3f pnt[] = new Point3f[3]; pnt[0] = new Point3f(-1.0f, -1.0f, 0.0f); pnt[1] = new Point3f(1.0f, -1.0f, 0.0f); pnt[2] = new Point3f(1.0f, 1.0f, 0.0f); Color3f colrs[] = new Color3f[3]; colrs[0] = red;/*from w w w . j a va2 s .co m*/ colrs[1] = green; colrs[2] = blue; Vector3f norms[] = new Vector3f[3]; Vector3f triNormal = new Vector3f(0.0f, 0.0f, 1.0f); norms[0] = triNormal; norms[1] = triNormal; norms[2] = triNormal; TriangleArray ta = new TriangleArray(3, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.NORMALS); ta.setCoordinates(0, pnt); ta.setColors(0, colrs); ta.setNormals(0, norms); return new Shape3D(ta, appearance); }
From source file:PickTest.java
TetrahedronPA() { super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3); Point3f verts[] = new Point3f[4]; Color3f colors[] = new Color3f[4]; verts[0] = new Point3f(1.0f, 1.0f, 1.0f); verts[1] = new Point3f(1.0f, -1.0f, -1.0f); verts[2] = new Point3f(-1.0f, -1.0f, 1.0f); verts[3] = new Point3f(-1.0f, 1.0f, -1.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); setCoordinates(0, verts);// w ww. ja v a 2s .c om setColors(0, colors); }
From source file:PickTest.java
TetrahedronLSA() { super(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3, lineLengths); Point3f verts[] = new Point3f[4]; Color3f colors[] = new Color3f[4]; verts[0] = new Point3f(1.0f, 1.0f, 1.0f); verts[1] = new Point3f(1.0f, -1.0f, -1.0f); verts[2] = new Point3f(-1.0f, -1.0f, 1.0f); verts[3] = new Point3f(-1.0f, 1.0f, -1.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); Point3f pnts[] = new Point3f[8]; Color3f clrs[] = new Color3f[8]; pnts[0] = verts[0];/*from ww w . ja v a 2s. co m*/ clrs[0] = colors[0]; pnts[1] = verts[1]; clrs[1] = colors[1]; pnts[2] = verts[3]; clrs[2] = colors[3]; pnts[3] = verts[2]; clrs[3] = colors[2]; pnts[4] = verts[1]; clrs[4] = colors[1]; pnts[5] = verts[2]; clrs[5] = colors[2]; pnts[6] = verts[0]; clrs[6] = colors[0]; pnts[7] = verts[3]; clrs[7] = colors[3]; setCoordinates(0, pnts); setColors(0, clrs); }
From source file:PickTest.java
TetrahedronLA() { super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3); Point3f verts[] = new Point3f[4]; Color3f colors[] = new Color3f[4]; verts[0] = new Point3f(1.0f, 1.0f, 1.0f); verts[1] = new Point3f(1.0f, -1.0f, -1.0f); verts[2] = new Point3f(-1.0f, -1.0f, 1.0f); verts[3] = new Point3f(-1.0f, 1.0f, -1.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); Point3f pnts[] = new Point3f[12]; Color3f clrs[] = new Color3f[12]; pnts[0] = verts[0];//from ww w. j av a2s .c o m clrs[0] = colors[0]; pnts[1] = verts[1]; clrs[1] = colors[1]; pnts[2] = verts[1]; clrs[2] = colors[1]; pnts[3] = verts[2]; clrs[3] = colors[2]; pnts[4] = verts[2]; clrs[4] = colors[2]; pnts[5] = verts[0]; clrs[5] = colors[0]; pnts[6] = verts[1]; clrs[6] = colors[1]; pnts[7] = verts[3]; clrs[7] = colors[3]; pnts[8] = verts[2]; clrs[8] = colors[2]; pnts[9] = verts[3]; clrs[9] = colors[3]; pnts[10] = verts[0]; clrs[10] = colors[0]; pnts[11] = verts[3]; clrs[11] = colors[3]; setCoordinates(0, pnts); setColors(0, clrs); }
From source file:PickTest.java
TetrahedronITA() { super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 12); Point3f verts[] = new Point3f[4]; Color3f colors[] = new Color3f[4]; verts[0] = new Point3f(1.0f, 1.0f, 1.0f); verts[1] = new Point3f(1.0f, -1.0f, -1.0f); verts[2] = new Point3f(-1.0f, -1.0f, 1.0f); verts[3] = new Point3f(-1.0f, 1.0f, -1.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); int pntsIndex[] = new int[12]; int clrsIndex[] = new int[12]; pntsIndex[0] = 2;//w ww . j a v a 2 s. c o m clrsIndex[0] = 0; pntsIndex[1] = 1; clrsIndex[1] = 0; pntsIndex[2] = 0; clrsIndex[2] = 0; pntsIndex[3] = 3; clrsIndex[3] = 1; pntsIndex[4] = 2; clrsIndex[4] = 1; pntsIndex[5] = 0; clrsIndex[5] = 1; pntsIndex[6] = 1; clrsIndex[6] = 2; pntsIndex[7] = 2; clrsIndex[7] = 2; pntsIndex[8] = 3; clrsIndex[8] = 2; pntsIndex[9] = 1; clrsIndex[9] = 3; pntsIndex[10] = 3; clrsIndex[10] = 3; pntsIndex[11] = 0; clrsIndex[11] = 3; setCoordinates(0, verts); setCoordinateIndices(0, pntsIndex); setColors(0, colors); setColorIndices(0, clrsIndex); }
From source file:PickTest.java
TetrahedronIPA() { super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 4); Point3f verts[] = new Point3f[4]; Color3f colors[] = new Color3f[4]; verts[0] = new Point3f(1.0f, 1.0f, 1.0f); verts[1] = new Point3f(1.0f, -1.0f, -1.0f); verts[2] = new Point3f(-1.0f, -1.0f, 1.0f); verts[3] = new Point3f(-1.0f, 1.0f, -1.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); int pntsIndex[] = new int[4]; int clrsIndex[] = new int[4]; pntsIndex[0] = clrsIndex[0] = 0;/* w ww .j ava 2 s . c o m*/ pntsIndex[1] = clrsIndex[1] = 1; pntsIndex[2] = clrsIndex[2] = 2; pntsIndex[3] = clrsIndex[3] = 3; setCoordinates(0, verts); setCoordinateIndices(0, pntsIndex); setColors(0, colors); setColorIndices(0, clrsIndex); }
From source file:AppearanceExplorer.java
Shape3D createColorCube() { // color cube int[] indices = { 0, 3, 4, 2, // left face x = -1 0, 1, 5, 3, // bottom face y = -1 0, 2, 6, 1, // back face z = -1 7, 5, 1, 6, // right face x = 1 7, 6, 2, 4, // top face y = 1 7, 4, 3, 5 // front face z = 1 };//from w w w .ja va 2 s. com Point3f pts[] = new Point3f[8]; pts[0] = new Point3f(-1.0f, -1.0f, -1.0f); pts[1] = new Point3f(1.0f, -1.0f, -1.0f); pts[2] = new Point3f(-1.0f, 1.0f, -1.0f); pts[3] = new Point3f(-1.0f, -1.0f, 1.0f); pts[4] = new Point3f(-1.0f, 1.0f, 1.0f); pts[5] = new Point3f(1.0f, -1.0f, 1.0f); pts[6] = new Point3f(1.0f, 1.0f, -1.0f); pts[7] = new Point3f(1.0f, 1.0f, 1.0f); Color3f colr[] = new Color3f[8]; colr[0] = black; colr[1] = red; colr[2] = green; colr[3] = blue; colr[4] = cyan; colr[5] = magenta; colr[6] = yellow; colr[7] = white; // The normals point out from 0,0,0, through the verticies of the // cube. These can be calculated by copying the coordinates to // a Vector3f and normalizing. Vector3f norm[] = new Vector3f[8]; for (int i = 0; i < 8; i++) { norm[i] = new Vector3f(pts[i]); norm[i].normalize(); } IndexedQuadArray iqa = new IndexedQuadArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.NORMALS, 24); iqa.setCoordinates(0, pts); iqa.setColors(0, colr); iqa.setNormals(0, norm); iqa.setCoordinateIndices(0, indices); iqa.setColorIndices(0, indices); iqa.setNormalIndices(0, indices); return new Shape3D(iqa, appearance); }
From source file:PickTest.java
IcosahedronTSA() { super(32, GeometryArray.COORDINATES | GeometryArray.COLOR_3, sVertCnt); Point3f verts[] = new Point3f[12]; Color3f colors[] = new Color3f[12]; verts[0] = new Point3f(0.0f, 1.4f, 0.8652f); verts[1] = new Point3f(0.0f, 1.4f, -0.8652f); verts[2] = new Point3f(1.4f, 0.8652f, 0.0f); verts[3] = new Point3f(1.4f, -0.8652f, 0.0f); verts[4] = new Point3f(0.0f, -1.4f, -0.8652f); verts[5] = new Point3f(0.0f, -1.4f, 0.8652f); verts[6] = new Point3f(0.8652f, 0.0f, 1.4f); verts[7] = new Point3f(-0.8652f, 0.0f, 1.4f); verts[8] = new Point3f(0.8652f, 0.0f, -1.4f); verts[9] = new Point3f(-0.8652f, 0.0f, -1.4f); verts[10] = new Point3f(-1.4f, 0.8652f, 0.0f); verts[11] = new Point3f(-1.4f, -0.8652f, 0.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); colors[4] = new Color3f(0.0f, 1.0f, 1.0f); colors[5] = new Color3f(1.0f, 0.0f, 1.0f); colors[6] = new Color3f(0.0f, 0.5f, 0.0f); colors[7] = new Color3f(0.0f, 0.0f, 0.5f); colors[8] = new Color3f(0.5f, 0.5f, 0.0f); colors[9] = new Color3f(0.0f, 0.5f, 0.5f); colors[10] = new Color3f(0.5f, 0.0f, 0.5f); colors[11] = new Color3f(0.5f, 0.5f, 0.5f); Point3f pnts[] = new Point3f[32]; Color3f clrs[] = new Color3f[32]; pnts[0] = verts[4];// w w w . j av a 2s . com clrs[0] = colors[4]; pnts[1] = verts[5]; clrs[1] = colors[5]; pnts[2] = verts[11]; clrs[2] = colors[11]; pnts[3] = verts[11]; clrs[3] = colors[11]; pnts[4] = verts[5]; clrs[4] = colors[5]; pnts[5] = verts[7]; clrs[5] = colors[7]; pnts[6] = verts[6]; clrs[6] = colors[6]; pnts[7] = verts[0]; clrs[7] = colors[0]; pnts[8] = verts[2]; clrs[8] = colors[2]; pnts[9] = verts[1]; clrs[9] = colors[1]; pnts[10] = verts[8]; clrs[10] = colors[8]; pnts[11] = verts[9]; clrs[11] = colors[9]; pnts[12] = verts[4]; clrs[12] = colors[4]; pnts[13] = verts[11]; clrs[13] = colors[11]; pnts[14] = verts[2]; clrs[14] = colors[2]; pnts[15] = verts[6]; clrs[15] = colors[6]; pnts[16] = verts[3]; clrs[16] = colors[3]; pnts[17] = verts[5]; clrs[17] = colors[5]; pnts[18] = verts[4]; clrs[18] = colors[4]; pnts[19] = verts[4]; clrs[19] = colors[4]; pnts[20] = verts[8]; clrs[20] = colors[8]; pnts[21] = verts[3]; clrs[21] = colors[3]; pnts[22] = verts[2]; clrs[22] = colors[2]; pnts[23] = verts[0]; clrs[23] = colors[0]; pnts[24] = verts[1]; clrs[24] = colors[1]; pnts[25] = verts[10]; clrs[25] = colors[10]; pnts[26] = verts[9]; clrs[26] = colors[9]; pnts[27] = verts[11]; clrs[27] = colors[11]; pnts[28] = verts[0]; clrs[28] = colors[0]; pnts[29] = verts[10]; clrs[29] = colors[10]; pnts[30] = verts[7]; clrs[30] = colors[7]; pnts[31] = verts[11]; clrs[31] = colors[11]; setCoordinates(0, pnts); setColors(0, clrs); }
From source file:PickTest.java
IcosahedronITSA() { super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 32, sVertCnt); Point3f verts[] = new Point3f[12]; Color3f colors[] = new Color3f[12]; verts[0] = new Point3f(0.0f, 1.4f, 0.8652f); verts[1] = new Point3f(0.0f, 1.4f, -0.8652f); verts[2] = new Point3f(1.4f, 0.8652f, 0.0f); verts[3] = new Point3f(1.4f, -0.8652f, 0.0f); verts[4] = new Point3f(0.0f, -1.4f, -0.8652f); verts[5] = new Point3f(0.0f, -1.4f, 0.8652f); verts[6] = new Point3f(0.8652f, 0.0f, 1.4f); verts[7] = new Point3f(-0.8652f, 0.0f, 1.4f); verts[8] = new Point3f(0.8652f, 0.0f, -1.4f); verts[9] = new Point3f(-0.8652f, 0.0f, -1.4f); verts[10] = new Point3f(-1.4f, 0.8652f, 0.0f); verts[11] = new Point3f(-1.4f, -0.8652f, 0.0f); 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); colors[3] = new Color3f(1.0f, 1.0f, 0.0f); colors[4] = new Color3f(0.0f, 1.0f, 1.0f); colors[5] = new Color3f(1.0f, 0.0f, 1.0f); colors[6] = new Color3f(0.0f, 0.5f, 0.0f); colors[7] = new Color3f(0.0f, 0.0f, 0.5f); colors[8] = new Color3f(0.5f, 0.5f, 0.0f); colors[9] = new Color3f(0.0f, 0.5f, 0.5f); colors[10] = new Color3f(0.5f, 0.0f, 0.5f); colors[11] = new Color3f(0.5f, 0.5f, 0.5f); int pntsIndex[] = new int[32]; int clrsIndex[] = new int[32]; pntsIndex[0] = 4;// w w w .j av a 2 s .c om clrsIndex[0] = 4; pntsIndex[1] = 5; clrsIndex[1] = 5; pntsIndex[2] = 11; clrsIndex[2] = 11; pntsIndex[3] = 11; clrsIndex[3] = 11; pntsIndex[4] = 5; clrsIndex[4] = 5; pntsIndex[5] = 7; clrsIndex[5] = 7; pntsIndex[6] = 6; clrsIndex[6] = 6; pntsIndex[7] = 0; clrsIndex[7] = 0; pntsIndex[8] = 2; clrsIndex[8] = 2; pntsIndex[9] = 1; clrsIndex[9] = 1; pntsIndex[10] = 8; clrsIndex[10] = 8; pntsIndex[11] = 9; clrsIndex[11] = 9; pntsIndex[12] = 4; clrsIndex[12] = 4; pntsIndex[13] = 11; clrsIndex[13] = 11; pntsIndex[14] = 2; clrsIndex[14] = 2; pntsIndex[15] = 6; clrsIndex[15] = 6; pntsIndex[16] = 3; clrsIndex[16] = 3; pntsIndex[17] = 5; clrsIndex[17] = 5; pntsIndex[18] = 4; clrsIndex[18] = 4; pntsIndex[19] = 4; clrsIndex[19] = 4; pntsIndex[20] = 8; clrsIndex[20] = 8; pntsIndex[21] = 3; clrsIndex[21] = 3; pntsIndex[22] = 2; clrsIndex[22] = 2; pntsIndex[23] = 0; clrsIndex[23] = 0; pntsIndex[24] = 1; clrsIndex[24] = 1; pntsIndex[25] = 10; clrsIndex[25] = 10; pntsIndex[26] = 9; clrsIndex[26] = 9; pntsIndex[27] = 11; clrsIndex[27] = 11; pntsIndex[28] = 0; clrsIndex[28] = 0; pntsIndex[29] = 10; clrsIndex[29] = 10; pntsIndex[30] = 7; clrsIndex[30] = 7; pntsIndex[31] = 11; clrsIndex[31] = 11; setCoordinates(0, verts); setCoordinateIndices(0, pntsIndex); setColors(0, colors); setColorIndices(0, clrsIndex); }