Package com.ardor3d.math

Examples of com.ardor3d.math.Quaternion


        assert (null != from) : "parameter 'from' can not be null";
        assert (null != to) : "parameter 'to' can not be null";
        assert (null != caller) : "parameter 'caller' can not be null";

        final Quaternion tempQuat = Quaternion.fetchTempInstance();

        tempQuat.slerpLocal(from, to, delta);

        if (isLocalRotation()) {
            caller.setRotation(tempQuat);
        } else {
            caller.setWorldRotation(tempQuat);
View Full Code Here


            _xArrow.removeFromParent();
        }
        _xColor.set(color);
        _xArrow = new InteractArrow("xMoveArrow", scale, width, lengthGap, tipGap);
        _xArrow.setDefaultColor(color);
        final Quaternion rotate = new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.UNIT_Y);
        _xArrow.setRotation(rotate);
        _handle.attachChild(_xArrow);
        return this;
    }
View Full Code Here

            _yArrow.removeFromParent();
        }
        _yColor.set(color);
        _yArrow = new InteractArrow("yMoveArrow", scale, width, lengthGap, tipGap);
        _yArrow.setDefaultColor(color);
        final Quaternion rotate = new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.NEG_UNIT_X);
        _yArrow.setRotation(rotate);
        _handle.attachChild(_yArrow);
        return this;
    }
View Full Code Here

    public SimpleScaleWidget withArrow(final ReadOnlyVector3 arrowDirection, final ReadOnlyColorRGBA color,
            final double lengthGap, final double tipGap) {
        _arrowDirection = new Vector3(arrowDirection);
        _handle = new InteractArrow("scaleHandle", 1.0, 0.125, lengthGap, tipGap);
        if (!_arrowDirection.equals(Vector3.UNIT_Z)) {
            _handle.setRotation(new Quaternion().fromVectorToVector(Vector3.UNIT_Z, _arrowDirection));
        }

        final BlendState blend = new BlendState();
        blend.setBlendEnabled(true);
        _handle.setRenderState(blend);
View Full Code Here

        if (_xRing != null) {
            _xRing.removeFromParent();
        }
        _xRing = new InteractRing("xRotRing", 4, 32, scale, width);
        _xRing.setDefaultColor(color);
        final Quaternion rotate = new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.UNIT_Y);
        _xRing.getMeshData().rotatePoints(rotate);
        _xRing.getMeshData().rotateNormals(rotate);
        _handle.attachChild(_xRing);
        return this;
    }
View Full Code Here

        if (_yRing != null) {
            _yRing.removeFromParent();
        }
        _yRing = new InteractRing("yRotRing", 4, 32, scale, width);
        _yRing.setDefaultColor(color);
        final Quaternion rotate = new Quaternion().fromAngleAxis(MathUtils.HALF_PI, Vector3.NEG_UNIT_X);
        _yRing.getMeshData().rotatePoints(rotate);
        _yRing.getMeshData().rotateNormals(rotate);
        _handle.attachChild(_yRing);
        return this;
    }
View Full Code Here

        _calcVec3A.subtractLocal(_handle.getWorldTranslation());
        _calcVec3B.subtractLocal(_handle.getWorldTranslation());

        // apply to our interact matrix if used
        if (_interactMatrix == InteractMatrix.World) {
            _rotateStore.multiplyLocal(new Quaternion().fromVectorToVector(_calcVec3A, _calcVec3B).toRotationMatrix(
                    _calcMat3));
        }

        // convert to target coord space
        final Node parent = manager.getSpatialTarget().getParent();
        if (parent != null) {
            parent.getWorldTransform().applyInverseVector(_calcVec3A);
            parent.getWorldTransform().applyInverseVector(_calcVec3B);
        }

        // return a rotation to take us to the new rotation
        return new Quaternion().fromVectorToVector(_calcVec3A, _calcVec3B);
    }
View Full Code Here

        // find mouse location in world coords
        _canvas.getCanvasRenderer().getCamera().getPickRay(mouseLoc, false, ray);
        ray.intersectsPlane(rocketPlane, worldStore);

        // get rocket's current orientation as quat
        final Quaternion currentOrient = new Quaternion().fromRotationMatrix(rocketEntityNode.getWorldRotation());

        // get orientation that points rocket nose straight at mouse
        final Vector3 dirTowardsMouse = new Vector3(worldStore).subtractLocal(rocketEntityNode.getWorldTranslation())
                .normalizeLocal();
        final Quaternion targetOrient = new Quaternion().fromVectorToVector(Vector3.NEG_UNIT_Z, dirTowardsMouse);

        // get a scale representing choice between direction of old and new quats
        final double scale = currentOrient.dot(targetOrient) * tpf * ROCKET_TURN_SPEED;
        currentOrient.addLocal(targetOrient.multiplyLocal(scale)).normalizeLocal();

        rocketEntityNode.setRotation(currentOrient);

        // propel forward
        rocketEntityNode.addTranslation(currentOrient.apply(Vector3.NEG_UNIT_Z, null).multiplyLocal(
View Full Code Here

        }
    }

    private void buildRocket() {
        final Arrow rocket = new Arrow("rocket", 5, 2);
        rocket.setRotation(new Quaternion().fromAngleAxis(MathUtils.DEG_TO_RAD * -90, Vector3.UNIT_X));
        rocketEntityNode.attachChild(rocket);
        _root.attachChild(rocketEntityNode);
    }
View Full Code Here

        ms.setColorMaterial(ColorMaterial.AmbientAndDiffuse);

        // A box to check aspect ratio of 3D objects
        box1 = new Box("test box 1", new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
        box1.setTranslation(0, 5, 0);
        box1.setRotation(new Quaternion().fromEulerAngles(MathUtils.DEG_TO_RAD * 45, MathUtils.DEG_TO_RAD * 60,
                MathUtils.DEG_TO_RAD * 30));
        box1.setSolidColor(ColorRGBA.GREEN);
        box1.setRenderState(ms);
        box1.updateModelBound();

View Full Code Here

TOP

Related Classes of com.ardor3d.math.Quaternion

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.