Example usage for javax.media.j3d PickBounds PickBounds

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

Introduction

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

Prototype

public PickBounds(Bounds boundsObject) 

Source Link

Document

Constructs a PickBounds from the specified bounds object.

Usage

From source file:NodesTest.java

public void processStimulus(java.util.Enumeration criteria) {
    while (criteria.hasMoreElements()) {
        WakeupCriterion wakeUp = (WakeupCriterion) criteria.nextElement();

        // every N frames, check for a collision
        if (wakeUp instanceof WakeupOnElapsedFrames) {
            // create a PickBounds
            PickTool pickTool = new PickTool(pickRoot);
            pickTool.setMode(PickTool.BOUNDS);

            BoundingSphere bounds = (BoundingSphere) collisionObject.getBounds();
            pickBounds = new PickBounds(new BoundingSphere(
                    new Point3d(positionVector.x, positionVector.y, positionVector.z), bounds.getRadius()));
            pickTool.setShape(pickBounds, new Point3d(0, 0, 0));
            PickResult[] resultArray = pickTool.pickAll();

            if (isCollision(resultArray))
                onCollide();/*from ww  w .  j  a va 2s. co m*/
            else
                onMiss();

            moveCollisionObject();
        }
    }

    // assign the next WakeUpCondition, so we are notified again
    wakeupOn(m_WakeupCondition);
}