Package com.jme.math

Examples of com.jme.math.Vector3f


            cellBounds.x = ((BoundingSphere)bounds).getRadius();
            return cellBounds;
        }
        else if (bounds instanceof BoundingBox) {
            cellBounds.type = BoundsType.BOX;
            Vector3f extent = new Vector3f();
            ((BoundingBox)bounds).getExtent(extent);
            cellBounds.x = extent.x;
            cellBounds.y = extent.y;
            cellBounds.z = extent.z;
            return cellBounds;
View Full Code Here


        // load the starting coordinates and look direction
        float startX = Float.parseFloat(System.getProperty("x", "0"));
        float startY = Float.parseFloat(System.getProperty("y", "0"));
        float startZ = Float.parseFloat(System.getProperty("z", "0"));
        Vector3f startLoc = new Vector3f(startX, startY, startZ);

        float look = Float.parseFloat(System.getProperty("look""0"));
        Quaternion startLook = new Quaternion(
                new float[] { 0f, (float) Math.toRadians(look), 0f });
View Full Code Here

    /** Default constructor, used when cell is created via WFS */
    public ColladaCellMO() {
    }
   
    public ColladaCellMO(Vector3f center, float size, AssetURI modelURI, Vector3f geometryTranslation, Quaternion geometryRotation) {
        super(new BoundingBox(new Vector3f(), size, size, size), new CellTransform(null, center));
        this.modelURI = modelURI;
        this.geometryRotation = geometryRotation;
        this.geometryTranslation = geometryTranslation;
    }
View Full Code Here

     *
     */
    public static float pointLineDistance( final Vector3f lineStart,
                                           final Vector3f lineEnd,
                                           final Vector3f point ) {
        Vector3f a = new Vector3f(lineEnd);
        a.subtract(lineStart);
       
        Vector3f b = new Vector3f(lineStart);
        b.subtract(point);
       
        Vector3f cross = new Vector3f();
        cross.cross(a,b);
       
        return cross.length()/a.length();
    }
View Full Code Here

    /**
     * Converts the Matrix into Euler angles (roll, pitch, yaw )
     */
    public static void toEuler( Matrix3f matrix, Vector3f euler ) {
        Vector3f v3d = new Vector3f();
       
        Vector3f zAxis = new Vector3f( 0, 0, -1 );
        Vector3f yAxis = new Vector3f( 0, 1, 0 );
        Vector3f xAxis = new Vector3f( 1, 0, 0 );

        v3d.set( xAxis );
        matrix.mult( v3d, v3d );
        v3d.x = Math.abs( v3d.x );
        v3d.z = 0;
        v3d.normalize();

        euler.x = xAxis.angleBetween( v3d );

        v3d.set( yAxis );
        matrix.mult( v3d, v3d );
        v3d.z = Math.abs( v3d.z );
        v3d.x = 0;
View Full Code Here

    /**
     * Returns true if the parent bounds fully encloses the child
     */
    public static boolean encloses(BoundingBox parent, BoundingSphere child) {
        Vector3f pCenter = parent.getCenter();
        Vector3f pExtent = parent.getExtent(null);
        Vector3f cCenter = child.getCenter();
        float radius= child.getRadius();

        if (cCenter.x+radius > pCenter.x + pExtent.x ||
            cCenter.y+radius > pCenter.y + pExtent.y ||
            cCenter.z+radius > pCenter.z + pExtent.z)
View Full Code Here

     /**
     * Returns true if the parent bounds fully encloses the child
     */
    public static boolean encloses(BoundingBox parent, BoundingBox child) {
        Vector3f pExtent = parent.getExtent(null);
        Vector3f cExtent = child.getExtent(null);
        Vector3f pCenter = parent.getCenter();
        Vector3f cCenter = child.getCenter();

        if (cCenter.x+cExtent.x > pCenter.x+pExtent.x ||
            cCenter.y+cExtent.y > pCenter.y+pExtent.y ||
            cCenter.z+cExtent.z > pCenter.z+pExtent.z)
                return false;
View Full Code Here

     * Returns true if the parent bounds fully encloses the child
     */
    public static boolean encloses(BoundingSphere parent, BoundingBox child) {
        // Check each corner of the box is within the sphere

        Vector3f cCenter = child.getCenter();
        Vector3f cExtent = child.getExtent(null);
        Vector3f tmp = new Vector3f();
       
        tmp.x=cCenter.x + cExtent.x;
        tmp.y=cCenter.y + cExtent.y;
        tmp.z=cCenter.z + cExtent.z;
        if (!parent.contains(tmp))
View Full Code Here

    /**
     * Returns true if the parent bounds fully encloses the child
     */
    public static boolean encloses(BoundingSphere parent, BoundingSphere child) {
        Vector3f childCenter = new Vector3f();
        Vector3f parentCenter = new Vector3f();
        child.getCenter(childCenter);
        parent.getCenter(parentCenter);
        float childR = child.getRadius();
        float parentR = parent.getRadius();

View Full Code Here

        translation.set(tIn);
        rotation.set(rIn);
        viewRot.set(rotation);
        viewTranslation.set(translation);

        Vector3f cameraTrans = rotation.mult(offset);
//            System.out.println("Camera trans "+cameraTrans );
        translation.addLocal(cameraTrans);

        // handle camera collision
        if (COLLISION_GLOBAL_ENABLE && (collisionEnabled || collisionCheck)) {
            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);
               
                // if the distance is less than the minimum, try the next
                // info
                if (details.getDistance() < MIN_DISTANCE) {
                    continue;
                }
               
                // if we are performing a collision check, see if the
                // camera is closer than the collision
                if (collisionCheck) {
                    if (target.distance(translation) <= details.getDistance()) {
                        // camera is closer than the nearest collision,
                        // re-enable collision
                        collisionEnabled = true;
                    }
                   
                    // only check the first collision
                    break;
                }
               
                // if the collision is farther than where the camera would
                // have been positioned or outside of range, we can stop and
                // leave the camera as is
                if (details.getDistance() >= MAX_DISTANCE ||
                    details.getDistance() >= target.distance(translation))
                {
                    break;
                }
               
                // if we made it here, the collision is within range. Move
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.