Package com.ardor3d.math

Examples of com.ardor3d.math.Matrix3


        // Add a spinning 3D box to show behind UI.
        final Box box = new Box("Box", new Vector3(0, 0, 0), 5, 5, 5);
        box.setModelBound(new BoundingBox());
        box.setTranslation(new Vector3(0, 0, -15));
        box.addController(new SpatialController<Box>() {
            private final Matrix3 rotate = new Matrix3();
            private double angle = 0;
            private final Vector3 axis = new Vector3(1, 1, 0.5f).normalizeLocal();

            public void update(final double time, final Box caller) {
                angle += time * 50;
                angle %= 360;
                rotate.fromAngleNormalAxis(angle * MathUtils.DEG_TO_RAD, axis);
                caller.setRotation(rotate);
            }
        });
        // Add a texture to the box.
        final TextureState ts = new TextureState();
View Full Code Here


        final Vector3 store = Vector3.fetchTempInstance();
        SkeletalDebugger.bone.setWorldTranslation(stPnt.add(endPnt, store).divideLocal(2.0));
        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
View Full Code Here

    }

    protected void buildAxis() {
        xAxis = new Arrow("_xAxis", length, width);
        xAxis.setDefaultColor(xAxisColor);
        xAxis.setRotation(new Matrix3().fromAngles(0, 0, -90 * MathUtils.DEG_TO_RAD));
        xAxis.setTranslation(length * .5, 0, 0);
        attachChild(xAxis);

        yAxis = new Arrow("yAxis", length, width);
        yAxis.setDefaultColor(yAxisColor);
        yAxis.setTranslation(0, length * .5, 0);
        attachChild(yAxis);

        zAxis = new Arrow("zAxis", length, width);
        zAxis.setDefaultColor(zAxisColor);
        if (rightHanded) {
            zAxis.setRotation(new Matrix3().fromAngles(90 * MathUtils.DEG_TO_RAD, 0, 0));
            zAxis.setTranslation(0, 0, length * .5);
        } else {
            zAxis.setRotation(new Matrix3().fromAngles(-90 * MathUtils.DEG_TO_RAD, 0, 0));
            zAxis.setTranslation(0, 0, -length * .5);
        }
        attachChild(zAxis);
    }
View Full Code Here

        localTranslation.set(_localTransform.getTranslation());
        top.add(bottom, localTranslation).multiplyLocal(.5);

        // rotation that takes us from 0,1,0 to the unit vector described by top/center.
        top.subtract(localTranslation, capsuleUp).normalizeLocal();
        final Matrix3 rotation = Matrix3.fetchTempInstance();
        rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp);
        _localTransform.setRotation(rotation);

        Vector3.releaseTempInstance(localTranslation);
        Vector3.releaseTempInstance(capsuleUp);
        Matrix3.releaseTempInstance(rotation);
View Full Code Here

        _center.multiply(scale, box._center);
        rotate.applyPost(box._center, box._center);
        box._center.addLocal(translate);

        final Matrix3 transMatrix = Matrix3.fetchTempInstance();
        transMatrix.set(rotate);
        // Make the rotation matrix all positive to get the maximum x/y/z extent
        transMatrix.setValue(0, 0, Math.abs(transMatrix.getM00()));
        transMatrix.setValue(0, 1, Math.abs(transMatrix.getM01()));
        transMatrix.setValue(0, 2, Math.abs(transMatrix.getM02()));
        transMatrix.setValue(1, 0, Math.abs(transMatrix.getM10()));
        transMatrix.setValue(1, 1, Math.abs(transMatrix.getM11()));
        transMatrix.setValue(1, 2, Math.abs(transMatrix.getM12()));
        transMatrix.setValue(2, 0, Math.abs(transMatrix.getM20()));
        transMatrix.setValue(2, 1, Math.abs(transMatrix.getM21()));
        transMatrix.setValue(2, 2, Math.abs(transMatrix.getM22()));

        _compVect1.set(getXExtent() * scale.getX(), getYExtent() * scale.getY(), getZExtent() * scale.getZ());
        transMatrix.applyPost(_compVect1, _compVect1);
        // Assign the biggest rotations after scales.
        box.setXExtent(Math.abs(_compVect1.getX()));
        box.setYExtent(Math.abs(_compVect1.getY()));
        box.setZExtent(Math.abs(_compVect1.getZ()));

View Full Code Here

        }

        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
        // D[i] containing the current center C has a minimum projected value
        // pmin[i] and a maximum projected value pmax[i]. The corresponding end
        // points on the axes are C+pmin[i]*D[i] and C+pmax[i]*D[i]. The point C
View Full Code Here

        if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) {
            return false;
        }

        _compVect1.set(bs.getCenter()).subtractLocal(_center);
        final Matrix3 tempMa = Matrix3.fetchTempInstance().fromAxes(_xAxis, _yAxis, _zAxis);

        tempMa.applyPost(_compVect1, _compVect1);

        boolean result = false;
        if (Math.abs(_compVect1.getX()) < bs.getRadius() + _extent.getX()
                && Math.abs(_compVect1.getY()) < bs.getRadius() + _extent.getY()
                && Math.abs(_compVect1.getZ()) < bs.getRadius() + _extent.getZ()) {
View Full Code Here

        getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        setFontScale(fontSize);
        setAutoFade(AutoFade.Off);
        setAutoScale(AutoScale.Off);
        setAutoRotate(false);
        setRotation(new Matrix3().fromAngles(-MathUtils.HALF_PI, 0, 0));

        final ZBufferState zState = new ZBufferState();
        zState.setEnabled(false);
        zState.setWritable(false);
        setRenderState(zState);
View Full Code Here

        // Skybox consists of 6 sides
        _skyboxQuads = new Quad[6];

        // Create each of the quads
        _skyboxQuads[Face.North.ordinal()] = new Quad("north", _xExtent * 2, _yExtent * 2);
        _skyboxQuads[Face.North.ordinal()].setRotation(new Matrix3().fromAngles(0, Math.toRadians(180), 0));
        _skyboxQuads[Face.North.ordinal()].setTranslation(new Vector3(0, 0, _zExtent));
        _skyboxQuads[Face.South.ordinal()] = new Quad("south", _xExtent * 2, _yExtent * 2);
        _skyboxQuads[Face.South.ordinal()].setTranslation(new Vector3(0, 0, -_zExtent));
        _skyboxQuads[Face.East.ordinal()] = new Quad("east", _zExtent * 2, _yExtent * 2);
        _skyboxQuads[Face.East.ordinal()].setRotation(new Matrix3().fromAngles(0, Math.toRadians(90), 0));
        _skyboxQuads[Face.East.ordinal()].setTranslation(new Vector3(-_xExtent, 0, 0));
        _skyboxQuads[Face.West.ordinal()] = new Quad("west", _zExtent * 2, _yExtent * 2);
        _skyboxQuads[Face.West.ordinal()].setRotation(new Matrix3().fromAngles(0, Math.toRadians(270), 0));
        _skyboxQuads[Face.West.ordinal()].setTranslation(new Vector3(_xExtent, 0, 0));
        _skyboxQuads[Face.Up.ordinal()] = new Quad("up", _xExtent * 2, _zExtent * 2);
        _skyboxQuads[Face.Up.ordinal()]
                .setRotation(new Matrix3().fromAngles(Math.toRadians(90), Math.toRadians(270), 0));
        _skyboxQuads[Face.Up.ordinal()].setTranslation(new Vector3(0, _yExtent, 0));
        _skyboxQuads[Face.Down.ordinal()] = new Quad("down", _xExtent * 2, _zExtent * 2);
        _skyboxQuads[Face.Down.ordinal()].setRotation(new Matrix3().fromAngles(Math.toRadians(270),
                Math.toRadians(270), 0));
        _skyboxQuads[Face.Down.ordinal()].setTranslation(new Vector3(0, -_yExtent, 0));

        // We don't want the light to effect our skybox
        getSceneHints().setLightCombineMode(LightCombineMode.Off);
View Full Code Here

        if (null == caller) {
            throw new IllegalArgumentException("caller can not be null!");
        }

        final Vector3 interpolated = Vector3.fetchTempInstance();
        final Matrix3 rotation = Matrix3.fetchTempInstance();

        _curveController.interpolateVectors(_curveController.getControlFrom(), _curveController.getControlTo(),
                _curveController.getDelta(), interpolated);

        MathUtils.matrixLookAt(_previous, interpolated, _worldUp, rotation);
View Full Code Here

TOP

Related Classes of com.ardor3d.math.Matrix3

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.