List of usage examples for javax.media.j3d Appearance setPointAttributes
public void setPointAttributes(PointAttributes pointAttributes)
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);// ww w . j a v a2 s .c o m 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:MixedTest.java
public void renderField(int fieldDesc) { super.renderField(fieldDesc); GraphicsContext3D g = getGraphicsContext3D(); // first time initialization if (m_nRender == 0) { // set the start time m_StartTime = System.currentTimeMillis(); // add a light to the graphics context DirectionalLight light = new DirectionalLight(); light.setEnable(true);//from w ww. j av a 2 s.c om g.addLight((Light) light); // create the material for the points Appearance a = new Appearance(); Material mat = new Material(); mat.setLightingEnable(true); mat.setAmbientColor(0.5f, 1.0f, 1.0f); a.setMaterial(mat); a.setColoringAttributes(new ColoringAttributes(1.0f, 0.5f, 0.5f, ColoringAttributes.NICEST)); // enlarge the points a.setPointAttributes(new PointAttributes(4, true)); // make the appearance current in the graphics context g.setAppearance(a); } // set the current transformation for the graphics context g.setModelTransform(m_t3d); // finally render the PointArray g.draw(m_PointArray); // calculate and display the Frames Per Second for the // Immediate Mode rendering of the PointArray m_nRender++; if ((m_nRender % m_kReportInterval) == 0) { float fps = (float) 1000.0f / ((System.currentTimeMillis() - m_StartTime) / (float) m_kReportInterval); System.out.println("FPS:\t" + fps); m_StartTime = System.currentTimeMillis(); } }
From source file:BackgroundApp.java
public BranchGroup createBackGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); PointArray starGeom1 = new PointArray(7, PointArray.COORDINATES); Appearance starAppear1 = new Appearance(); starGeom1.setCoordinate(0, new Point3f(0.79483311f, -0.58810995f, 0.14955615f)); starGeom1.setCoordinate(1, new Point3f(0.44430932f, -0.55736839f, -0.70137505f)); starGeom1.setCoordinate(2, new Point3f(0.94901367f, -0.30404968f, 0.08322775f)); starGeom1.setCoordinate(3, new Point3f(0.68060123f, -0.43044807f, 0.59287173f)); starGeom1.setCoordinate(4, new Point3f(-0.11641672f, 0.47273532f, 0.87348049f)); starGeom1.setCoordinate(5, new Point3f(-0.10399289f, -0.98059412f, 0.16619437f)); starGeom1.setCoordinate(6, new Point3f(0.08024400f, -0.96944100f, -0.23182900f)); PointAttributes point1 = new PointAttributes(4.0f, false); starAppear1.setPointAttributes(point1); objRoot.addChild(new Shape3D(starGeom1, starAppear1)); PointArray starGeom2 = new PointArray(18, PointArray.COORDINATES); starGeom2.setCoordinate(0, new Point3f(0.050844f, -0.992329f, 0.112678f)); starGeom2.setCoordinate(1, new Point3f(-0.063091f, -0.997672f, 0.025869f)); starGeom2.setCoordinate(2, new Point3f(0.096706f, -0.980384f, 0.171736f)); starGeom2.setCoordinate(3, new Point3f(-0.562384f, 0.073568f, 0.823595f)); starGeom2.setCoordinate(4, new Point3f(-0.863904f, 0.059045f, 0.500180f)); starGeom2.setCoordinate(5, new Point3f(-0.727033f, 0.304149f, 0.615559f)); starGeom2.setCoordinate(6, new Point3f(-0.724850f, 0.535590f, 0.433281f)); starGeom2.setCoordinate(7, new Point3f(0.185904f, -0.976907f, -0.105311f)); starGeom2.setCoordinate(8, new Point3f(0.738028f, -0.531886f, -0.415221f)); starGeom2.setCoordinate(9, new Point3f(-0.402152f, 0.392690f, -0.827085f)); starGeom2.setCoordinate(10, new Point3f(-0.020020f, -0.999468f, -0.025724f)); starGeom2.setCoordinate(11, new Point3f(-0.384103f, -0.887075f, 0.256050f)); starGeom2.setCoordinate(12, new Point3f(-0.224464f, -0.968946f, -0.103720f)); starGeom2.setCoordinate(13, new Point3f(-0.828880f, -0.397932f, -0.393203f)); starGeom2.setCoordinate(14, new Point3f(-0.010557f, -0.998653f, 0.050797f)); starGeom2.setCoordinate(15, new Point3f(-0.282122f, 0.258380f, -0.923930f)); starGeom2.setCoordinate(16, new Point3f(-0.941342f, -0.030364f, 0.336082f)); starGeom2.setCoordinate(17, new Point3f(0.00057f, -0.99651f, -0.08344f)); Appearance starAppear2 = new Appearance(); PointAttributes point2 = new PointAttributes(2.0f, false); starAppear2.setPointAttributes(point2); objRoot.addChild(new Shape3D(starGeom2, starAppear2)); PointArray starGeom3 = new PointArray(20, PointArray.COORDINATES); starGeom3.setCoordinate(0, new Point3f(0.07292f, -0.98862f, -0.13153f)); starGeom3.setCoordinate(1, new Point3f(0.23133f, -0.87605f, -0.42309f)); starGeom3.setCoordinate(2, new Point3f(-0.08215f, -0.64657f, 0.75840f)); starGeom3.setCoordinate(3, new Point3f(-0.84545f, 0.53398f, 0.00691f)); starGeom3.setCoordinate(4, new Point3f(-0.49365f, -0.83645f, -0.23795f)); starGeom3.setCoordinate(5, new Point3f(0.06883f, -0.99319f, -0.09396f)); starGeom3.setCoordinate(6, new Point3f(0.87582f, -0.40662f, 0.25997f)); starGeom3.setCoordinate(7, new Point3f(-0.09095f, -0.99555f, 0.02467f)); starGeom3.setCoordinate(8, new Point3f(0.45306f, -0.81575f, -0.35955f)); starGeom3.setCoordinate(9, new Point3f(0.17669f, -0.97939f, 0.09776f)); starGeom3.setCoordinate(10, new Point3f(0.27421f, -0.83963f, 0.46884f)); starGeom3.setCoordinate(11, new Point3f(0.32703f, -0.94013f, -0.09584f)); starGeom3.setCoordinate(12, new Point3f(-0.01615f, -0.99798f, -0.06132f)); starGeom3.setCoordinate(13, new Point3f(-0.76665f, 0.45998f, -0.44791f)); starGeom3.setCoordinate(14, new Point3f(-0.91025f, -0.07102f, 0.40791f)); starGeom3.setCoordinate(15, new Point3f(-0.00240f, -0.97104f, -0.23887f)); starGeom3.setCoordinate(16, new Point3f(0.91936f, -0.39244f, 0.02740f)); starGeom3.setCoordinate(17, new Point3f(0.18290f, -0.97993f, 0.07920f)); starGeom3.setCoordinate(18, new Point3f(-0.48755f, 0.61592f, 0.61884f)); starGeom3.setCoordinate(19, new Point3f(-0.89375f, 0.36087f, -0.26626f)); objRoot.addChild(new Shape3D(starGeom3)); int[] stripCount = { 10 }; LineStripArray orion = new LineStripArray(10, LineStripArray.COORDINATES, stripCount); orion.setCoordinate(0, new Point3f(0.978330f, -0.033900f, 0.204426f)); orion.setCoordinate(1, new Point3f(0.968007f, -0.167860f, 0.186506f)); orion.setCoordinate(2, new Point3f(0.981477f, -0.142660f, 0.127873f)); orion.setCoordinate(3, new Point3f(0.983764f, -0.005220f, 0.179391f)); orion.setCoordinate(4, new Point3f(0.981112f, 0.110597f, 0.158705f)); orion.setCoordinate(5, new Point3f(0.967377f, 0.172516f, 0.185523f)); orion.setCoordinate(6, new Point3f(0.961385f, 0.128845f, 0.243183f)); orion.setCoordinate(7, new Point3f(0.978330f, -0.033900f, 0.204426f)); orion.setCoordinate(8, new Point3f(0.981293f, -0.020980f, 0.191375f)); orion.setCoordinate(9, new Point3f(0.983764f, -0.005220f, 0.179391f)); objRoot.addChild(new Shape3D(orion)); objRoot.compile();/*from ww w.ja v a2 s . c om*/ return objRoot; }
From source file:AppearanceTest.java
private Appearance createAppearance(int idx) { Appearance app = new Appearance(); // Globally used colors Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); switch (idx) { // Unlit solid case 0: {/*from www . j av a2 s . c om*/ // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.2f, 0.4f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); break; } // Unlit wire frame case 1: { // Set up the coloring properties Color3f objColor = new Color3f(0.5f, 0.0f, 0.2f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_LINE); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); break; } // Unlit points case 2: { // Set up the coloring properties Color3f objColor = new Color3f(0.2f, 0.2f, 1.0f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_POINT); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up point attributes PointAttributes pta = new PointAttributes(); pta.setPointSize(5.0f); app.setPointAttributes(pta); break; } // Lit solid case 3: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } // Texture mapped, lit solid case 4: { // Set up the texture map TextureLoader tex = new TextureLoader(texImage, this); app.setTexture(tex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); app.setTextureAttributes(texAttr); // Set up the material properties app.setMaterial(new Material(white, black, white, black, 1.0f)); break; } // Transparent, lit solid case 5: { // Set up the transparency properties TransparencyAttributes ta = new TransparencyAttributes(); ta.setTransparencyMode(ta.BLENDED); ta.setTransparency(0.6f); app.setTransparencyAttributes(ta); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up the material properties Color3f objColor = new Color3f(0.7f, 0.8f, 1.0f); app.setMaterial(new Material(objColor, black, objColor, black, 1.0f)); break; } // Lit solid, no specular case 6: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); break; } // Lit solid, specular only case 7: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(black, black, black, white, 80.0f)); break; } // Another lit solid with a different color case 8: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.8f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } default: { ColoringAttributes ca = new ColoringAttributes(); ca.setColor(new Color3f(0.0f, 1.0f, 0.0f)); app.setColoringAttributes(ca); } } return app; }
From source file:TickTockPicking.java
private Appearance createAppearance(int idx) { Appearance app = new Appearance(); // Globally used colors Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); switch (idx) { // Unlit solid case 0: {//from w w w. ja v a 2 s . c o m // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.2f, 0.4f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); break; } // Unlit wire frame case 1: { // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.4f, 0.0f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_LINE); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); break; } // Unlit points case 2: { // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 1.0f, 0.0f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_POINT); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up point attributes PointAttributes pta = new PointAttributes(); pta.setPointSize(5.0f); app.setPointAttributes(pta); break; } // Lit solid case 3: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } // Texture mapped, lit solid case 4: { // Set up the texture map TextureLoader tex = new TextureLoader(texImage, this); app.setTexture(tex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); app.setTextureAttributes(texAttr); // Set up the material properties app.setMaterial(new Material(white, black, white, black, 1.0f)); break; } // Transparent, lit solid case 5: { // Set up the transparency properties TransparencyAttributes ta = new TransparencyAttributes(); ta.setTransparencyMode(ta.BLENDED); ta.setTransparency(0.6f); app.setTransparencyAttributes(ta); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up the material properties Color3f objColor = new Color3f(0.7f, 0.8f, 1.0f); app.setMaterial(new Material(objColor, black, objColor, black, 1.0f)); break; } // Lit solid, no specular case 6: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); break; } // Lit solid, specular only case 7: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(black, black, black, white, 80.0f)); break; } // Another lit solid with a different color case 8: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.8f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } default: { ColoringAttributes ca = new ColoringAttributes(); ca.setColor(new Color3f(0.0f, 1.0f, 0.0f)); app.setColoringAttributes(ca); } } return app; }
From source file:PickTest.java
private Group createObject(int index, double scale, double xpos, double ypos) { Shape3D shape = null;/*from w w w.j av a 2 s .co m*/ 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:ExAppearance.java
private Appearance createAppearance(int idx) { Appearance app = new Appearance(); // Globally used colors Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); switch (idx) { // Unlit solid case 0: {/*w w w . j av a 2s . c om*/ // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.2f, 0.4f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); break; } // Unlit wire frame case 1: { // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.2f, 0.4f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_LINE); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up line attributes LineAttributes lta = new LineAttributes(); lta.setLineWidth(10.0f); app.setLineAttributes(lta); break; } // Unlit points case 2: { // Set up the coloring properties Color3f objColor = new Color3f(1.0f, 0.2f, 0.4f); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(objColor); app.setColoringAttributes(ca); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setPolygonMode(pa.POLYGON_POINT); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up point attributes PointAttributes pta = new PointAttributes(); pta.setPointSize(10.0f); app.setPointAttributes(pta); break; } // Lit solid case 3: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } // Texture mapped, lit solid case 4: { // Set up the texture map TextureLoader tex = new TextureLoader("apimage.jpg", this); app.setTexture(tex.getTexture()); // Set up the material properties app.setMaterial(new Material(white, black, white, black, 1.0f)); break; } // Transparent, lit solid case 5: { // Set up the transparency properties TransparencyAttributes ta = new TransparencyAttributes(); ta.setTransparencyMode(ta.BLENDED); ta.setTransparency(0.6f); app.setTransparencyAttributes(ta); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(pa.CULL_NONE); app.setPolygonAttributes(pa); // Set up the material properties Color3f objColor = new Color3f(0.7f, 0.8f, 1.0f); app.setMaterial(new Material(objColor, black, objColor, black, 1.0f)); break; } // Lit solid, no specular case 6: { // Set up the material properties Color3f objColor = new Color3f(0.0f, 0.0f, 0.8f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); break; } // Lit solid, specular only case 7: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f); app.setMaterial(new Material(black, black, black, white, 80.0f)); break; } // Another lit solid with a different color case 8: { // Set up the material properties Color3f objColor = new Color3f(0.8f, 0.8f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, white, 80.0f)); break; } default: { ColoringAttributes ca = new ColoringAttributes(); ca.setColor(new Color3f(0.0f, 1.0f, 0.0f)); app.setColoringAttributes(ca); } } return app; }