Example usage for javax.media.j3d WakeupOr WakeupOr

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

Introduction

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

Prototype

public WakeupOr(WakeupCriterion conditions[]) 

Source Link

Document

Constructs a new WakeupOr criterion.

Usage

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]);//from  w w  w . j a v a  2  s  .c om
}

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;/*from w  w w .  j  a v a  2 s . c o 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:SimpleCollision.java

/**
 * This creates an entry, exit and movement collision criteria. These are
 * then OR'ed together, and the wake up condition set to the result.
 *//*www  .  j a  v  a2 s . c om*/
public void initialize() {
    theCriteria = new WakeupCriterion[3];
    theCriteria[0] = new WakeupOnCollisionEntry(collidingShape);
    theCriteria[1] = new WakeupOnCollisionExit(collidingShape);
    theCriteria[2] = new WakeupOnCollisionMovement(collidingShape);
    oredCriteria = new WakeupOr(theCriteria);
    wakeupOn(oredCriteria);
}

From source file:SimpleCollision2.java

/**
 * This sets up the criteria for triggering the behaviour. It creates an
 * entry, exit and movement trigger, OR's these together and then sets the
 * OR'ed criterion as the wake up condition.
 *//* ww  w . ja va 2 s.c  o  m*/
public void initialize() {
    theCriteria = new WakeupCriterion[3];
    WakeupOnCollisionEntry startsCollision = new WakeupOnCollisionEntry(collidingShape);
    WakeupOnCollisionExit endsCollision = new WakeupOnCollisionExit(collidingShape);
    WakeupOnCollisionMovement moveCollision = new WakeupOnCollisionMovement(collidingShape);
    theCriteria[0] = startsCollision;
    theCriteria[1] = endsCollision;
    theCriteria[2] = moveCollision;
    oredCriteria = new WakeupOr(theCriteria);
    wakeupOn(oredCriteria);
}

From source file:AvatarTest.java

public CollisionBehavior(Node node, ComplexObject owner) {
    wakeupOne = new WakeupOnCollisionEntry(node, WakeupOnCollisionEntry.USE_BOUNDS);
    wakeupTwo = new WakeupOnCollisionExit(node, WakeupOnCollisionExit.USE_BOUNDS);

    wakeupArray[0] = wakeupOne;/*from   w w  w. j a v  a 2  s.c  o  m*/
    wakeupArray[1] = wakeupTwo;

    wakeupCondition = new WakeupOr(wakeupArray);

    m_Owner = owner;
}

From source file:SimpleGame.java

/**
 * This sets up the criteria for triggering the behaviour. It creates an
 * collision crtiterion and a time elapsed criterion, OR's these together
 * and then sets the OR'ed criterion as the wake up condition.
 *//*from w  w  w.  ja  va  2 s  .c om*/
public void initialize() {
    theCriteria = new WakeupCriterion[2];
    theCriteria[0] = new WakeupOnCollisionEntry(collidingShape);
    theCriteria[1] = new WakeupOnElapsedTime(1);
    oredCriteria = new WakeupOr(theCriteria);
    wakeupOn(oredCriteria);
}

From source file:AvatarTest.java

public CarSteering(TransformGroup tg) {
    m_TransformGroup = tg;/*from  w  w w  .j a  v  a  2 s .  c o m*/

    try {
        m_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        m_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    } catch (Exception e) {
    }

    wakeupOne = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
    wakeupArray[0] = wakeupOne;
    wakeupCondition = new WakeupOr(wakeupArray);
}

From source file:BehaviorTest.java

public ObjectSizeBehavior(GeometryArray geomArray) {
    // save the GeometryArray that we are modifying
    m_GeometryArray = geomArray;/*w w  w .  ja  v  a 2s .  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:BehaviorTest.java

public StretchBehavior(GeometryArray geomArray) {
    // save the GeometryArray that we are modifying
    m_GeometryArray = geomArray;// w w  w.j a v  a2s.com

    // 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:KeyNavigateTest.java

public TextureAnimationBehavior(TextureAttributes texAttribs) {
    m_TextureAttributes = texAttribs;/* w ww . ja va 2 s.c om*/
    m_Transform3D = new Transform3D();
    m_TextureAttributes.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE);

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

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