Example usage for javax.media.j3d WakeupOnElapsedTime WakeupOnElapsedTime

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

Introduction

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

Prototype

public WakeupOnElapsedTime(long milliseconds) 

Source Link

Document

Constructs a new WakeupOnElapsedTime criterion.

Usage

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  ww w  .j  a va  2  s .c  o  m
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:BehaviorTest.java

public WakeupCondition restart(Shape3D shape3D, int nElapsedTime, int nNumFrames, ExplosionListener listener) {
    System.out.println("Will explode after: " + nElapsedTime / 1000 + " secs.");

    m_Shape3D = shape3D;/*from   w  w w.  ja  va 2 s .c  o m*/
    m_nElapsedTime = nElapsedTime;
    m_nNumFrames = nNumFrames;
    m_nFrameNumber = 0;

    // create the WakeupCriterion for the behavior
    m_InitialWakeupCondition = new WakeupOnElapsedTime(m_nElapsedTime);

    m_Listener = listener;

    // save the GeometryArray that we are modifying
    m_GeometryArray = (GeometryArray) m_Shape3D.getGeometry();

    if (m_Shape3D.isLive() == false && m_Shape3D.isCompiled() == false) {
        // set the capability bits that the behavior requires
        m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
        m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);

        m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POINT_ATTRIBUTES_WRITE);
        m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
        m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
        m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TEXTURE_WRITE);

        m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
        m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
        m_GeometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ);
    }

    // make a copy of the object's original appearance
    m_Appearance = new Appearance();
    m_Appearance = (Appearance) m_Shape3D.getAppearance().cloneNodeComponent(true);

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

    // make a copy of the models original coordinates
    m_OriginalCoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];
    m_GeometryArray.getCoordinates(0, m_OriginalCoordinateArray);

    // start (or restart) the behavior
    setEnable(true);

    return m_InitialWakeupCondition;
}

From source file:KeyNavigateTest.java

public TextureAnimationBehavior(TextureAttributes texAttribs) {
    m_TextureAttributes = texAttribs;/*from w w w  .  j  ava2s. c  o m*/
    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);
}

From source file:KeyNavigateTest.java

public RandomWalkBehavior(TransformGroup tg, CollisionDetector detector) {
    m_TransformGroup = tg;//from w  w w  .j  av a  2s .co  m

    m_CollisionChecker = new CollisionChecker(tg, detector, false);

    m_Transform3D = new Transform3D();

    TargetVector3d = new Vector3d();
    CurrentVector3d = new Vector3d();

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

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