Example usage for javax.media.j3d WakeupOnAWTEvent getAWTEvent

List of usage examples for javax.media.j3d WakeupOnAWTEvent getAWTEvent

Introduction

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

Prototype

public AWTEvent[] getAWTEvent() 

Source Link

Document

Retrieves the array of consecutive AWT event that triggered this wakeup.

Usage

From source file:Text2DTest.java

/**
 * Override Behavior's stimulus method to handle the event.
 *///from  www.j a va2s  .co  m
public void processStimulus(Enumeration criteria) {
    WakeupOnAWTEvent ev;
    WakeupCriterion genericEvt;
    AWTEvent[] events;

    while (criteria.hasMoreElements()) {
        genericEvt = (WakeupCriterion) criteria.nextElement();
        if (genericEvt instanceof WakeupOnAWTEvent) {
            ev = (WakeupOnAWTEvent) genericEvt;
            events = ev.getAWTEvent();
            processManualEvent(events);
        }
    }
    // Set wakeup criteria for next time
    wakeupOn(w);
}

From source file:AvatarTest.java

/**
 * Override Behavior's stimulus method to handle the event.
 *///from w ww.  j a  v a2s .  c o  m
public void processStimulus(Enumeration criteria) {
    WakeupOnAWTEvent ev;
    WakeupCriterion genericEvt;
    AWTEvent[] events;

    while (criteria.hasMoreElements()) {
        genericEvt = (WakeupCriterion) criteria.nextElement();

        if (genericEvt instanceof WakeupOnAWTEvent) {
            ev = (WakeupOnAWTEvent) genericEvt;
            events = ev.getAWTEvent();
            processAWTEvent(events);
        }
    }

    // Set wakeup criteria for next time
    wakeupOn(wakeupCondition);
}

From source file:Demo3D.java

/**
 * Override Behavior's stimulus method to handle the event. This method is
 * called when a key on the keyboard has been pressed and operates on the
 * specified transform group to move the camera.
 * /*from  www .ja  v a2  s.c  o m*/
 * @param Enumeration
 *            criteria - all pressed keys in a list. This will be passed by
 *            the system.
 */
public void processStimulus(Enumeration criteria) {
    WakeupOnAWTEvent eventToWakeUp;
    AWTEvent[] events;

    if (criteria.hasMoreElements()) {
        // Decode the wakeup criteria
        eventToWakeUp = (WakeupOnAWTEvent) criteria.nextElement();
        events = eventToWakeUp.getAWTEvent();
        keyEvent = (KeyEvent) events[0];
        int keyCode = keyEvent.getKeyCode();

        // Perform our processing
        switch (keyCode) {
        case KeyEvent.VK_A:
            if (validation) {
                sceneBuilder3.addEarth();
                System.out.println("===>    Add Earth");
                validation = false;
            }
            break;

        case KeyEvent.VK_D:
            if (!validation) {
                sceneBuilder32.detachEarth();
                System.out.println("===>    Detach Earth");
                validation = true;
            }
            break;

        default:
        }
    }

    // Set wakeup criteria for next time.
    wakeupOn(wakeUp);
}

From source file:Demo3D.java

/**
 * Override Behavior's stimulus method to handle the event. This method is
 * called when a key on the keyboard has been pressed and operates on the
 * specified transform group to move the camera.
 * //from w  ww  .jav a2s . c om
 * @param Enumeration
 *            criteria - all pressed keys in a list. This will be passed by
 *            the system.
 */
public void processStimulus(Enumeration criteria) {
    WakeupOnAWTEvent eventToWakeUp;
    AWTEvent[] events;

    if (criteria.hasMoreElements()) {
        // Decode the wakeup criteria
        eventToWakeUp = (WakeupOnAWTEvent) criteria.nextElement();
        events = eventToWakeUp.getAWTEvent();
        keyEvent = (KeyEvent) events[0];
        int keyCode = keyEvent.getKeyCode();

        // Perform our processing

        // Get the initial transformation from target and put it
        // into myKeyNavTransf3D
        target_trGr.getTransform(myKeyNavTransf3D);

        // Not any of the 2 rotations don't act simultaneously.
        switch (keyCode) {
        case KeyEvent.VK_HOME: // Home - rotate up
            rotation.rotX(angle);
            break;

        case KeyEvent.VK_END: // End - rotate down
            rotation.rotX(-angle);
            break;

        default:
            rotation.rotX(0.0f);
        }

        myKeyNavTransf3D.mul(rotation);

        // Return the final transformation myKeyNavTransf3D to target
        target_trGr.setTransform(myKeyNavTransf3D);
    }

    // Set wakeup criteria for next time.
    wakeupOn(wakeUp);
}

From source file:Demo3D.java

/**
 * Override Behavior's stimulus method to handle the event. This method is
 * called when a key on the keyboard has been pressed and operates on the
 * specified transform group to move the camera.
 * //from w w  w .  j ava2  s .  c om
 * @param Enumeration
 *            criteria - all pressed keys in a list. This will be passed by
 *            the system.
 */
public void processStimulus(Enumeration criteria) {
    WakeupOnAWTEvent eventToWakeUp;
    AWTEvent[] events;

    if (criteria.hasMoreElements()) {
        // Decode the wakeup criteria
        eventToWakeUp = (WakeupOnAWTEvent) criteria.nextElement();
        events = eventToWakeUp.getAWTEvent();
        keyEvent = (KeyEvent) events[0];
        int keyCode = keyEvent.getKeyCode();

        // Perform our processing

        // Get the initial transformation from target and put it into
        // myKeyNavTransf3D
        target_trGr.getTransform(myKeyNavTransf3D);

        // Set the translational components of myKeyNavTransf3D in
        // translation
        myKeyNavTransf3D.get(translation);

        // Not any of the 8 motions (6 translations and 2 rotations)
        // don't act simultaneously.
        switch (keyCode) {
        case KeyEvent.VK_UP: // Up Arrow - to move forward
            trans_rot.set(new Vector3f(0.0f, 0.0f, -step));
            break;

        case KeyEvent.VK_DOWN: // Down Arrow - to move backwards
            trans_rot.set(new Vector3f(0.0f, 0.0f, step));
            break;

        case KeyEvent.VK_LEFT: // Left Arrow -to turn left or move left
            if (keyEvent.isShiftDown())
                trans_rot.set(new Vector3f(-step, 0.0f, 0.0f));
            else
                trans_rot.rotY(angle);
            break;

        case KeyEvent.VK_RIGHT: // Right Arrow - to turn right or move right
            if (keyEvent.isShiftDown())
                trans_rot.set(new Vector3f(step, 0.0f, 0.0f));
            else
                trans_rot.rotY(-angle);
            break;

        case KeyEvent.VK_PAGE_DOWN: // Page Down - to move down
            trans_rot.set(new Vector3f(0.0f, -step, 0.0f));
            break;

        case KeyEvent.VK_PAGE_UP: // Page Up - to move up
            trans_rot.set(new Vector3f(0.0f, step, 0.0f));
            break;

        default:
            trans_rot.set(new Vector3f(0.0f, 0.0f, 0.0f));
        }

        myKeyNavTransf3D.mul(trans_rot);

        // Return the final transformation myKeyNavTransf3D to target
        target_trGr.setTransform(myKeyNavTransf3D);
    }

    // Set wakeup criteria for next time.
    wakeupOn(wakeUp);
}