public ShapeGroup duplicate() { final ShapeGroup ret = new ShapeGroup(); if (shape != null) { ret.shape = new Shape3D(shape.getGeometry(), shape.getAppearance()); ret.group.addChild(ret.shape); } ret.pos = pos; return ret; } }
lsa.setNormals(0, normals); lsa.setCoordinates(0, pts); Shape3D sh=new Shape3D(); PolygonAttributes pa=new PolygonAttributes(); pa.setPolygonMode(PolygonAttributes.POLYGON_FILL); app.setMaterial(mat); app.setPolygonAttributes(pa); sh.setGeometry(lsa); sh.setAppearance(app); sh.setPickable(true); TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
/** * Checks whether the geometry in this shape node intersects with * the specified pickShape. * * @param path the SceneGraphPath to this shape node * @param pickShape the PickShape to be intersected * * @return true if the pick shape intersects this node; false * otherwise. * * @exception IllegalArgumentException if pickShape is a PickPoint. * Java 3D doesn't have spatial information of the surface. * Use PickBounds with BoundingSphere and a small radius, instead. * * @exception CapabilityNotSetException if the Geometry.ALLOW_INTERSECT * capability bit is not set in all of the Geometry objects * referred to by this shape node. */ public boolean intersect(SceneGraphPath path, PickShape pickShape) { return intersect(path, pickShape, null); }
/** * Used to create a new instance of the node. This routine is called * by <code>cloneTree</code> to duplicate the current node. * <code>cloneNode</code> should be overridden by any user subclassed * objects. All subclasses must have their <code>cloneNode</code> * method consist of the following lines: * <P><blockquote><pre> * public Node cloneNode(boolean forceDuplicate) { * UserSubClass usc = new UserSubClass(); * usc.duplicateNode(this, forceDuplicate); * return usc; * } * </pre></blockquote> * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @see Node#cloneTree * @see Node#duplicateNode * @see NodeComponent#setDuplicateOnCloneTree */ @Override public Node cloneNode(boolean forceDuplicate) { Shape3D s = new Shape3D(); s.duplicateNode(this, forceDuplicate); return s; }
final Appearance a = appCreator.getAppearance(axis, index); final Shape3D frontShape = new Shape3D(quadArray, a); frontShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); frontShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ); front.addChild(frontShapeGroup); final Shape3D backShape = new Shape3D(quadArray, a); backShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ); backShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
@Override protected org.scijava.java3d.SceneGraphObject createNode() { return new Shape3D(); }
/** * Use the currently selected color to paint an edge. * * @param shape a Java3D shape - must be a LineArray * */ void highlightEdge(Shape3D shape) { Color3f highlightColor = volumes.getSelectedColor(); if (shape.getGeometry() instanceof LineArray) { Appearance appearance = shape.getAppearance(); ColoringAttributes ca = appearance.getColoringAttributes(); Color3f before = new Color3f(); appearance.setColoringAttributes(ca); ca.getColor(before); ca.setColor(highlightColor); } }
p[7] = new Point3f(min.x, max.y, min.z); final Shape3D shape = new Shape3D(); shape.setName("BB"); final float fz = tickDistance - (this.min.z % tickDistance); shape.addGeometry(makeLine(p[0], p[1], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[1], p[2], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[2], p[3], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[3], p[0], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[4], p[5], c, td, fx, ts, false)); shape.addGeometry(makeLine(p[5], p[6], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[6], p[7], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[4], p[7], c, td, fy, ts, false)); shape.addGeometry(makeLine(p[4], p[0], c, td, fz, ts, false)); shape.addGeometry(makeLine(p[1], p[5], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[2], p[6], c, td, 0f, ts, true)); shape.addGeometry(makeLine(p[3], p[7], c, td, 0f, ts, true)); shape.setAppearance(createAppearance(color)); addChild(shape);
/** Gets the appearance of the primitive (defaults to first subpart). */ public Appearance getAppearance(){ return getShape(0).getAppearance(); }
Shape3D shape = new Shape3D(); shape.setGeometry(gi.getGeometryArray(false, false, false));
shape[BODY] = new Shape3D(cache.getComputedGeometry()); numVerts += cache.getNumVerts(); numTris += cache.getNumTris(); xdivisions, 1.0-1.0/(double)ydivisions, outside, texCoordYUp); shape[BODY] = new Shape3D(gbuf.getGeom(flags)); numVerts += gbuf.getNumVerts(); numTris += gbuf.getNumTris(); shape[BODY].addGeometry(cache.getComputedGeometry()); numVerts += cache.getNumVerts(); numTris += cache.getNumTris(); xdivisions, ydivisions-1, 1.0/(double)ydivisions, outside, texCoordYUp); shape[BODY].addGeometry(gbuf.getGeom(flags)); numVerts += gbuf.getNumVerts(); numTris += gbuf.getNumTris(); (shape[BODY]).setCapability(Shape3D.ALLOW_APPEARANCE_READ); (shape[BODY]).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); (shape[BODY]).setCapability(Shape3D.ALLOW_GEOMETRY_READ); shape[CAP] = new Shape3D(cache.getComputedGeometry()); numVerts += cache.getNumVerts(); numTris += cache.getNumTris();
public Shape3DState( SymbolTableData symbol, Controller control ) { super( symbol, control ); if (node!=null) { appearance = control.getSymbolTable().addReference( ((Shape3D)node).getAppearance() ); int length = ((Shape3D)node).numGeometries(); geometry = new int[length]; for(int i=0; i<length; i++) geometry[i] = control.getSymbolTable().addReference( ((Shape3D)node).getGeometry(i) ); } }
public Scalebar(final float length) { final Transform3D position = new Transform3D(); positionTG = new TransformGroup(position); positionTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); positionTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); addChild(positionTG); lineShape = new Shape3D(); lineShape.setGeometry(createLineGeometry()); lineShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); positionTG.addChild(lineShape); final Transform3D texttranslate = new Transform3D(); texttranslate.setTranslation(new Vector3f(length / 2, -length / 2, 0.0f)); textTG = new TransformGroup(texttranslate); textTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); positionTG.addChild(textTG); textShape = new OrientedShape3D(); textShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); textShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); textShape.setGeometry(createTextGeometry()); textShape.setAppearance(createTextAppearance()); textShape.setAlignmentAxis(0.0f, 1.0f, 0.0f); textTG.addChild(textShape); }
/** * Draw the specified Shape3D leaf node object. This is * a convenience method that is identical to calling the * setAppearance(Appearance) and draw(Geometry) methods * passing the appearance and geometry component objects of * the specified shape node as arguments. * * @param shape the Shape3D node containing the Appearance component * object to set and Geometry component object to draw * * @exception IllegalSharingException if the Shape3D node * is part of or is subsequently made part of a live scene graph. * * @exception IllegalSharingException if the Shape3D node's Appearance * refers to an ImageComponent2D that is being used by a * Canvas3D as an off-screen buffer. */ public void draw(Shape3D shape) { if (shape.isLive()) { throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D26")); } ((Shape3DRetained)shape.retained).setInImmCtx(true); setAppearance(shape.getAppearance()); draw(shape.getGeometry()); }
Shape3D plShape = new Shape3D(); int vIndex=-1; int k=0; lsa.setColor(vIndex, new Color3f(0.9f,0.0f,0.0f)); plShape.addGeometry(lsa);
Shape3D edgeShape = new Shape3D(la, appearance); edgeShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ); edgeShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); edgeShape.setUserData(ud);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ); throw new IllegalArgumentException("Improper level"); for (int i = 0; i < shape.numGeometries(); i++) { Geometry geo = shape.getGeometry(i); if (geo instanceof GeometryArray) { setCapabilities((GeometryArray)geo, level);
if (node instanceof Shape3D) { Shape3D shape = (Shape3D) node; if (shape.getGeometry() instanceof LineArray) { Appearance appearance = shape.getAppearance(); ColoringAttributes ca = appearance.getColoringAttributes(); ca.getColor(currentColor); LineArray segments = (LineArray) shape.getGeometry(); int nSegs = segments.getVertexCount(); for (int i = 0; i < nSegs; i++) { UserData ud = (UserData) (shape.getUserData()); ud.setColorIndex(99);
@Override public void buildGraph() { ((Shape3D)node).setAppearance( (Appearance)control.getSymbolTable().getJ3dNode( appearance ) ); ((Shape3D)node).setGeometry( (Geometry)control.getSymbolTable().getJ3dNode( geometry[0] ) ); for(int i=1; i<geometry.length; i++) { ((Shape3D)node).addGeometry( (Geometry)control.getSymbolTable().getJ3dNode( geometry[i] ) ); } super.buildGraph(); // Must be last call in method }
float radius = 2.4f; int divisions = 24; // Further flags: GENERATE_TEXTURE_COORDS etc. int primflags = Sphere.GEOMETRY_NOT_SHARED | Sphere.GENERATE_NORMALS; Sphere sphere = new Sphere(radius, primflags, divisions); Shape3D shape3D = sphere.getShape(); Geometry = shape3D.getGeometry(); // Your desired result ! shape3D.setGeometry(null);