Package javax.media.j3d

Examples of javax.media.j3d.Alpha


            pos++;
        }
       
        setUserData(entity);

        alpha = new Alpha(1, 500*movePath.size());
        KBRotPosScaleSplinePathInterpolator interpolator1 =
            new KBRotPosScaleSplinePathInterpolator(alpha, facing, new Transform3D(), keyframes1) {
                @Override
                public void computeTransform(float alphaValue, Transform3D transform) {
                    super.computeTransform(alphaValue, transform);
View Full Code Here


    TransformGroup tgmCyl = new TransformGroup();
    tgmCyl.addChild(tgCylinder);

    //The movement from left to right.
    Transform3D escape = new Transform3D();
    Alpha cylAlphaR = new Alpha(1,2000);

    //The starting time is first postponed until "infinity".
    cylAlphaR.setStartTime(Long.MAX_VALUE);

    //The interpolator for the movement.
    float maxRight = 0.5f;
    PositionInterpolator cylMoveR = new PositionInterpolator(cylAlphaR,tgmCyl,
                                                             escape,0.0f,maxRight);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    cylMoveR.setSchedulingBounds(bounds);


    //The same for the movement from right to left.
    Alpha cylAlphaL = new Alpha(1,2000);
    cylAlphaL.setStartTime(Long.MAX_VALUE);

    PositionInterpolator cylMoveL = new PositionInterpolator(cylAlphaL,tgmCyl,
                                                             escape,maxRight,0.0f);

    cylMoveL.setSchedulingBounds(bounds);
View Full Code Here

    Transform3D rotationAxis = new Transform3D();


    //The following lines define what the cube should do when picked.
    Alpha boxAlpha = new Alpha(1,2000);

    //The starting time is first postponed until "infinity".
    boxAlpha.setStartTime(Long.MAX_VALUE);

    RotationInterpolator boxRotation = new RotationInterpolator(boxAlpha,tgmBox,
                                             rotationAxis,0.0f,(float) Math.PI*2);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    boxRotation.setSchedulingBounds(bounds);

    //The movement is added to the transformation group.
    tgmBox.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmBox.addChild(boxRotation);


    //A transformation group for positioning the cube.
    Transform3D tfFBox = new Transform3D();
    tfFBox.rotY(Math.PI/6);
    Transform3D rotationX = new Transform3D();
    rotationX.rotX(-Math.PI/5);
    tfFBox.mul(rotationX);
    TransformGroup tgFBox = new TransformGroup(tfFBox);
    tgFBox.addChild(tgmBox);


//*** The same for the sphere.
    Color3f ambientColourBSphere = new Color3f(0.0f,0.6f,0.0f);
    Color3f emissiveColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourBSphere = new Color3f(0.0f,0.6f,0.0f);
    Color3f specularColourBSphere = new Color3f(0.0f,0.6f,0.0f);
    float shininessBSphere = 2.0f;

    Appearance bSphereApp = new Appearance();

    bSphereApp.setMaterial(new Material(ambientColourBSphere,
                                        emissiveColourBSphere,
                                        diffuseColourBSphere,
                                        specularColourBSphere,
                                        shininessBSphere));

    Sphere bSphere = new Sphere(0.4f,bSphereApp);

    //The UserData are needed in order to identify the sphere when it is picked.
    bSphere.setUserData("sphere");

    TransformGroup tgmBSphere = new TransformGroup();
    tgmBSphere.addChild(bSphere);


    //Two transformations must be defined for the sphere: One for
    //shrinking, one for growing. First the shrinking transformation
    //is defined.
    Alpha sphereShrinkAlpha = new Alpha(1,2000);

    //The starting time is first postponed until "infinity".
    sphereShrinkAlpha.setStartTime(Long.MAX_VALUE);

    ScaleInterpolator shrinker = new ScaleInterpolator(sphereShrinkAlpha,
                                                       tgmBSphere,
                                                       new Transform3D(),
                                                       1.0f,0.5f);

    shrinker.setSchedulingBounds(bounds);

    tgmBSphere.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmBSphere.addChild(shrinker);


    //The same for the growing sphere.
    Alpha sphereStretchAlpha = new Alpha(1,2000);
    sphereStretchAlpha.setStartTime(Long.MAX_VALUE);

    ScaleInterpolator stretcher = new ScaleInterpolator(sphereStretchAlpha,
                                                       tgmBSphere,
                                                       new Transform3D(),
                                                       0.5f,1.0f);
View Full Code Here

    //The transformation group for the directional light including the rotation.
    TransformGroup tfmLight = new TransformGroup();
    tfmLight.addChild(light);

    //The Alpha for the rotation.
    Alpha alphaLight = new Alpha(-1,4000);
    //The rotation.
    RotationInterpolator rot = new RotationInterpolator(alphaLight,tfmLight,
                                                        new Transform3D(),
                                                         0.0f,(float) Math.PI*2);
    rot.setSchedulingBounds(bounds);
View Full Code Here

    tgmBox.addChild(fBox);

    //Define the rotation.
    Transform3D rotationAxis = new Transform3D();

    Alpha boxAlpha = new Alpha(1,2000);

    //Set the starting time of the rotation to infinity.
    boxAlpha.setStartTime(Long.MAX_VALUE);

    RotationInterpolator boxRotation = new RotationInterpolator(boxAlpha,tgmBox,
                                             rotationAxis,0.0f,(float) Math.PI*2);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);
    boxRotation.setSchedulingBounds(bounds);

    //Add the rotation to the corresponding transform group.
    tgmBox.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmBox.addChild(boxRotation);


    //Create a transformgroup for the positioning of the box and add the
    //transformgroup with the rotation.
    Transform3D tfFBox = new Transform3D();
    tfFBox.rotY(Math.PI/6);
    Transform3D rotationX = new Transform3D();
    rotationX.rotX(-Math.PI/5);
    tfFBox.mul(rotationX);
    TransformGroup tgFBox = new TransformGroup(tfFBox);

    tgFBox.addChild(tgmBox);


    //The same for the sphere:
    Color3f ambientColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f emissiveColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourBSphere = new Color3f(0.0f,0.5f,0.0f);
    Color3f specularColourBSphere = new Color3f(0.0f,0.8f,0.0f);
    float shininessBSphere = 128.0f;

    Appearance bSphereApp = new Appearance();

    bSphereApp.setMaterial(new Material(ambientColourBSphere,
                                        emissiveColourBSphere,
                                        diffuseColourBSphere,
                                        specularColourBSphere,
                                        shininessBSphere));

    Sphere bSphere = new Sphere(0.4f,bSphereApp);

    bSphere.setUserData("sphere");

    TransformGroup tgmBSphere = new TransformGroup();
    tgmBSphere.addChild(bSphere);


    //Create the transformation for shrinking.
    Alpha sphereShrinkAlpha = new Alpha(1,2000);
    sphereShrinkAlpha.setStartTime(Long.MAX_VALUE);

    ScaleInterpolator shrinker = new ScaleInterpolator(sphereShrinkAlpha,
                                                       tgmBSphere,
                                                       new Transform3D(),
                                                       1.0f,0.5f);

    shrinker.setSchedulingBounds(bounds);



    tgmBSphere.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmBSphere.addChild(shrinker);


    //Create the transformation for stretching the sphere again.
    Alpha sphereStretchAlpha = new Alpha(1,2000);
    sphereStretchAlpha.setStartTime(Long.MAX_VALUE);

    ScaleInterpolator stretcher = new ScaleInterpolator(sphereStretchAlpha,
                                                       tgmBSphere,
                                                       new Transform3D(),
                                                       0.5f,1.0f);
View Full Code Here

    //The transformation group for the spotlight and its rotation.
    TransformGroup tfmLight = new TransformGroup();
    tfmLight.addChild(lightSpot);

    //The Alpha for the rotation.
    Alpha alphaLight = new Alpha(-1,4000);
    //The rotation
    RotationInterpolator rot = new RotationInterpolator(alphaLight,tfmLight,
                                                        new Transform3D(),
                                                         0.0f,(float) Math.PI*2);
    rot.setSchedulingBounds(bounds);
View Full Code Here

    tgmBird.addChild(body);


    //The bird's flight.
    long flightTime = 10000;
    Alpha flightAlpha = new Alpha(-1,Alpha.INCREASING_ENABLE+Alpha.DECREASING_ENABLE,
                                  0,0,flightTime,0,0,flightTime,0,0);

    float flightDistance = 9.0f;
    PositionInterpolator posIFlight = new PositionInterpolator(flightAlpha,
                                                   tgmBird,new Transform3D(),
View Full Code Here

    //The transformation group for the directional light and its rotation.
    TransformGroup tfmLight = new TransformGroup();
    tfmLight.addChild(light);

    //The Alpha for the rotation.
    Alpha alphaLight = new Alpha(-1,4000);
    //The rotation
    RotationInterpolator rot = new RotationInterpolator(alphaLight,tfmLight,
                                                        new Transform3D(),
                                                         0.0f,(float) Math.PI*2);
    rot.setSchedulingBounds(bounds);
View Full Code Here

    int timeStartRotor = 2000; //The rotor blade should start to turn after 2 seconds.
    int noStartRotations = 2//First, two slow rotations are carried out.
    int timeSlowRotation = 1500;//A slow rotation takes 1.5 seconds.

    //The Alpha for the slow rotation.
    Alpha bladeRotationStartAlpha = new Alpha(noStartRotations,
                                              Alpha.INCREASING_ENABLE,
                                              timeStartRotor,
                                              0,timeSlowRotation,0,0,0,0,0);



    //The slow rotation.
    RotationInterpolator bladeRotationStart = new RotationInterpolator(
                                             bladeRotationStartAlpha,tgmRotor,
                                             bladeRotationAxis,0.0f,(float) Math.PI*2);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    bladeRotationStart.setSchedulingBounds(bounds);



    int timeFastRotation = 500; //A fast rotation takes 0.5 seconds.
    int timeOneWayFlight = 2000;//The helicopter rises within 2 seconds.
    int timeHovering = 1000;//It shall hover for one second.
    int timeStartWait = 1000;//The helicopter should start its flight when the rotor
                             //blade has been rotating fast for one second.

    //The overall time when the helicopter should start its flight.
    int timeFlightStart = timeStartRotor+timeSlowRotation*noStartRotations+timeStartWait;
    //Number of fast rotations.
    int noFastRotations = 1+ ((timeStartWait+2*timeOneWayFlight+timeHovering)/timeFastRotation);

    //The Alpha for the fast rotations.
    Alpha bladeRotationAlpha = new Alpha(noFastRotations,Alpha.INCREASING_ENABLE,
                                         timeStartRotor+timeSlowRotation*noStartRotations,
                                         0,timeFastRotation,0,0,0,0,0);


    //The fast rotation.
    RotationInterpolator bladeRotation = new RotationInterpolator(
                                             bladeRotationAlpha,tgmRotor,
                                             bladeRotationAxis,0.0f,(float) Math.PI*2);
    bladeRotation.setSchedulingBounds(bounds);


    //The slow and the fast rotation are assigned to the transformation group
    //of the rotor blade. These rotations are carried out in the origin so far.
    //The later transformations will place everything correctly.
    tgmRotor.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmRotor.addChild(bladeRotationStart);
    tgmRotor.addChild(bladeRotation);


//*** The transformation group to position the rotor blade on top of the cockpit. ***
    //The rotation of the rotor blade will therefore also take place om top
    //of the cockpit.
    Transform3D tfRotor = new Transform3D();
    tfRotor.setTranslation(new Vector3f(0.0f,cabinRadius,0.0f));
    TransformGroup tgRotor = new TransformGroup(tfRotor);
    tgRotor.addChild(tgmRotor);



//*** The tail of the helicopter. ***

    //Length of the tail.
    float halfTailLength = 0.2f;

    //Generate the tail in form of a green box.
    Box tail = new Box(halfTailLength,0.02f,0.02f,greenApp);

    //A transformation placing the tail at the end of the cockpit.
    Transform3D tfTail = new Transform3D();
    tfTail.setTranslation(new Vector3f(cabinRadius+halfTailLength,0.0f,0.0f));

    //The transformation group for the tail.
    TransformGroup tgTail = new TransformGroup(tfTail);
    tgTail.addChild(tail);



//*** The transformation group for the flight of the helicopter. ***
    //The flight is carried out with respect to the origin. Later on, the helicopter
    //including its movement will be placed onto the platform.
    TransformGroup tgmHelicopter = new TransformGroup();

    //Add all parts of the helicopter.
    tgmHelicopter.addChild(tgCabin);
    tgmHelicopter.addChild(tgRotor);
    tgmHelicopter.addChild(tgTail);

    //Define the movement for the flight.
    int timeAcc = 300; //The acceleration and breaking phase should last 0.3 seconds.
    //The helicopter fly slightly of from the vertical axis.
    Transform3D helicopterFlightAxis = new Transform3D();
    helicopterFlightAxis.rotZ(0.4*Math.PI);

    //The Alpha for the flight of the helicopter.
    Alpha helicopterAlpha = new Alpha(1,Alpha.INCREASING_ENABLE+Alpha.DECREASING_ENABLE,
                                      timeFlightStart,0,timeOneWayFlight,timeAcc,
                                      timeHovering,timeOneWayFlight,timeAcc,0);



View Full Code Here

        float[] knots = new float[] { 0, 1 };
        Point3f position1 = new Point3f(translationVector.getX(), translationVector.getY(), translationVector.getZ());
        Point3f position2 = ProjectionHelper.getProjectionPoint(position1);
        Point3f[] positions = new Point3f[] { position1, position2 };
        Quat4f[] rotations = new Quat4f[] { rotationQuat, rotationQuat };
        Alpha alpha = new Alpha(1, (long) (translationVector.getY() * 1000));
        alpha.setStartTime(System.currentTimeMillis());
        RotPosPathInterpolator gravity = new RotPosPathInterpolator(alpha, newTransformGroup, new Transform3D(), knots,
                rotations, positions);
        gravity.setSchedulingBounds(new BoundingSphere());
        return gravity;
    }
View Full Code Here

TOP

Related Classes of javax.media.j3d.Alpha

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.