Example usage for javax.media.j3d WakeupOnElapsedFrames WakeupOnElapsedFrames

List of usage examples for javax.media.j3d WakeupOnElapsedFrames WakeupOnElapsedFrames

Introduction

In this page you can find the example usage for javax.media.j3d WakeupOnElapsedFrames WakeupOnElapsedFrames.

Prototype

public WakeupOnElapsedFrames(int frameCount) 

Source Link

Document

Constructs a non-passive WakeupOnElapsedFrames criterion.

Usage

From source file:BehaviorTest.java

public FpsBehavior() {
    // save the WakeupCriterion for the behavior
    m_WakeupCondition = new WakeupOnElapsedFrames(m_knReportInterval);
}

From source file:NodesTest.java

public CollisionBehavior(BranchGroup pickRoot, TransformGroup collisionObject, Appearance app,
        Vector3d posVector, Vector3d incVector) {
    // save references to the objects
    this.pickRoot = pickRoot;
    this.collisionObject = collisionObject;
    this.objectAppearance = app;

    incrementVector = incVector;//  w  w  w  . jav  a2  s.  co m
    positionVector = posVector;

    // create the WakeupCriterion for the behavior
    WakeupCriterion criterionArray[] = new WakeupCriterion[1];
    criterionArray[0] = new WakeupOnElapsedFrames(ELAPSED_FRAME_COUNT);

    objectAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);

    collisionObject.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    collisionObject.setCapability(Node.ALLOW_BOUNDS_READ);

    // save the WakeupCriterion for the behavior
    m_WakeupCondition = new WakeupOr(criterionArray);
}

From source file:SimpleMorph2.java

/** Set up the criteria to trigger after zero time or when a key is pressed */
public void initialize() {
    wakeConditions = new WakeupCriterion[2];
    wakeConditions[0] = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
    wakeConditions[1] = new WakeupOnElapsedFrames(0);
    oredConditions = new WakeupOr(wakeConditions);
    wakeupOn(wakeConditions[0]);// www  .  j a  v a 2 s  .  c  o m
}

From source file:BehaviorTest.java

public BoundsBehavior(Node node) {
    // save the GeometryArray that we are modifying
    m_Node = node;//  w w w  .j  ava 2s  .  co m

    m_Transform3D = new Transform3D();
    m_Scale = new Vector3d();
    m_Vector3d = new Vector3d();
    m_Point3d1 = new Point3d();
    m_Point3d2 = new Point3d();

    // set the capability bits that the behavior requires
    m_Node.setCapability(Node.ALLOW_BOUNDS_READ);

    // save the WakeupCriterion for the behavior
    m_WakeupCondition = new WakeupOnElapsedFrames(10);
}

From source file:BehaviorTest.java

public ExplodeBehavior(Shape3D shape3D, int nElapsedTime, int nNumFrames, ExplosionListener listener) {
    // allocate a temporary vector
    m_Vector = new Vector3f();

    m_FrameWakeupCondition = new WakeupOnElapsedFrames(1);

    restart(shape3D, nElapsedTime, nNumFrames, listener);
}

From source file:TextureByReference.java

public AnimateTexturesBehavior(Texture2D texP, java.net.URL[] fnames, Appearance appP,
        TextureByReference applet) {/*  w w w  .jav a  2  s  .c o m*/
    int size = fnames.length;
    images = new ImageComponent2D[size];
    BufferedImage bImage;
    TextureLoader loader;
    for (int i = 0; i < size; i++) {
        loader = new TextureLoader(fnames[i], TextureLoader.BY_REFERENCE | TextureLoader.Y_UP, applet);
        images[i] = loader.getImage();
        bImage = images[i].getImage();

        // convert the image to TYPE_4BYTE_ABGR
        currentType = BufferedImage.TYPE_4BYTE_ABGR;
        bImage = ImageOps.convertImage(bImage, currentType);
        // flip the image
        flip = true;
        ImageOps.flipImage(bImage);

        // set the image on the ImageComponent to the new one
        images[i].set(bImage);

        images[i].setCapability(ImageComponent.ALLOW_IMAGE_READ);
        images[i].setCapability(ImageComponent.ALLOW_FORMAT_READ);
    }
    texture = texP;
    current = 0;
    max = size;
    wakeupC = new WakeupOnElapsedFrames(20);
    appearance = appP;
}

From source file:BehaviorTest.java

public ObjectSizeBehavior(GeometryArray geomArray) {
    // save the GeometryArray that we are modifying
    m_GeometryArray = geomArray;/*from  w  w  w .  jav a 2 s  . c  o m*/

    // set the capability bits that the behavior requires
    m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
    m_GeometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ);

    // allocate an array for the coordinates
    m_CoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];

    // create the BoundingBox used to
    // calculate the size of the object
    m_BoundingBox = new BoundingBox();

    // create a temporary point
    m_Point = new Point3d();

    // create the WakeupCriterion for the behavior
    WakeupCriterion criterionArray[] = new WakeupCriterion[1];
    criterionArray[0] = new WakeupOnElapsedFrames(20);

    // save the WakeupCriterion for the behavior
    m_WakeupCondition = new WakeupOr(criterionArray);
}

From source file:TextureByReference.java

public void setFrameDelay(int delay) {
    wakeupC = new WakeupOnElapsedFrames(delay);
}

From source file:BehaviorTest.java

public StretchBehavior(GeometryArray geomArray) {
    // save the GeometryArray that we are modifying
    m_GeometryArray = geomArray;/*from  w w w  .jav  a 2  s.c  o  m*/

    // set the capability bits that the behavior requires
    m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
    m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
    m_GeometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ);

    // allocate an array for the model coordinates
    m_CoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];

    // retrieve the models original coordinates - this defines
    // the relaxed length of the springs
    m_GeometryArray.getCoordinates(0, m_CoordinateArray);

    // allocate an array to store the relaxed length
    // of the springs from the origin to every vertex
    m_LengthArray = new float[m_GeometryArray.getVertexCount()];

    // allocate an array to store the mass of every vertex
    m_MassArray = new float[m_GeometryArray.getVertexCount()];

    // allocate an array to store the acceleration of every vertex
    m_AccelerationArray = new float[m_GeometryArray.getVertexCount()];

    // allocate a temporary vector
    m_Vector = new Vector3f();

    float x = 0;
    float y = 0;
    float z = 0;

    for (int n = 0; n < m_CoordinateArray.length; n += 3) {
        // calculate and store the relaxed spring length
        x = m_CoordinateArray[n];
        y = m_CoordinateArray[n + 1];
        z = m_CoordinateArray[n + 2];

        m_LengthArray[n / 3] = (x * x) + (y * y) + (z * z);

        // assign the mass for the vertex
        m_MassArray[n / 3] = (float) (50 + (5 * Math.random()));
    }

    // create the WakeupCriterion for the behavior
    WakeupCriterion criterionArray[] = new WakeupCriterion[2];
    criterionArray[0] = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
    criterionArray[1] = new WakeupOnElapsedFrames(1);

    // save the WakeupCriterion for the behavior
    m_WakeupCondition = new WakeupOr(criterionArray);
}

From source file:ExText.java

/**
 * Initializes the behavior./*from   w  w  w  . j a v a 2 s  .  c om*/
 */
public void initialize() {
    super.initialize();
    savedMouseCriterion = mouseCriterion; // from parent class
    mouseAndAnimationEvents = new WakeupCriterion[4];
    mouseAndAnimationEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
    mouseAndAnimationEvents[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
    mouseAndAnimationEvents[2] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
    mouseAndAnimationEvents[3] = new WakeupOnElapsedFrames(0);
    mouseAndAnimationCriterion = new WakeupOr(mouseAndAnimationEvents);
    // Don't use the above criterion until a button 1 down event
}