TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.addChild(plShape); lineGroup.addChild(objRotate); return lineGroup;
TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.addChild(plShape); lineGroup.addChild(objRotate); return lineGroup;
TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.addChild(plShape); lineGroup.addChild(objRotate); return lineGroup;
TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.addChild(sh); light1.setColor(new Color3f(1f,1f,1f)); light1.setDirection(new Vector3f(0,1,0)); objRotate.addChild(light1); DirectionalLight light2=new DirectionalLight(); light2.setInfluencingBounds(new BoundingSphere(new Point3d(5.0,0,0),10.0)); light2.setColor(new Color3f(0.5f,1f,0.5f)); light2.setDirection(new Vector3f(0,-1,0)); objRotate.addChild(light2); MouseRotate f1=new MouseRotate(); f1.setSchedulingBounds(new BoundingSphere()); f1.setTransformGroup(objRotate); lineGroup.addChild(f1); objRotate.addChild(new Sphere(0.60f,1,128)); lineGroup.addChild(objRotate); return lineGroup;
objRotate.addChild(sh); DirectionalLight light1=new DirectionalLight(); light1.setInfluencingBounds(new BoundingSphere(new Point3d(-5.0,0,0),10.0)); light1.setColor(new Color3f(1f,1f,1f)); light1.setDirection(new Vector3f(0,1,0)); objRotate.addChild(light1); DirectionalLight light2=new DirectionalLight(); light2.setInfluencingBounds(new BoundingSphere(new Point3d(5.0,0,0),10.0)); light2.setColor(new Color3f(0.5f,1f,0.5f)); light2.setDirection(new Vector3f(0,-1,0)); objRotate.addChild(light2); MouseRotate f1=new MouseRotate(); f1.setSchedulingBounds(new BoundingSphere()); f1.setTransformGroup(objRotate); lineGroup.addChild(f1); objRotate.addChild(new Sphere(0.60f,1,128)); lineGroup.addChild(objRotate); return lineGroup;
objRotate.addChild(plShape); AmbientLight al=new AmbientLight();
// The transform group that moves the cube TransformGroup tgThatMovesTheCube = new TransformGroup(); tgThatMovesTheCube .addChild(new ColorCube(0.4)); // The transform group that "attaches" the sphere to the cube: TransformGroup tgThatAttachesTheSphere = new TransformGroup(); tgThatAttachesTheSphere.addChild(new Sphere(...)); // The transform of this transform group: It is a transform // that moves the sphere (from its original position) to // one side of the cube (at its original position) Transform3D attachingTransform = new Transform3D(); attachingTransform.setTranslation(new Vector3f(1,0,0)); tgThatAttachesTheSphere.setTransform(attachingTransform); // Attach the transformed (!) sphere to the same TG as the cube: tgThatMovesTheCube.addChild(tgThatAttachesTheSphere);
TransformGroup obj = new TransformGroup(); Scene s = null; ObjectFile f = new ObjectFile (); f.setFlags (ObjectFile.RESIZE | ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY); try{ s = f.load (obj_path+model+"\\"+model+".obj"); }catch(Exception ex) { ex.printStackTrace(); } obj.addChild(s.getSceneGroup()); obj.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
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++)
/** * Creates a pick/rotate behavior that waits for user mouse events for * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); rotate = new MouseRotate(MouseRotate.MANUAL_WAKEUP); rotate.setTransformGroup(currGrp); currGrp.addChild(rotate); rotate.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/translate behavior that waits for user mouse events for * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickTranslateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); translate = new MouseTranslate(MouseBehavior.MANUAL_WAKEUP); translate.setTransformGroup(currGrp); currGrp.addChild(translate); translate.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/rotate behavior that waits for user mouse events for * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); drag = new MouseRotate(MouseRotate.MANUAL_WAKEUP); drag.setTransformGroup(currGrp); currGrp.addChild(drag); drag.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/rotate behavior that waits for user mouse events for * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); drag = new MouseRotate(MouseRotate.MANUAL_WAKEUP); drag.setTransformGroup(currGrp); currGrp.addChild(drag); drag.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/zoom behavior that waits for user mouse events for * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); zoom = new MouseZoom(MouseBehavior.MANUAL_WAKEUP); zoom.setTransformGroup(currGrp); currGrp.addChild(zoom); zoom.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/zoom behavior that waits for user mouse events for * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); zoom = new MouseZoom(MouseBehavior.MANUAL_WAKEUP); zoom.setTransformGroup(currGrp); currGrp.addChild(zoom); zoom.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/translate behavior that waits for user mouse events for * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickTranslateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); translate = new MouseTranslate(MouseBehavior.MANUAL_WAKEUP); translate.setTransformGroup(currGrp); currGrp.addChild(translate); translate.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
/** * Creates a pick/translate behavior that waits for user mouse events for * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. **/ public PickTranslateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(canvas, root, bounds); translate = new MouseTranslate(MouseBehavior.MANUAL_WAKEUP); translate.setTransformGroup(currGrp); currGrp.addChild(translate); translate.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); }
PlatformGeometry pg = new PlatformGeometry(); TransformGroup objScale = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3f(0f, 0f, -1f)); objScale.setTransform(t3d); Text2D text = new Text2D("Text to display", Cell.BLACK, "Verdana", 18, 1); objScale.addChild(text); pg.addChild(objScale); simpleUniverse.getViewingPlatform().setPlatformGeometry(pg);
TransformGroup moveGroup = new TransformGroup(); Transform3D move = new Transform3D(); move.setTranslation(new Vector3f(0.0f, 0.0f, -10.0f)); //^^ set the Vector3f to where you want the object to be moveGroup.setTransform(move); moveGroup.addChild(YOUR_OBJECT);
TransformGroup getNewBox(float hpos) { Cuboid box = new Cuboid(0.03f, 0.03f, 0.03f, cubeAppearance); TransformGroup tg = new TransformGroup(); Transform3D transform = new Transform3D(); Vector3f vector = new Vector3f(0f, hposf, 0f); transform.setTranslation(vector); tg.addChild(box); tg.setTransform(transform); return tg; } { rootGroup.addChild(getNewBox(0f); rootGroup.addChild(getNewBox(0.3f); rootGroup.addChild(getNewBox(0.6f); rootGroup.addChild(getNewBox(0.9f); }