List of usage examples for javax.media.j3d Billboard ROTATE_ABOUT_AXIS
int ROTATE_ABOUT_AXIS
To view the source code for javax.media.j3d Billboard ROTATE_ABOUT_AXIS.
Click Source Link
From source file:BillboardTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator);/*from w w w . j a v a2 s. c om*/ objTrans.addChild(createBillboard("AXIS - 0,1,0", new Point3f(-40.0f, 40.0f, 0.0f), Billboard.ROTATE_ABOUT_AXIS, new Point3f(0.0f, 1.0f, 0.0f), bounds)); objTrans.addChild(createBillboard("POINT - 10,0,0", new Point3f(40.0f, 00.0f, 0.0f), Billboard.ROTATE_ABOUT_POINT, new Point3f(10.0f, 0.0f, 0.0f), bounds)); objTrans.addChild(new ColorCube(20.0)); objRoot.addChild(objTrans); return objRoot; }
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 w w w . j a v a2s .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; }