DacWizard/src/main/java/jme3utilities/minie/wizard/TestMode.java
/**
     * Cast a physics ray from the mouse pointer. If the nearest hit is a
     * PhysicsLink, select that link.
     */
Cast a physics ray from the mouse pointer. If the nearest hit is a
PhysicsLink, select that link.
Cast a physics ray from the mouse pointer . If the nearest hit is a PhysicsLink select that link .
private void pickLink() {
        Vector2f screenXY = inputManager.getCursorPosition();
        Vector3f from = cam.getWorldCoordinates(screenXY, 0f);
        Vector3f to = cam.getWorldCoordinates(screenXY, 1f);
        BulletAppState bulletAppState
                = DacWizard.findAppState(BulletAppState.class);
        PhysicsSpace physicsSpace = bulletAppState.getPhysicsSpace();
        List<PhysicsRayTestResult> rayTest = physicsSpace.rayTest(from, to);
        if (rayTest.size() > 0) {
            PhysicsRayTestResult nearestHit = rayTest.get(0);
            PhysicsCollisionObject pco = nearestHit.getCollisionObject();
            Object user = pco.getUserObject();
            if (user instanceof PhysicsLink) {
                PhysicsLink link = (PhysicsLink) user;
                Model model = DacWizard.getModel();
                if (link instanceof BoneLink) {
                    String boneName = link.boneName();
                    model.selectLink(boneName);
                } else {
                    assert link instanceof TorsoLink;
                    model.selectLink(DacLinks.torsoName);
                }
            }
        }
    }
private void pickLink ( ) { Vector2f screenXY = inputManager . getCursorPosition ( ) ; Vector3f from = cam . getWorldCoordinates ( screenXY , 0f ) ; Vector3f to = cam . getWorldCoordinates ( screenXY , 1f ) ; BulletAppState bulletAppState = DacWizard . findAppState ( BulletAppState . class ) ; PhysicsSpace physicsSpace = bulletAppState . getPhysicsSpace ( ) ; List < PhysicsRayTestResult > rayTest = physicsSpace . rayTest ( from , to ) ; if ( rayTest . size ( ) > 0 ) { PhysicsRayTestResult nearestHit = rayTest . get ( 0 ) ; PhysicsCollisionObject pco = nearestHit . getCollisionObject ( ) ; Object user = pco . getUserObject ( ) ; if ( user instanceof PhysicsLink ) { PhysicsLink link = ( PhysicsLink ) user ; Model model = DacWizard . getModel ( ) ; if ( link instanceof BoneLink ) { String boneName = link . boneName ( ) ; model . selectLink ( boneName ) ; } else { assert link instanceof TorsoLink ; model . selectLink ( DacLinks . torsoName ) ; } } } }
Cast a physics ray from the mouse pointer.
Cast a physics ray from the mouse pointer .