Package com.ardor3d.math

Examples of com.ardor3d.math.Matrix3


        final Texture tex = new Texture2D();

        // Build up our function
        final Function3D primaryJade = new RidgeFunction3D(Functions.simplexNoise(), 6, 2.0, 2.207);
        final Function3D baseSecondaryJade = new CylinderFunction3D(2);
        final Function3D rotatedBaseSecondaryJade = Functions.rotateInput(baseSecondaryJade, new Matrix3().fromAngles(
                0, MathUtils.DEG_TO_RAD * 65, MathUtils.DEG_TO_RAD * 85));
        final Function3D perturbedBaseSecondaryJade = new TurbulenceFunction3D(rotatedBaseSecondaryJade, 1.0 / 4.0, 4,
                4.0);
        final Function3D secondaryJade = Functions.scaleBias(perturbedBaseSecondaryJade, .25, 0);
        final Function3D combinedJade = Functions.add(primaryJade, secondaryJade);
View Full Code Here


        final Torus torus = new Torus("torus", 64, 12, 10.0f, 15.0f);
        torus.setModelBound(new BoundingBox());
        occluders.attachChild(torus);
        torus.addController(new SpatialController<Torus>() {
            double timer = 0;
            Matrix3 rotation = new Matrix3();

            public void update(final double time, final Torus caller) {
                timer += time;
                caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 50.0 + 20.0, Math.cos(timer) * 40.0);
                rotation.fromAngles(timer * 0.4, timer * 0.4, timer * 0.4);
                caller.setRotation(rotation);
            }
        });

        // Attach "billboard" with an alpha test.
View Full Code Here

        // 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

        frame.setUseStandin(false);
        frame.setOpacity(1f);
        frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
        frame.setName("sample");

        final Matrix3 rotate = new Matrix3();
        final Vector3 axis = new Vector3(0, 0, 1).normalizeLocal();
        rotate.fromAngleNormalAxis(45 * MathUtils.DEG_TO_RAD, axis);
        frame.setRotation(rotate);

        hud = new UIHud();
        hud.add(frame);
        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
View Full Code Here

        staticLabel.setLayoutData(BorderLayoutData.CENTER);
        panel.add(staticLabel);

        final UICheckBox rotatingLabel = new UICheckBox("Look at me! :)");
        rotatingLabel.setBackdrop(new SolidBackdrop(ColorRGBA.GREEN));
        rotatingLabel.setRotation(new Matrix3().fromAngleNormalAxis(45 * MathUtils.DEG_TO_RAD, new Vector3(0, 0, 1)));
        panel.add(rotatingLabel);

        final Matrix3 rotate = new Matrix3();
        final Vector3 axis = new Vector3(0, 0, 1);
        rotatingLabel.addController(new SpatialController<UICheckBox>() {
            double angle = 0;

            public void update(final double time, final UICheckBox caller) {
                angle += time * 10;
                angle %= 360;
                rotate.fromAngleNormalAxis(angle * MathUtils.DEG_TO_RAD, axis);
                caller.setRotation(rotate);
                caller.fireComponentDirty();
                panel.layout();
            }
        });
View Full Code Here

                        .getIntersectionPoint(0);
                sphere.setTranslation(intersectionPoint);

                final Vector3 intersectionNormal = pickResults.getPickData(0).getIntersectionRecord()
                        .getIntersectionNormal(0);
                final Matrix3 rotation = new Matrix3();
                rotation.lookAt(intersectionNormal, Vector3.UNIT_Z);
                arrow.setRotation(rotation);
                arrow.setTranslation(intersectionPoint);
            }
        }
    }
View Full Code Here

        }

        // add some shapes
        rectangle = new AwtShapeElement(new Rectangle(400, 50));
        Transform t = new Transform();
        t.setRotation(new Matrix3().fromAngles(0, 0, 45 * MathUtils.DEG_TO_RAD));
        rectangle.setTransform(t);
        awtTextureSource.getProvider().addElement(rectangle);

        oval = new AwtShapeElement(new Ellipse2D.Float(0, 0, 250, 150));
        oval.setFillColor(Color.red);
View Full Code Here

                workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1.0));
                finalMat.multiplyLocal(workingMat);
            } else if (type == TransformElementType.Rotation) {
                if (array[3] != 0) {
                    workingMat.setIdentity();
                    final Matrix3 rotate = new Matrix3().fromAngleAxis(array[3] * MathUtils.DEG_TO_RAD, new Vector3(
                            array[0], array[1], array[2]));
                    workingMat.set(rotate);
                    finalMat.multiplyLocal(workingMat);
                }
            } else if (type == TransformElementType.Scale) {
                workingMat.setIdentity();
                workingMat.scale(new Vector4(array[0], array[1], array[2], 1), workingMat);
                finalMat.multiplyLocal(workingMat);
            } else if (type == TransformElementType.Matrix) {
                workingMat.fromArray(array);
                finalMat.multiplyLocal(workingMat);
            } else if (type == TransformElementType.Lookat) {
                final Vector3 pos = new Vector3(array[0], array[1], array[2]);
                final Vector3 target = new Vector3(array[3], array[4], array[5]);
                final Vector3 up = new Vector3(array[6], array[7], array[8]);
                final Matrix3 rot = new Matrix3();
                rot.lookAt(target.subtractLocal(pos), up);
                workingMat.set(rot);
                workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1.0));
                finalMat.multiplyLocal(workingMat);
            } else {
                if (logger.isLoggable(Level.WARNING)) {
View Full Code Here

                workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1.0));
                finalMat.multiplyLocal(workingMat);
            } else if ("rotate".equals(transform.getName())) {
                if (array[3] != 0) {
                    workingMat.setIdentity();
                    final Matrix3 rotate = new Matrix3().fromAngleAxis(array[3] * MathUtils.DEG_TO_RAD, new Vector3(
                            array[0], array[1], array[2]));
                    workingMat.set(rotate);
                    finalMat.multiplyLocal(workingMat);
                }
            } else if ("scale".equals(transform.getName())) {
                workingMat.setIdentity();
                workingMat.scale(new Vector4(array[0], array[1], array[2], 1), workingMat);
                finalMat.multiplyLocal(workingMat);
            } else if ("matrix".equals(transform.getName())) {
                workingMat.fromArray(array);
                finalMat.multiplyLocal(workingMat);
            } else if ("lookat".equals(transform.getName())) {
                final Vector3 pos = new Vector3(array[0], array[1], array[2]);
                final Vector3 target = new Vector3(array[3], array[4], array[5]);
                final Vector3 up = new Vector3(array[6], array[7], array[8]);
                final Matrix3 rot = new Matrix3();
                rot.lookAt(target.subtractLocal(pos), up);
                workingMat.set(rot);
                workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1));
                finalMat.multiplyLocal(workingMat);
            } else {
                logger.warning("transform not currently supported: " + transform.getClass().getCanonicalName());
View Full Code Here

        final Vector3 pVelocity = particle.getVelocity();
        // determine if the particle is in the inner or outer zone
        final double pDist = particle.getPosition().distanceSquared(_swarmPoint);
        final Vector3 workVect = Vector3.fetchTempInstance();
        final Vector3 workVect2 = Vector3.fetchTempInstance();
        final Matrix3 workMat = Matrix3.fetchTempInstance();
        workVect.set(_swarmPoint).subtractLocal(particle.getPosition()).normalizeLocal();
        workVect2.set(pVelocity).normalizeLocal();
        if (pDist > _swarmRangeSQ) {
            // IN THE OUTER ZONE...
            // Determine if the angle between particle velocity and a vector to
            // the swarmPoint is less than the accepted deviance
            final double angle = workVect.smallestAngleBetween(workVect2);
            if (angle < _deviance) {
                // if it is, increase the speed speedBump over time
                if (pVelocity.lengthSquared() < _maxSpeedSQ) {
                    final double change = _speedBump * dt;
                    workVect2.multiplyLocal(change); // where workVector2 = pVelocity.normalizeLocal()
                    pVelocity.addLocal(workVect2);
                }
            } else {
                final Vector3 axis = workVect2.crossLocal(workVect);
                // if it is not, shift the velocity to bring it back in line
                if ((Double.doubleToLongBits(pVelocity.lengthSquared()) & 0x1d) != 0) {
                    workMat.fromAngleAxis(_turnSpeed * dt, axis);
                } else {
                    workMat.fromAngleAxis(-_turnSpeed * dt, axis);
                }
                workMat.applyPost(pVelocity, pVelocity);
            }
        } else {
            final Vector3 axis = workVect2.crossLocal(workVect);
            // IN THE INNER ZONE...
            // Alter the heading based on how fast we are going
            if ((index & 0x1f) != 0) {
                workMat.fromAngleAxis(_turnSpeed * dt, axis);
            } else {
                workMat.fromAngleAxis(-_turnSpeed * dt, axis);
            }
            workMat.applyPost(pVelocity, pVelocity);
        }
        Vector3.releaseTempInstance(workVect);
        Vector3.releaseTempInstance(workVect2);
        Matrix3.releaseTempInstance(workMat);
    }
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.