Package com.jme.math

Examples of com.jme.math.Vector3f


     */
    public Vector3f getHitIntersectionPointLocal () {
  if (hitPickDetails == null) {
      return null;
  } else {
      Vector3f posWorld = hitPickDetails.getPosition();
      if (posWorld == null) return null;
      CollisionComponent cc = hitPickDetails.getCollisionComponent();
      Node node = cc.getNode();
      node.getLocalToWorldMatrix(world2Local);
      world2Local.invert();
      return world2Local.mult(hitPickDetails.getPosition(), new Vector3f());
  }
    }
View Full Code Here


    public static Vector3f getDragVectorWorld (int eventX, int eventY, Vector3f dragStartWorld,
                                               Point dragStartScreen, Vector3f ret) {
 
  logger.fine("dragStartWorld rel = " + dragStartWorld);
  if (ret == null) {
      ret = new Vector3f();
  }

  // The current world position of the eye
  Vector3f eyeWorld = InputPicker3D.getInputPicker().getCameraPosition(null);
  logger.fine("eyeWorld = " + eyeWorld);

  // The float movement vector in screen space
  Vector2f scrPos = new Vector2f((float)(eventX - dragStartScreen.x),
                                       (float)(eventY - dragStartScreen.y));
  logger.fine("scrPos = " + scrPos);

  Vector2f pressXY = new Vector2f((float)dragStartScreen.x, (float)dragStartScreen.y);
  Vector3f pressWorld = ((InputManager3D)InputManager3D.getInputManager()).
      getCamera().getWorldCoordinates(pressXY, 0f);

  Vector2f dragXY = new Vector2f((float)eventX, (float)eventY);
  Vector3f dragWorld = ((InputManager3D)InputManager3D.getInputManager()).
      getCamera().getWorldCoordinates(dragXY, 0f);

  // The world position of this event (in the view plane)
  Vector3f thisWorld = ((InputManager3D)InputManager3D.getInputManager()).
      getCamera().getWorldCoordinates(scrPos, 0f);
  logger.fine("thisWorld = " + thisWorld);

  // The calculations need to take place in eye space. Get the necessary matrices.
  Matrix4f camMatrix = InputPicker3D.getInputPicker().getCameraModelViewMatrix(null);
  Matrix4f camInverse = InputPicker3D.getInputPicker().getCameraModelViewMatrixInverse(null);
  logger.finest("camInverse = " + camInverse);

  // Transform vectors from world space into eye space
  Vector3f dragEye = new Vector3f();
  Vector3f dragStartEye = new Vector3f();
  Vector3f pressEye = new Vector3f();
  Vector3f eyeEye = new Vector3f();
  Vector3f thisEye = new Vector3f();
  camInverse.mult(dragWorld, dragEye);
  camInverse.mult(dragStartWorld, dragStartEye);
  camInverse.mult(pressWorld, pressEye);
  // TODO: perf: only really need to recalc eyeEye on camera change
  camInverse.mult(eyeWorld, eyeEye);
  camInverse.mult(thisWorld, thisEye);

  // The displacement vector of this event from the center of the drag plane
  Vector3f dragVectorEye = new Vector3f(
            (dragEye.x - pressEye.x) * (dragStartEye.z - eyeEye.z) / (thisEye.z - eyeEye.z),
      (pressEye.y - dragEye.y) * (dragStartEye.z - eyeEye.z) / (thisEye.z - eyeEye.z),
      0f);
  logger.fine("dragVectorEye = " + dragVectorEye);

View Full Code Here

        }

        public BoundingVolumeHandler(BoundingVolume v) {
            if (v instanceof BoundingSphere) {
                boundsType = BoundsType.SPHERE;
                Vector3f center = ((BoundingSphere)v).getCenter();
                center_x = center.x;
                center_y = center.y;
                center_z = center.z;
                dimension_x = ((BoundingSphere)v).getRadius();
            } else if (v instanceof BoundingBox) {
                boundsType = BoundsType.BOX;
                Vector3f center = ((BoundingBox)v).getCenter();
                center_x = center.x;
                center_y = center.y;
                center_z = center.z;
                Vector3f dimension = ((BoundingBox)v).getExtent(null);
                dimension_x = dimension.x;
                dimension_y = dimension.y;
                dimension_z = dimension.z;
            } else {
                throw new RuntimeException("Unsupported bounds type "+v.getClass().getName());
View Full Code Here

        }

        public BoundingVolume createBounds() {
            switch(boundsType) {
                case SPHERE :
                    return new BoundingSphere(dimension_x, new Vector3f(center_x, center_y, center_z));
                case BOX :
                    return new BoundingBox(new Vector3f(center_x, center_y, center_z), dimension_x, dimension_y, dimension_z);
                default :
                    throw new RuntimeException("Unsupported bounds type "+boundsType);
            }
        }
View Full Code Here

    @Override
    public Quaternion unmarshal(QuaternionHandler q) throws Exception {
        if (q==null)
            return null;
        Vector3f axis = new Vector3f(q.x, q.y, q.z);
        Quaternion ret = new Quaternion();
        ret.fromAngleAxis(q.angle, axis);
        return ret;
    }
View Full Code Here

        public QuaternionHandler() {
        }

        public QuaternionHandler(Quaternion q) {
            Vector3f axis=new Vector3f();
            float a = q.toAngleAxis(axis);

            x = axis.x;
            y = axis.y;
            z = axis.z;
View Full Code Here

    @Override
    public Vector3f unmarshal(Vector3fHandler v) throws Exception {
        if (v==null)
            return null;
        return new Vector3f(v.x, v.y, v.z);
    }
View Full Code Here

        String transZStr = connectionProperties.getProperty(INITIAL_POSITION_PROP_PREFIX + "z");
        if (transZStr != null) {
            transZ = Float.parseFloat(transZStr);
        }

        Vector3f translation = new Vector3f(transX, transY, transZ);

        float rotX = 0f;
        float rotY = 0f;
        float rotZ = 0f;
View Full Code Here

            return;

        if (live) {
            if (localBounds==null) {
                logger.severe("CELL HAS NULL BOUNDS, defaulting to unit sphere");
                localBounds = new BoundingSphere(1f, new Vector3f());
            }

            createChannelComponent();
            resolveAutoComponentAnnotationsForCell();
View Full Code Here

    public static BoundingVolume getCellBounds(PositionComponentServerState setup) {
        BoundsType type = setup.getBounds().type;
        float x = (float)setup.getBounds().x;
       
        if (type.equals(BoundsType.SPHERE) == true) {
            return new BoundingSphere(x, new Vector3f());
        }
        else if (type.equals(BoundsType.BOX) == true) {
            return new BoundingBox(new Vector3f(), x, (float)setup.getBounds().y, (float)setup.getBounds().z);
        }
       
        /* This should never happen, but in case it does... */
        throw new RuntimeException("Unsupported bounds type " + type);
    }
View Full Code Here

TOP

Related Classes of com.jme.math.Vector3f

Copyright © 2018 www.massapicom. 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.