/** * 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/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/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.setFactor(1); translate.setTransformGroup(currGrp); currGrp.addChild(translate); translate.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. * @param pickMode specifys PickTool.BOUNDS, PickTool.GEOMETRY or * PickTool.GEOMETRY_INTERSECT_INFO. * @see PickTool#setMode */ public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode) { super(canvas, root, bounds); zoom = new MouseZoom(MouseBehavior.MANUAL_WAKEUP); zoom.setTransformGroup(currGrp); currGrp.addChild(zoom); zoom.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); this.setMode(pickMode); }
/** * Creates a pick/rotate 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. * @param pickMode specifys PickTool.BOUNDS, PickTool.GEOMETRY or * PickTool.GEOMETRY_INTERSECT_INFO. * @see PickTool#setMode **/ public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode){ super(canvas, root, bounds); drag = new MouseRotate(MouseRotate.MANUAL_WAKEUP); drag.setTransformGroup(currGrp); currGrp.addChild(drag); drag.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); this.setMode(pickMode); }
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); }
/** * Construit et initialise le groupe. */ public BGroupeVolume() { switch_ = new Switch(Switch.CHILD_MASK); switch_.setCapability(Group.ALLOW_CHILDREN_EXTEND); switch_.setCapability(Group.ALLOW_CHILDREN_READ); switch_.setCapability(Group.ALLOW_CHILDREN_WRITE); switch_.setCapability(Switch.ALLOW_SWITCH_WRITE); switch_.setCapability(Switch.ALLOW_SWITCH_READ); switch_.setCapability(ALLOW_DETACH); tg_.addChild(switch_); }
/** * 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. * @param pickMode specifys PickTool.BOUNDS, PickTool.GEOMETRY or * PickTool.GEOMETRY_INTERSECT_INFO. * @see PickTool#setMode **/ public PickTranslateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode) { super(canvas, root, bounds); translate = new MouseTranslate(MouseBehavior.MANUAL_WAKEUP); translate.setFactor(1); translate.setTransformGroup(currGrp); currGrp.addChild(translate); translate.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); this.setMode(pickMode); }
/** * Combines any number of shapes into one shape and returns it. */ public static Shape combine (Shape... shapes) { BranchGroup combinedGroup = createBranchGroup(); TransformGroup combinedTransform = new TransformGroup(); for (int i = 0; i < shapes.length; i++) { BranchGroup bg = shapes[i].bg; TransformGroup tg = shapes[i].tg; offscreenGroup.removeChild(bg); onscreenGroup.removeChild(bg); bg.removeChild(tg); combinedTransform.addChild(shapes[i].tg); } combinedGroup.addChild(combinedTransform); offscreenGroup.addChild(combinedGroup); return new Shape(combinedGroup, combinedTransform); }
private static Shape drawLWS (String filename) { Lw3dLoader loader = new Lw3dLoader(); try { BranchGroup bg = loader.load(filename).getSceneGroup(); bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ); bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); bg.setCapability(BranchGroup.ALLOW_DETACH); TransformGroup transGroup = new TransformGroup(); transGroup.addChild(bg); BranchGroup bg2 = createBranchGroup(); bg2.addChild(transGroup); offscreenGroup.addChild(bg2); return new Shape(bg2, transGroup); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } return null; }
/** * Combines any number of shapes into one shape and returns it. */ public static Shape combine (Shape... shapes) { BranchGroup combinedGroup = createBranchGroup(); TransformGroup combinedTransform = new TransformGroup(); for (int i = 0; i < shapes.length; i++) { BranchGroup bg = shapes[i].bg; TransformGroup tg = shapes[i].tg; offscreenGroup.removeChild(bg); onscreenGroup.removeChild(bg); bg.removeChild(tg); combinedTransform.addChild(shapes[i].tg); } combinedGroup.addChild(combinedTransform); offscreenGroup.addChild(combinedGroup); return new Shape(combinedGroup, combinedTransform); }
private static Shape drawLWS (String filename) { Lw3dLoader loader = new Lw3dLoader(); try { BranchGroup bg = loader.load(filename).getSceneGroup(); bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ); bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); bg.setCapability(BranchGroup.ALLOW_DETACH); TransformGroup transGroup = new TransformGroup(); transGroup.addChild(bg); BranchGroup bg2 = createBranchGroup(); bg2.addChild(transGroup); offscreenGroup.addChild(bg2); return new Shape(bg2, transGroup); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } return null; }
/** * 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); }
/** * 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); }
/** * Adds ambient light of color col. */ public static Light ambientLight (Color col) { Color3f lightColor = new Color3f(col); AmbientLight light = new AmbientLight(lightColor); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(AmbientLight.ALLOW_STATE_WRITE); light.setCapability(AmbientLight.ALLOW_COLOR_WRITE); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); return new Light(bg, tg, light); }
/** * Adds ambient light of color col. */ public static Light ambientLight (Color col) { Color3f lightColor = new Color3f(col); AmbientLight light = new AmbientLight(lightColor); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(AmbientLight.ALLOW_STATE_WRITE); light.setCapability(AmbientLight.ALLOW_COLOR_WRITE); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); return new Light(bg, tg, light); }
@Override public void setViewValue(Object o) { // value = o; if (!VGraphicsUtil.NO_3D) { if (shapeGroup != null) { shapeGroup.detach(); } Shape3D shape = (Shape3D) o; shapeGroup = new BranchGroup(); shapeGroup.setCapability(BranchGroup.ENABLE_PICK_REPORTING); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); shapeGroup.setCapability(BranchGroup.ALLOW_DETACH); shapeGroup.addChild(shape); universeCreator.getRootGroup().addChild(shapeGroup); getCanvas().postRenderTask(); } }
/** * Adds a directional light of color col which shines in the direction vector (x, y, z) */ public static Light directionalLight (double x, double y, double z, Color col) { DirectionalLight light = new DirectionalLight(); light.setColor(new Color3f(col)); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(DirectionalLight.ALLOW_STATE_WRITE); light.setCapability(DirectionalLight.ALLOW_COLOR_WRITE); light.setEnable(true); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); Light l = new Light(bg, tg, light); l.setDirection(new Vector3D(x, y, z)); return l; }
/** * Adds a directional light of color col which shines in the direction vector (x, y, z) */ public static Light directionalLight (double x, double y, double z, Color col) { DirectionalLight light = new DirectionalLight(); light.setColor(new Color3f(col)); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(DirectionalLight.ALLOW_STATE_WRITE); light.setCapability(DirectionalLight.ALLOW_COLOR_WRITE); light.setEnable(true); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); Light l = new Light(bg, tg, light); l.setDirection(new Vector3D(x, y, z)); return l; }
public static Light pointLight (double x, double y, double z, Color col, double power) { PointLight light = new PointLight(); light.setColor(new Color3f(col)); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(PointLight.ALLOW_STATE_WRITE); light.setCapability(PointLight.ALLOW_COLOR_WRITE); light.setCapability(PointLight.ALLOW_ATTENUATION_WRITE); float scale = (float)zoom; float linearFade = 0.03f; float quadraticFade = 0.03f; light.setAttenuation(1.0f, linearFade / scale, quadraticFade / (scale * scale)); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); Light l = new Light(bg, tg, light); l.setPosition(x, y, z); l.scalePower(power); return l; }