Package com.jme3.math

Examples of com.jme3.math.Quaternion


    /**
     * @return the physicsLocation
     */
    public Quaternion getPhysicsRotation(Quaternion rot) {
        if (rot == null) {
            rot = new Quaternion();
        }
        getPhysicsRotation(objectId, rot);
        return rot;
    }
View Full Code Here


    /**
     * @return the physicsLocation
     */
    public Quaternion getPhysicsRotation() {
        Quaternion quat = new Quaternion();
        getPhysicsRotation(objectId, quat);
        return quat;
    }
View Full Code Here

    /**
     * @return the physicsLocation
     */
    public Quaternion getPhysicsRotation(Quaternion rot) {
        if (rot == null) {
            rot = new Quaternion();
        }
        getPhysicsRotation(objectId, rot);
        return rot;
    }
View Full Code Here

    /**
     * @return the physicsLocation
     */
    public Quaternion getPhysicsRotation() {
        Quaternion quat = new Quaternion();
        getPhysicsRotation(objectId, quat);
        return quat;
    }
View Full Code Here

    public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
        if (needToCompute && influence != 0) {
            ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
            BoneContext[] boneContexts = this.getBones();
            float b = chainLength;
            Quaternion boneWorldRotation = new Quaternion();

            for (int i = 0; i < boneContexts.length; ++i) {
                Bone bone = boneContexts[i].getBone();

                bone.updateWorldVectors();
                Transform boneWorldTransform = constraintHelper.getTransform(boneContexts[i].getArmatureObjectOMA(), bone.getName(), Space.CONSTRAINT_SPACE_WORLD);

                Vector3f head = boneWorldTransform.getTranslation();
                Vector3f tail = head.add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneContexts[i].getLength())));

                Vector3f vectorA = tail.subtract(head);
                float a = vectorA.length();
                vectorA.normalizeLocal();

                Vector3f vectorC = targetTransform.getTranslation().subtract(head);
                float c = vectorC.length();
                vectorC.normalizeLocal();

                b -= a;
                float theta = 0;

                if (c >= a + b) {
                    theta = vectorA.angleBetween(vectorC);
                } else if (c <= FastMath.abs(a - b) && i < boneContexts.length - 1) {
                    theta = vectorA.angleBetween(vectorC) - FastMath.HALF_PI;
                } else {
                    theta = vectorA.angleBetween(vectorC) - FastMath.acos(-(b * b - a * a - c * c) / (2 * a * c));
                }
               
                theta *= influence;

                if (theta != 0) {
                    Vector3f vectorR = vectorA.cross(vectorC);
                    boneWorldRotation.fromAngleAxis(theta, vectorR);
                    boneWorldTransform.getRotation().multLocal(boneWorldRotation);
                    constraintHelper.applyTransform(boneContexts[i].getArmatureObjectOMA(), bone.getName(), Space.CONSTRAINT_SPACE_WORLD, boneWorldTransform);
                }

                bone.updateWorldVectors();
View Full Code Here

    public void applyWheelTransform() {
        if (wheelSpatial == null) {
            return;
        }
        Quaternion localRotationQuat = wheelSpatial.getLocalRotation();
        Vector3f localLocation = wheelSpatial.getLocalTranslation();
        if (!applyLocal && wheelSpatial.getParent() != null) {
            localLocation.set(wheelWorldLocation).subtractLocal(wheelSpatial.getParent().getWorldTranslation());
            localLocation.divideLocal(wheelSpatial.getParent().getWorldScale());
            tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);

            localRotationQuat.set(wheelWorldRotation);
            tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);

            wheelSpatial.setLocalTranslation(localLocation);
            wheelSpatial.setLocalRotation(localRotationQuat);
        } else {
View Full Code Here

                            // take the initial transform of a bone and its virtual track
                            Transform previousTransform = previousTransforms.get(boneIndex);
                            VirtualTrack vTrack = trackEntry.getValue();

                            Vector3f bonePositionDifference = bone.getLocalPosition().subtract(previousTransform.getTranslation());
                            Quaternion boneRotationDifference = bone.getLocalRotation().mult(previousTransform.getRotation().inverse()).normalizeLocal();
                            Vector3f boneScaleDifference = bone.getLocalScale().divide(previousTransform.getScale());
                            if (frame > 0) {
                                bonePositionDifference = vTrack.translations.get(frame - 1).add(bonePositionDifference);
                                boneRotationDifference = vTrack.rotations.get(frame - 1).mult(boneRotationDifference);
                                boneScaleDifference = vTrack.scales.get(frame - 1).mult(boneScaleDifference);
View Full Code Here

    @Override
    public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
        Transform ownerTransform = this.getOwnerTransform(ownerSpace);
       
        Quaternion ownerRotation = ownerTransform.getRotation();
        ownerAngles = ownerRotation.toAngles(ownerAngles);
        targetAngles = targetTransform.getRotation().toAngles(targetAngles);

        Quaternion startRotation = ownerRotation.clone();
        Quaternion offset = Quaternion.IDENTITY;
        if ((flag & ROTLIKE_OFFSET) != 0) {// we add the original rotation to
                                           // the copied rotation
            offset = startRotation;
        }
View Full Code Here

    // Setup first view
    viewPort.setBackgroundColor(ColorRGBA.Blue);
    cam.setViewPort(.5f, 1f, 0f, 0.5f);
    cam.setLocation(new Vector3f(3.3212643f, 4.484704f, 4.2812433f));
    cam.setRotation(new Quaternion(-0.07680723f, 0.92299235f, -0.2564353f, -0.27645364f));

    // Setup second view
    Camera cam2 = cam.clone();
    cam2.setViewPort(0f, 0.5f, 0f, 0.5f);
    cam2.setLocation(new Vector3f(-0.10947256f, 1.5760219f, 4.81758f));
    cam2.setRotation(new Quaternion(0.0010108891f, 0.99857414f, -0.04928594f, 0.020481428f));

    ViewPort view2 = renderManager.createMainView("Bottom Left", cam2);
    view2.setClearFlags(true, true, true);
    view2.attachScene(rootNode);

    // Setup third view
    Camera cam3 = cam.clone();
    cam3.setViewPort(0f, .5f, .5f, 1f);
    cam3.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
    cam3.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));

    ViewPort view3 = renderManager.createMainView("Top Left", cam3);
    view3.setClearFlags(true, true, true);
    view3.attachScene(rootNode);

    // Setup fourth view
    Camera cam4 = cam.clone();
    cam4.setViewPort(.5f, 1f, .5f, 1f);
    cam4.setLocation(new Vector3f(4.775564f, 1.4548365f, 0.11491505f));
    cam4.setRotation(new Quaternion(0.02356979f, -0.74957186f, 0.026729556f, 0.66096294f));

    ViewPort view4 = renderManager.createMainView("Top Right", cam4);
    view4.setClearFlags(true, true, true);
    view4.attachScene(rootNode);
View Full Code Here

       
        Bone target = control.getSkeleton().getBone(targetBoneIndex);

        Vector3f tempV = vars.vect1;
        Vector3f tempS = vars.vect2;
        Quaternion tempQ = vars.quat1;
        Vector3f tempV2 = vars.vect3;
        Vector3f tempS2 = vars.vect4;
        Quaternion tempQ2 = vars.quat2;
       
        int lastFrame = times.length - 1;
        if (time < 0 || lastFrame == 0) {
            rotations.get(0, tempQ);
            translations.get(0, tempV);
View Full Code Here

TOP

Related Classes of com.jme3.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.