Examples of Ray


Examples of com.jme.math.Ray

    /**
     * Calculates the ray to use for picking, based on the given screen coordinates.
     */
    Ray calcPickRayWorld (int x, int y) {
        Ray result = null;
  // Get the world space coordinates of the eye position
  Camera camera = cameraComp.getCamera();
  Vector3f eyePosWorld = camera.getLocation();

  // Convert the event from AWT coords to JME float screen space.
  // Need to invert y because (0f, 0f) is at the button left corner.
  eventPointScreen.setX((float)x);
  eventPointScreen.setY((float)(canvas.getHeight()-1-y));

  // Get the world space coordinates of the screen space point from the event
  // (The glass plate of the screen is considered to be at at z = 0 in world space
        try { // May fail if jME thinks the camera matrix is singular
            camera.getWorldCoordinates(eventPointScreen, 0f, eventPointWorld);
            // Compute the diff and create the ray
            eventPointWorld.subtract(eyePosWorld, directionWorld);
            result = new Ray(eyePosWorld, directionWorld.normalize());
        } catch (ArithmeticException ex) {
            logger.log(Level.SEVERE,"Problem getting world space coords for pick ray.", ex);
            result = new Ray();
        }
        return result;
    }
View Full Code Here

Examples of com.jme.math.Ray

     */
    PickInfo pickEventScreenPos (int x, int y) {
  if (cameraComp == null) return null;

  logger.fine("pick at " + x + ", " + y);
  Ray pickRayWorld = calcPickRayWorld(x, y);

  // Note: pickAll is needed to in order to pick through transparent objects.
  return collisionSys.pickAllWorldRay(pickRayWorld, true, false/*TODO:interp*/,
                                            true, /* for now, always include ortho objects in picking */
                                            cameraComp);
View Full Code Here

Examples of com.jme.math.Ray

            Vector3f dir = new Vector3f(translation);
            Vector3f target = new Vector3f(tIn);
            target.addLocal(0, DEFAULT_OFFSET.y, 0);
            dir.subtractLocal(target).normalizeLocal();
           
            Ray ray = new Ray(target, dir);
            PickInfo info = collisionSys.pickAllWorldRay(ray, true, false,
                                                         false, cameraComp);
            for (int i = 0; i < info.size(); i++) {
                // find the next picked object
                PickDetails details = info.get(i);
View Full Code Here

Examples of com.jme.math.Ray

     */
    public static float getVectorToCollidable(JMECollisionSystem collision,
            Vector3f position, Vector3f lookAt) {
       
        // Construct a ray out from the avatar given it's "look at".
        Ray heightRay = new Ray();
        heightRay.origin.set(position);
        heightRay.direction = lookAt;

        logger.info("For collidable, origin=" + position + " look at " +
                lookAt);
View Full Code Here

Examples of com.jme.math.Ray

            Vector3f position) {

        // Construct a ray down to the ground from the position given. We add
        // a bit of "slop" to the y vector.
        float yDelta = 1.0f;
        Ray heightRay = new Ray();
        heightRay.origin.set(position);
        heightRay.origin.y += yDelta;
        heightRay.direction = new Vector3f(0.0f, -1.0f, 0.0f);

        // Use the given collision system to find where the ground is. If we
View Full Code Here

Examples of com.jme.math.Ray

  @Override
  public void onDetonate(Node other) {
    Vector3f dummy = new Vector3f();
    Vector3f direction = new Vector3f();
    getWorldRotation().toAxes(new Vector3f[] {dummy, dummy, direction});
    Ray ray = new Ray(getWorldTranslation(), direction);
   
    warhead.detonate(ray, TankGame.GAMESTATE.getRoot());
  }
View Full Code Here

Examples of com.jme.math.Ray

  @Override
  public void onDetonate(Node other) {
    Vector3f dummy = new Vector3f();
    Vector3f direction = new Vector3f();
    getWorldRotation().toAxes(new Vector3f[] {dummy, dummy, direction});
    Ray ray = new Ray(getWorldTranslation(), direction);
   
    warhead.detonate(ray, other);
  }
View Full Code Here

Examples of com.jme.math.Ray

  @Override
  public void fire(Ray vector, Vector3f force, Node rootNode) {
    // instantly ray picks and collides
    Vector3f store = new Vector3f();
    Tools.pointPick(vector, rootNode, store);
    Ray ray = new Ray(store, vector.direction);
    warhead.detonate(ray, rootNode);
    cleanup();
  }
View Full Code Here

Examples of com.jme.math.Ray

  @Override
  public void onDetonate(Node other) {
    Vector3f dummy = new Vector3f();
    Vector3f direction = new Vector3f();
    getWorldRotation().toAxes(new Vector3f[] {dummy, dummy, direction});
    Ray ray = new Ray(getWorldTranslation(), direction);
   
    warhead.detonate(ray, other);
  }
View Full Code Here

Examples of com.jme.math.Ray

     * the window with which the ray can be intersected.
     */
    public Point calcIntersectionPixelOfEyeRay(int x, int y) {

        // Calculate the ray
        Ray rayWorld = InputManager3D.getInputManager().pickRayWorld(x, y);

        // Calculate an arbitrary point on the plane (in this case, the top left corner)
        float width = view.getDisplayerLocalWidth();
        float height = view.getDisplayerLocalHeight();
        Vector3f topLeftLocal = new Vector3f(-width / 2f, height / 2f, 0f);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.