Refine search
scene.compile(); BranchGroup lineGroup = new BranchGroup(); Appearance app = new Appearance(); ColoringAttributes ca = new ColoringAttributes(new Color3f(204.0f, 204.0f, 204.0f), ColoringAttributes.SHADE_FLAT); pla.setCoordinates(0, plaPts); Shape3D plShape = new Shape3D(pla, app); TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.addChild(plShape); lineGroup.addChild(objRotate); return lineGroup;
TransformGroup translate(Node node,Vector3f vector){ Transform3D transform3D = new Transform3D(); transform3D.setTranslation(vector); TransformGroup transformGroup = new TransformGroup(); transformGroup.setTransform(transform3D); transformGroup.addChild(node); return transformGroup; } for(int i=0;vec[i];i++) translate(Your_Object,new Vector3f(x,y,vec[i]); //do this while you still have elements in your vector. //you may want to set a value, let's say 2500 that indicates that you ran out of objects //in that case, you will have for(int i=0;vec[i]!=2500;i++)
final BranchGroup bg1 = new BranchGroup(); bg1.setCapability( BranchGroup.ALLOW_DETACH ); bg1.addChild( node ); spotSwitch.addChild( bg1 ); textShape.setAppearance( textAp ); final Transform3D translation = new Transform3D(); translation.rotX( Math.PI ); translation.setTranslation( new Vector3d( center.x + 1.5f * center.w, center.y, center.z ) ); final TransformGroup tg = new TransformGroup( translation ); tg.addChild( textShape ); final BranchGroup bg2 = new BranchGroup(); bg2.setCapability( BranchGroup.ALLOW_DETACH );
v3f.z = p.z; final BranchGroup bg = new BranchGroup(); bg.setName(name); bg.setCapability(BranchGroup.ALLOW_DETACH); t3d.set(v3f); final TransformGroup tg = new TransformGroup(t3d); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); bg.addChild(tg); final TransformGroup sig = new TransformGroup(); sig.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg.addChild(sig); si.setSchedulingBounds(bs); tg.addChild(si); sphere.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY); sphere.setAppearance(appearance); sig.addChild(sphere); addText(tg, name, p, color); final Transform3D scaleTransform = new Transform3D(); sig.getTransform(scaleTransform); scaleTransform.setScale(radius); sig.setTransform(scaleTransform);
public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); Transform3D rotate = new Transform3D(); Transform3D tempRotate = new Transform3D(); rotate.rotX(Math.PI/4.0d); tempRotate.rotY(Math.PI/5.0d); rotate.mul(tempRotate); TransformGroup objRotate = new TransformGroup(rotate); TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objRotate); objRotate.addChild(objSpin); objSpin.addChild(new ColorCube(0.4)); objSpin.addChild(rotator);
BranchGroup group = new BranchGroup(); group.addChild(createModel()); universe.getViewingPlatform().setNominalViewingTransform(); universe.addBranchGraph(group); Transform3D transform = new Transform3D(); Transform3D translate1 = new Transform3D(); translate1.setTranslation(new Vector3d(0.0, -radius, 0.0)); transform.mul(translate1, transform); transform.mul(translate2, transform); TransformGroup tg = new TransformGroup(); tg.setTransform(transform); tg.addChild(cube); return tg;
TransformGroup tg2 = new TransformGroup (); //set the appearance of the product boxes (transparent) Appearance app = new Appearance(); app.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.BLENDED,0.2f)); //create a box having length = l, breadth = b and height = h Box box = new Box( (float )item[p].getLength(), (float) item[p].getBreadth(), (float) item[p].getHeight(), app); // vector to translate the item box to the position (x, y, z) Vector3f position = new Vector3f((float) x, (float) y, (float) z); //creation of a 3D transform group Transform3D transform = new Transform3D(); transform.setTranslation(position); tg2.setTransform(transform); //add new item box to the transform group tg2.addChild(box); tg2.setCapability(Group.ALLOW_CHILDREN_EXTEND); BranchGroup scene = new BranchGroup(); scene.addChild(tg2); scene1.addChild(scene);
public void addVertex(Image3DUniverse univ, Color3f color, float x, float y, float z) { BranchGroup bg = new BranchGroup(); bg.setCapability(BranchGroup.ALLOW_DETACH); TransformGroup tg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3f(x, y, z)); tg.setTransform(t3d); bg.addChild(tg); Appearance app = new Appearance(); ColoringAttributes cattr = new ColoringAttributes(); cattr.setColor(color); app.setColoringAttributes(cattr); tg.addChild(new Sphere(0.1f, app)); univ.getScene().addChild(bg); }
echoTransformGroup = new TransformGroup() ; echoTransformGroup.setCapability (TransformGroup.ALLOW_TRANSFORM_WRITE) ; sensor.getHotspot(hotspot) ; Transform3D t3d = new Transform3D() ; Vector3f v3f = new Vector3f(hotspot) ; t3d.set(v3f) ; echoTransformGroup.addChild(echo) ;
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); }
TransformGroup modelGroupReset = new TransformGroup(); TransformGroup modelGroup = new TransformGroup(); modelGroupReset.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); modelGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); modelGroupReset.addChild(modelGroup); JButton resetButton = new JButton(); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Transform3D t3d = new Transform3D(); modelGroup.getTransform(t3d); t3d.invert(); modelGroupReset.setTransform(t3d); } });
for(j=0; j<group.numChildren(); j++) { Node ni=group.getChild(j); if(ni instanceof TransformGroup) { Transform3D tdi=new Transform3D(); TransformGroup tgi=(TransformGroup)group.getChild(j); tgi.getTransform(tdi); Transform3D rotation = new Transform3D(); rotation.rotX(Math.toRadians(0.001*i)); tdi.mul(rotation); tgi.setTransform(tdi); } }
scene1 = new BranchGroup(); Transform3D rotateCube = new Transform3D(); rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI /4.0)); tg1.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg1.addChild(container);
/** * Rotate the univere so that the user looks in the negative direction of the * z-axis. */ public void rotateToNegativeXY() { fireTransformationStarted(); getRotationTG().setTransform(new Transform3D()); fireTransformationFinished(); }
/** * Set the radius of the points. * * @param r */ public void setRadius(final float r) { this.radius = r; final Transform3D t3d = new Transform3D(); for (int i = 0; i < numChildren(); i++) { final BranchGroup bg = (BranchGroup) getChild(i); final TransformGroup tg = (TransformGroup) bg.getChild(0); final ScaleInterpolator si = (ScaleInterpolator) tg.getChild(1); if (si != null) { si.setMaximumScale(5 * radius); si.setMinimumScale(radius); } final TransformGroup sig = (TransformGroup) tg.getChild(0); sig.getTransform(t3d); t3d.setScale(radius); sig.setTransform(t3d); } }
BranchGroup group = new BranchGroup(); Transform3D transform= new Transform3D(); Vector3d vector = new Vector3d(-0.5, 0.0, 0.4); Transform3D transform = new Transform3D(); transformGroup.addChild(cube); group.addChild(transformGroup);
translateRootTG.addChild(hexaGrid); Polygon myPolygon = hexaGrid.getPolygon(19,1); // Get the First TransformGroup that containt the first Translation TransformGroup firstTransform= (TransformGroup)myPolygon.getParent(); // the the Second TransfromGroup that containt the secondary Translation TransformGroup secondTransform = (TransformGroup)myPolygon.getParent().getParent().getParent().getParent(); // Get the Transform3D from the first TransformGroup Transform3D firstTranslation = new Transform3D(); firstTransform.getTransform(firstTranslation); // put the Transform in T3D var // Get the Transform3D from the second TransformGroup Transform3D secondTranslation = new Transform3D(); secondTransform.getTransform(secondTranslation); // put the Transform in T3D var // Mul Transform3D to have complete translation Transform3D t3DTotalPolygon = new Transform3D(); t3DTotalPolygon.mul(firstTranslation, secondTranslation); TransformGroup tgTest = new TransformGroup(t3DTotalPolygon); tgTest.addChild(new ColorCube(0.03f)); translateRootTG.addChild(tgTest);
public void setPosition(final float x, final float y) { this.x = x; this.y = y; final Transform3D p = new Transform3D(); p.setTranslation(new Vector3f(x, y, 0.0f)); positionTG.setTransform(p); }
TransformGroup modelGroup = new TransformGroup(); modelGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); modelGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); JButton resetButton = new JButton(); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { modelGroup.setTransform( new Transform3D()); } });
/** * Copy the whole transformation, which transforms any point from the vworld * coordinate system to the observer coordinate system. */ public void getVworldToCamera(final Transform3D transform) { final Transform3D tmp = new Transform3D(); getCenterTG().getTransform(transform); getTranslateTG().getTransform(tmp); transform.mul(tmp); getRotationTG().getTransform(tmp); transform.mul(tmp); getZoomTG().getTransform(tmp); transform.mul(tmp); transform.invert(); }