Package com.ardor3d.math

Examples of com.ardor3d.math.Quaternion


            final ColladaImporter colladaImporter = new ColladaImporter();

            // Load the collada scene
            final ColladaStorage storage = colladaImporter.load(source);
            colladaNode = storage.getScene();
            colladaNode.setRotation(new Quaternion(-1,0,0,1));
        } catch (final Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here


    public static WireframeState wireframeState = new WireframeState();


    public void addStaticModel(String name, Vector3 position, double scale, Quaternion rotation) {
        if (rotation == null)
            rotation = new Quaternion(-1,0,0,1);
        try {
            final ColladaStorage storage = new ColladaImporter().load(name);
            Node colladaNode = storage.getScene();
            colladaNode.setRotation(rotation);
            colladaNode.setTranslation(position);
View Full Code Here

        return store;
    }

    public void setRotation(double x, double y, double z) {
        Quaternion rotation = new Quaternion();
        rotation.fromEulerAngles(x, y, z);
        set(rotation);
    }
View Full Code Here

        // Construct our data
        _rotations = new ReadOnlyQuaternion[rotations.length];
        int i = 0;
        for (final ReadOnlyQuaternion q : rotations) {
            _rotations[i++] = new Quaternion(q);
        }
        _translations = new ReadOnlyVector3[translations.length];
        i = 0;
        for (final ReadOnlyVector3 v : translations) {
            _translations[i++] = new Vector3(v);
View Full Code Here

            final ReadOnlyTransform transform = transforms[i];
            if (!transform.isRotationMatrix()) {
                TransformChannel.logger.warning("TransformChannel '" + channelName
                        + "' supplied transform with non-rotational matrices.  May have unexpected results.");
            }
            _rotations[i] = new Quaternion().fromRotationMatrix(transform.getMatrix()).normalizeLocal();
            _translations[i] = new Vector3(transform.getTranslation());
            _scales[i] = new Vector3(transform.getScale());
        }
    }
View Full Code Here

    public Class<? extends TransformData> getClassTag() {
        return this.getClass();
    }

    public void write(final OutputCapsule capsule) throws IOException {
        capsule.write(_rotation, "rotation", new Quaternion(Quaternion.IDENTITY));
        capsule.write(_scale, "scale", new Vector3(Vector3.ONE));
        capsule.write(_translation, "translation", new Vector3(Vector3.ZERO));
    }
View Full Code Here

        capsule.write(_scale, "scale", new Vector3(Vector3.ONE));
        capsule.write(_translation, "translation", new Vector3(Vector3.ZERO));
    }

    public void read(final InputCapsule capsule) throws IOException {
        setRotation((Quaternion) capsule.readSavable("rotation", new Quaternion(Quaternion.IDENTITY)));
        setScale((Vector3) capsule.readSavable("scale", new Vector3(Vector3.ONE)));
        setTranslation((Vector3) capsule.readSavable("rotation", new Vector3(Vector3.ZERO)));
    }
View Full Code Here

        Vector3.releaseTempInstance(store);

        // Orient bone to point along axis formed by start and end points.
        final Matrix3 orient = Matrix3.fetchTempInstance();
        orient.lookAt(endPnt.subtractLocal(stPnt).normalizeLocal(), Vector3.UNIT_Y);
        final Quaternion q = new Quaternion().fromRotationMatrix(orient);
        q.normalizeLocal();
        SkeletalDebugger.bone.setWorldRotation(q);

        // Offset with skin transform
        SkeletalDebugger.bone.setWorldTransform(scene.getWorldTransform().multiply(
                SkeletalDebugger.bone.getWorldTransform(), null));
View Full Code Here

        final IndexMode indexMode = shape.getMeshData().getIndexMode(0);

        final int shapeVertices = shapeBuffer.limit() / 3;
        final Vector3 vector = new Vector3();
        final Vector3 direction = new Vector3();
        final Quaternion rotation = new Quaternion();

        for (int i = 0; i < path.size(); i++) {
            final ReadOnlyVector3 point = path.get(i);
            shapeBuffer.rewind();
            if (shapeNormalBuffer != null) {
                shapeNormalBuffer.rewind();
            }
            int shapeVertice = 0;
            do {
                final ReadOnlyVector3 nextPoint = i < path.size() - 1 ? path.get(i + 1) : closed ? path.get(0) : null;
                final ReadOnlyVector3 lastPoint = i > 0 ? path.get(i - 1) : null;
                if (nextPoint != null) {
                    direction.set(nextPoint).subtractLocal(point);
                } else {
                    direction.set(point).subtractLocal(lastPoint);
                }
                rotation.lookAt(direction, up);

                if (shapeNormalBuffer != null && normals != null) {
                    vector.set(shapeNormalBuffer.get(), shapeNormalBuffer.get(), shapeNormalBuffer.get());
                    rotation.apply(vector, vector);
                    normals.put(vector.getXf());
                    normals.put(vector.getYf());
                    normals.put(vector.getZf());
                }

                vector.set(shapeBuffer.get(), shapeBuffer.get(), shapeBuffer.get());
                rotation.apply(vector, vector);
                vector.addLocal(point);
                vertices.put(vector.getXf());
                vertices.put(vector.getYf());
                vertices.put(vector.getZf());
View Full Code Here

        // matrix. The input box axes are converted to quaternions. The average
        // quaternion is computed, then normalized to unit length. The result is
        // the slerp of the two input quaternions with t-value of 1/2. The
        // result is converted back to a rotation matrix and its columns are
        // selected as the merged box axes.
        final Quaternion kQ0 = Quaternion.fetchTempInstance(), kQ1 = Quaternion.fetchTempInstance();
        kQ0.fromAxes(rkBox0._xAxis, rkBox0._yAxis, rkBox0._zAxis);
        kQ1.fromAxes(rkBox1._xAxis, rkBox1._yAxis, rkBox1._zAxis);

        if (kQ0.dot(kQ1) < 0.0) {
            kQ1.multiplyLocal(-1.0);
        }

        final Quaternion kQ = kQ0.addLocal(kQ1);
        kQ.normalizeLocal();

        final Matrix3 kBoxaxis = kQ.toRotationMatrix(Matrix3.fetchTempInstance());
        final Vector3 newXaxis = kBoxaxis.getColumn(0, Vector3.fetchTempInstance());
        final Vector3 newYaxis = kBoxaxis.getColumn(1, Vector3.fetchTempInstance());
        final Vector3 newZaxis = kBoxaxis.getColumn(2, Vector3.fetchTempInstance());

        // Project the input box vertices onto the merged-box axes. Each axis
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.