List of usage examples for javax.media.j3d Billboard setSchedulingBounds
public void setSchedulingBounds(Bounds region)
From source file:SimpleBillboard.java
/** * Build the content branch for the scene graph. This creates two cubes and * uses a billboard node to keep one face of one of the cubes facing the * viewer.//from ww w . j a v a 2 s.c o m * * @return BranchGroup that is the root of the content */ protected BranchGroup buildContentBranch() { //Create the appearance Appearance app = new Appearance(); Color3f ambientColour = new Color3f(1.0f, 1.0f, 0.0f); Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f); Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f); Color3f diffuseColour = new Color3f(1.0f, 1.0f, 0.0f); float shininess = 20.0f; app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess)); //Make the cubes Box leftCube = new Box(1.0f, 1.0f, 1.0f, app); ColorCube rightCube = new ColorCube(); //Create the transformgroup used for the billboard TransformGroup billBoardGroup = new TransformGroup(); //Set the access rights to the group billBoardGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); //Add the cube to the group billBoardGroup.addChild(rightCube); //Create and activate the billboard Billboard myBillboard = new Billboard(billBoardGroup, Billboard.ROTATE_ABOUT_AXIS, new Vector3f(0.0f, 1.0f, 0.0f)); myBillboard.setSchedulingBounds(bounds); BranchGroup contentBranch = new BranchGroup(); contentBranch.addChild(myBillboard); addLights(contentBranch); //Position the cubes TransformGroup bothGroup = new TransformGroup(); Transform3D leftGroupXfm = new Transform3D(); leftGroupXfm.set(new Vector3d(-1.5, 0.0, 0.0)); TransformGroup leftGroup = new TransformGroup(leftGroupXfm); Transform3D rightGroupXfm = new Transform3D(); rightGroupXfm.set(new Vector3d(1.5, 0.0, 0.0)); TransformGroup rightGroup = new TransformGroup(rightGroupXfm); //Put it all together bothGroup.addChild(leftGroup); leftGroup.addChild(leftCube); bothGroup.addChild(rightGroup); rightGroup.addChild(billBoardGroup); contentBranch.addChild(bothGroup); return contentBranch; }
From source file:BillboardTest.java
private TransformGroup createBillboard(String szText, Point3f locationPoint, int nMode, Point3f billboardPoint, BoundingSphere bounds) {// w w w . j ava2 s . c o m TransformGroup subTg = new TransformGroup(); subTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Font3D f3d = new Font3D(new Font("SansSerif", Font.PLAIN, 10), new FontExtrusion()); Text3D label3D = new Text3D(f3d, szText, locationPoint); Appearance app = new Appearance(); Color3f black = new Color3f(0.1f, 0.1f, 0.1f); Color3f objColor = new Color3f(0.2f, 0.2f, 0.2f); app.setMaterial(new Material(objColor, black, objColor, black, 90.0f)); Shape3D sh = new Shape3D(label3D, app); subTg.addChild(sh); Billboard billboard = new Billboard(subTg, nMode, billboardPoint); billboard.setSchedulingBounds(bounds); subTg.addChild(billboard); return subTg; }