public void setApperance() { Appearance app = null; if (state == FILL.POINT) app = new PointAppearance(color); else if (state == FILL.GRID) app = new GridAppearance(color); else app = new ColorAppearance(color); shape.setAppearance(app); }
/** * Sets the appearance. * * @param shape the new appearance */ private void setAppearance(Shape3D shape) { Appearance sphereApp = new Appearance(); TransparencyAttributes sphereTrans = new TransparencyAttributes(); PolygonAttributes spherePa = new PolygonAttributes(); spherePa.setCullFace(PolygonAttributes.CULL_NONE); sphereApp.setPolygonAttributes(spherePa); sphereTrans.setTransparency(0.6f); sphereTrans.setTransparencyMode(TransparencyAttributes.NICEST); sphereApp.setTransparencyAttributes(sphereTrans); shape.setAppearance(sphereApp); }
@Deprecated public void addText(String text, Font3D font, Color3f color, Point3f position) { Text3D renderedText = new Text3D(font, text); renderedText.setAlignment(Text3D.ALIGN_CENTER); Shape3D textShape = new Shape3D(); textShape.setGeometry(renderedText); textShape.setAppearance( Utils.makeAppearance(getSettings().getPolygonSettings().toJ3DPolygonAttributes(), color)); textShape.setBounds(getSettings().getRenderSettings3D().getBounds()); Transform3D transform = new Transform3D(); transform.setTranslation(new Vector3f(position)); // Math3D.scale(transformations, DEFAULT_SCALE); TransformGroup transformations = new TransformGroup(); transformations.setTransform(transform); transformations.addChild(textShape); getScene().addChild(transformations); getLogger().info("Text ('" + text + "') added to scene."); }
private void createTriangle() { int[] stripCount = {3}; GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); gi.setCoordinates(points); gi.setStripCounts(stripCount); NormalGenerator ng = new NormalGenerator(); ng.generateNormals(gi); gi.recomputeIndices(); Stripifier st = new Stripifier(); st.stripify(gi); gi.recomputeIndices(); Appearance appearance = new Appearance(); Material material = new Material(); material.setAmbientColor(new Color3f(Color.GREEN)); appearance.setMaterial(material); shape3D = new Shape3D(); shape3D.setGeometry(gi.getGeometryArray()); shape3D.setAppearance(appearance); }
public WireNode(double len, double rad) { // super(2); // // setGeometry(0,Cylinder.makeGeometry(24,rad,len).getIndexedGeometryArray(),0); super(); Shape3D wire = new Shape3D(); initShape(wire); wire.setGeometry(Cylinder.makeGeometry(24, rad, len).getIndexedGeometryArray()); Appearance app = Node3D.makeAppearance(new Color3f(new Color(154, 105, 0)), .8f, 0.5f, false); TransparencyAttributes ta = new TransparencyAttributes( TransparencyAttributes.NICEST, 0.5f); // app.getTransparencyAttributes(); // ta.setTransparency(0.5f); app.setTransparencyAttributes(ta); wire.setAppearance(app); mContents.addChild(wire); ////////////////////////////////////////////////////////////////////// /* txt = new Text2D("This is a Text2D!!", new Color3f(0.f,0.f,0.f),"SansSerif",70,Font.PLAIN); txt.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); txt.setCapability(Shape3D.ALLOW_APPEARANCE_READ); txt.setCapability(Shape3D.ALLOW_GEOMETRY_READ); txt.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); Appearance a = txt.getAppearance(); a.setCapability(Appearance.ALLOW_TEXTURE_READ); a.setCapability(Appearance.ALLOW_TEXTURE_WRITE); txt.setAppearance(a); TransformGroup bbtg = new TransformGroup(); bbtg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D t = new Transform3D(); t.setScale(50.); bbtg.setTransform(t); bbtg.addChild(txt); Billboard bb = new Billboard(bbtg,Billboard.ROTATE_ABOUT_POINT,new Point3f(0.f,0.f,0.f)); bb.setSchedulingBounds(new BoundingSphere(new Point3d(0.,0.,0.), 100.)); bbtg.addChild(bb); mContents.addChild(bbtg); */ /////////////////////////////////////////////////////////////////////// Shape3D line = new Shape3D(); initShape(line); // line.setGeometry(sLine); Geometry stem = teal.render.j3d.geometry.Cylinder.makeGeometry(20, 0.05, 1, 0.5) .getIndexedGeometryArray(true); line.setGeometry(stem); Cone fatcone = new Cone(0.2f, 0.25f); Shape3D cone = new Shape3D(); initShape(cone); cone.setGeometry(fatcone.getShape(Cone.BODY).getGeometry()); cone.addGeometry(fatcone.getShape(Cone.CAP).getGeometry()); TransformGroup translated_cone = new TransformGroup(); Transform3D tran = new Transform3D(); // tran.set( new Vector3f(0.f,0.95f,0.f)); tran.set(new Vector3f(0.f, 1.f, 0.f)); translated_cone.addChild(cone); translated_cone.setTransform(tran); arrow.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); arrow.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // arrow.addChild(line); // arrow.addChild(translated_cone); Appearance arrowAppearance = Node3D.makeAppearance(new Color3f(new Color(154, 105, 0)), 0.f, 0.f, false); line.setAppearance(arrowAppearance); cone.setAppearance(arrowAppearance); arrow.addChild(line); arrow.addChild(translated_cone); Transform3D tran2 = new Transform3D(); // tran2.set(new Vector3f(0.f,-0.5f,0.f)); tran2.setScale(4.); arrow.setTransform(tran2); mContents.addChild(arrow); }