/** * Translates a given transform group. * @param tGroup the transform group to translate * @param transVec the vector that describes the translation */ public static void translate(TransformGroup tGroup, Vector3d transVec) { Transform3D t3d = new Transform3D(); tGroup.getTransform(t3d); translate(t3d, transVec); tGroup.setTransform(t3d); }
public EdgeGroup(E edge, Node shape) { this.edge = edge; this.shape = shape; setCapability(TransformGroup.ENABLE_PICK_REPORTING); // Cylinder cylinder = new Cylinder(radius, 1, // Cylinder.GENERATE_NORMALS | // Cylinder.GENERATE_TEXTURE_COORDS | // Cylinder.ENABLE_GEOMETRY_PICKING, // 26, 26, look); Transform3D t = new Transform3D(); t.setTranslation(new Vector3f(0.f, .5f, 0.f)); TransformGroup group = new TransformGroup(t); group.addChild(shape); addChild(group); }
/** * Creates a blank TransformGroup with the proper capabilities. */ private static TransformGroup createTransformGroup () { TransformGroup tg = new TransformGroup(); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg.setPickable(false); tg.setCollidable(false); return tg; }
/** * Creates a PickMouseBehavior given current canvas, root of the tree to * operate on, and the bounds. */ public PickMouseBehavior(Canvas3D canvas, BranchGroup root, Bounds bounds){ super(); currGrp = new TransformGroup(); currGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); currGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); root.addChild(currGrp); pickCanvas = new PickCanvas(canvas, root); }
/** * Draws a Java3D Shape3D object with the given properties. * * @param polygonFill Polygon fill properties, specified by Java 3D. */ private static Shape shape (Shape3D shape, boolean fill, Transform3D transform, boolean custom) { Appearance ap; if (custom) ap = createCustomAppearance(fill); else ap = createAppearance(null, fill); shape.setAppearance(ap); TransformGroup transGroup = new TransformGroup(); if (transform != null) transGroup.setTransform(transform); transGroup.addChild(shape); BranchGroup bg = createBranchGroup(); bg.addChild(transGroup); offscreenGroup.addChild(bg); return new Shape(bg, transGroup); }
private Transform3D getTransform () { Transform3D t = new Transform3D(); tg.getTransform(t); return t; }
/** * 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); }
objRoot.setCapability(Group.ALLOW_CHILDREN_WRITE); TransformGroup objScale = new TransformGroup(); Transform3D t3d = new Transform3D(); objScale.setTransform(t3d); objRoot.addChild(objScale); tt.setScale(.05); tt.setTranslation(new Vector3f(0, 0, -30.f)); objTrans = new TransformGroup(tt); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ ); objTrans.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND); objScale.addChild(objTrans); objTrans.addChild(behavior1); behavior1.setSchedulingBounds(bounds); objTrans.addChild(behavior2); behavior2.setSchedulingBounds(bounds); objTrans.addChild(behavior3); behavior3.setSchedulingBounds(bounds); objTrans.addChild(pvb); pvb.addChangeListener(new ChangeListener() {
public void setVue(final int _vue) { if (vues_[_vue] != null) { transformU_.setTransform(vues_[_vue]); vue_ = _vue; } }
public BUnivers(final BCanvas3D _canvas) { canvas_ = _canvas; locale_ = new Locale(this); final ViewPlatform camera = new ViewPlatform(); final BranchGroup viewGroup = new BranchGroup(); final TransformGroup viewTg = new TransformGroup(); viewTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); viewTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); viewTg.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ); viewTg.addChild(camera); viewGroup.addChild(viewTg); final PhysicalBody body = new PhysicalBody(); final PhysicalEnvironment env = new PhysicalEnvironment(); final View view = new View(); view.setPhysicalBody(body); view.setPhysicalEnvironment(env); view.setBackClipDistance(100); view.setFrontClipDistance(.1); view.addCanvas3D(canvas_); view.attachViewPlatform(camera); transformU_ = viewTg; position_ = new Vector3d(); viewGroup.setCapability(BranchGroup.ALLOW_DETACH); locale_.addBranchGraph(viewGroup); }
cameraTG.getTransform(cameraTrans); cameraTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); cameraTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); camera = new Camera(cameraTG); universe.addBranchGraph(viewingPlatform);
transformGroup.getTransform(currXform); transformGroup.getLocalToVworld(ltvw); transformGroup.setTransform(currXform);
/** * Draws a Java 3D Primitive object at (x, y, z) with axial rotations (xA, yA, zA). */ private static Shape primitive (Primitive shape, double x, double y, double z, Vector3d angles, Vector3d scales) { shape.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY); shape.setPickable(false); shape.setCollidable(false); TransformGroup tgScale = createTransformGroup(); Transform3D scaleTransform = new Transform3D(); if (scales != null) scaleTransform.setScale(scales); tgScale.setTransform(scaleTransform); tgScale.addChild(shape); TransformGroup tgShape = createTransformGroup(); Transform3D transform = new Transform3D(); if (angles != null) { angles.scale(Math.PI / 180); transform.setEuler( angles); } Vector3f vector = createVector3f(x, y, z); transform.setTranslation(vector); tgShape.setTransform(transform); tgShape.addChild(tgScale); BranchGroup bg = createBranchGroup(); bg.addChild(tgShape); offscreenGroup.addChild(bg); return new Shape(bg, tgShape); }
/** * Returns the global coordinates of a given transform group. * @param tGroup the transform group * @return the global coordinates of the given transform group */ public static Point3d getGlobalCoordinates(TransformGroup tGroup) { Transform3D globalT3d = new Transform3D(); Transform3D t3d = new Transform3D(); tGroup.getLocalToVworld(globalT3d); tGroup.getTransform(t3d); return getGlobalCoordinates(t3d, globalT3d); }
rootGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); rootGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); rootGroup.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE); rootGroup.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND); rootGroup.setCapability(BranchGroup.ALLOW_DETACH); Transform3D camTranslate = new Transform3D(); camTranslate.set(new Vector3f(0.0f, 0.0f, 20.0f)); camGroup.setTransform(camTranslate);
private Shape (BranchGroup bg, TransformGroup tg) { super(tg); this.bg = bg; this.tg = tg; tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); }
/** * Returns an identical copy of a Shape that can be controlled independently. * Much more efficient than redrawing a specific shape or model. */ public static Shape copy (Shape shape) { TransformGroup tg = shape.tg; BranchGroup bg = shape.bg; TransformGroup tg2 = (TransformGroup)tg.cloneTree(); BranchGroup bg2 = createBranchGroup(); bg2.addChild(tg2); offscreenGroup.addChild(bg2); return new Shape(bg2, tg2); }
/** * Draws a Java3D Shape3D object with the given properties. * * @param polygonFill Polygon fill properties, specified by Java 3D. */ private static Shape shape (Shape3D shape, boolean fill, Transform3D transform, boolean custom) { Appearance ap; if (custom) ap = createCustomAppearance(fill); else ap = createAppearance(null, fill); shape.setAppearance(ap); TransformGroup transGroup = new TransformGroup(); if (transform != null) transGroup.setTransform(transform); transGroup.addChild(shape); BranchGroup bg = createBranchGroup(); bg.addChild(transGroup); offscreenGroup.addChild(bg); return new Shape(bg, transGroup); }
private Transform3D getTransform () { Transform3D t = new Transform3D(); tg.getTransform(t); return t; }
/** * 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); }