List of usage examples for javax.media.j3d Alpha Alpha
public Alpha(int loopCount, long triggerTime, long phaseDelayDuration, long increasingAlphaDuration, long increasingAlphaRampDuration, long alphaAtOneDuration)
From source file:SimpleGame.java
/** * Creates the duck. This loads the two duck geometries from the files * 'duck.obj' and 'deadduck.obj' and loads these into a switch. The access * rights to the switch are then set so we can write to this switch to swap * between the two duck models. It also creates a transform group and an * interpolator to move the duck./*from www .ja va 2 s.c o m*/ * * @return BranchGroup with content attached. */ protected BranchGroup buildDuck() { BranchGroup theDuck = new BranchGroup(); duckSwitch = new Switch(0); duckSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); ObjectFile f1 = new ObjectFile(); ObjectFile f2 = new ObjectFile(); Scene s1 = null; Scene s2 = null; try { s1 = f1.load("duck.obj"); s2 = f2.load("deadduck.obj"); } catch (Exception e) { System.exit(1); } TransformGroup duckRotXfmGrp = new TransformGroup(); Transform3D duckRotXfm = new Transform3D(); Matrix3d duckRotMat = new Matrix3d(); duckRotMat.rotY(Math.PI / 2); duckRotXfm.set(duckRotMat, new Vector3d(0.0, 0.0, -30.0), 1.0); duckRotXfmGrp.setTransform(duckRotXfm); duckRotXfmGrp.addChild(duckSwitch); duckSwitch.addChild(s1.getSceneGroup()); duckSwitch.addChild(s2.getSceneGroup()); TransformGroup duckMovXfmGrp = new TransformGroup(); duckMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); duckMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); duckMovXfmGrp.addChild(duckRotXfmGrp); duckAlpha = new Alpha(-1, 0, 0, 3000, 0, 0); Transform3D axis = new Transform3D(); PositionInterpolator moveDuck = new PositionInterpolator(duckAlpha, duckMovXfmGrp, axis, -30.0f, 30.0f); moveDuck.setSchedulingBounds(bounds); theDuck.addChild(moveDuck); theDuck.addChild(duckMovXfmGrp); return theDuck; }
From source file:SimpleGame.java
/** * This builds the ball that acts as the bullet for our gun. The ball is * created from a sphere primitive, and a transform group and interpolator * are added so that we can 'fire' the bullet. * //from w ww . j a v a2s .c o m * @return BranchGroup that is the root of the ball branch. */ protected BranchGroup buildBall() { BranchGroup theBall = new BranchGroup(); Appearance ballApp = new Appearance(); Color3f ambientColour = new Color3f(1.0f, 0.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, 0.0f, 0.0f); float shininess = 20.0f; ballApp.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess)); Sphere ball = new Sphere(0.2f, ballApp); TransformGroup ballMovXfmGrp = new TransformGroup(); ballMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); ballMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); ballMovXfmGrp.addChild(ball); theBall.addChild(ballMovXfmGrp); ballAlpha = new Alpha(1, 0, 0, 500, 0, 0); Transform3D axis = new Transform3D(); axis.rotY(Math.PI / 2); moveBall = new PositionInterpolator(ballAlpha, ballMovXfmGrp, axis, 0.0f, 50.0f); moveBall.setSchedulingBounds(bounds); theBall.addChild(moveBall); return theBall; }