Package com.ardor3d.math

Examples of com.ardor3d.math.Transform


        final Spatial picked = (Spatial) _results.getPickData(0).getTarget();
        if (picked != null && picked.getParent() instanceof InteractArrow) {
            final InteractArrow arrow = (InteractArrow) picked.getParent();
            _lastArrow = arrow;
            final Vector3 loc = getNewOffset(arrow, oldMouse, current, camera, manager);
            final Transform transform = manager.getSpatialState().getTransform();
            transform.setTranslation(loc.addLocal(transform.getTranslation()));

            // apply our filters, if any, now that we've made updates.
            applyFilters(manager);
        }
    }
View Full Code Here


        // act on drag
        final Spatial picked = (Spatial) _results.getPickData(0).getTarget();
        if (picked != null) {
            final Vector3 loc = getNewOffset(oldMouse, current, camera, manager);
            final Transform transform = manager.getSpatialState().getTransform();
            transform.setTranslation(loc.addLocal(transform.getTranslation()));

            // apply our filters, if any, now that we've made updates.
            applyFilters(manager);
        }
    }
View Full Code Here

                    new Vector3[] { _calcVec3A, _calcVec3B, _calcVec3C });
            picked.localToWorld(_calcVec3A, _calcVec3A);
            picked.localToWorld(_calcVec3B, _calcVec3B);
            picked.localToWorld(_calcVec3C, _calcVec3C);
            final Vector3 loc = getNewOffset(oldMouse, current, camera, manager);
            final Transform transform = manager.getSpatialState().getTransform();
            transform.setTranslation(loc.addLocal(transform.getTranslation()));

            // apply our filters, if any, now that we've made updates.
            applyFilters(manager);
        }
    }
View Full Code Here

        final Spatial picked = (Spatial) _results.getPickData(0).getTarget();
        if (picked instanceof InteractRing) {
            final InteractRing ring = (InteractRing) picked;
            _lastRing = ring;
            final ReadOnlyQuaternion rot = getNewAxisRotation(ring, oldMouse, current, camera, manager);
            final Transform transform = manager.getSpatialState().getTransform();
            rot.toRotationMatrix(_calcMat3).multiply(transform.getMatrix(), _calcMat3);
            transform.setRotation(_calcMat3);

            // apply our filters, if any, now that we've made updates.
            applyFilters(manager);
        }
    }
View Full Code Here

        final ReadOnlyTransform neckBindGlobalTransform = inverseNeckBindGlobalTransform.invert(calcTrans1);

        calcQuat1.fromRotationMatrix(neckBindGlobalTransform.getMatrix());
        calcQuat1.slerpLocal(calcQuat1, rotation, 1);

        final Transform subTransform = calcTrans2.setIdentity();
        subTransform.setRotation(calcQuat1);

        // Calculate a global version of that transform, as if it were attached to the neck
        final Transform subGlobal = neckBindGlobalTransform.multiply(subTransform, calcTrans3);

        // now remove the global/world transform of the neck's parent bone, leaving us with just the local transform of
        // neck + rotation.
        final Transform local = joints[parentIndex].getInverseBindPose().multiply(subGlobal, calcTrans2);

        // set that as the neck's transform
        transforms[jointIndex].set(local);
    }
View Full Code Here

        ExampleBase.start(PrimitiveSkeletonExample.class);
    }

    @Override
    protected void initExample() {
        final Transform j1Transform = new Transform();
        j1Transform.setTranslation(0, 0, -5);
        j1Transform.invert(j1Transform);
        final Joint j1 = new Joint("j1");
        j1.setInverseBindPose(j1Transform);
        j1.setParentIndex(Joint.NO_PARENT);

        final Transform j2Transform = new Transform();
        j2Transform.setTranslation(0, 0, 5);
        j2Transform.invert(j2Transform);
        final Joint j2 = new Joint("j2");
        j2.setInverseBindPose(j2Transform);
        j2.setParentIndex((short) 0);

        final Skeleton sk = new Skeleton("arm sk", new Joint[] { j1, j2 });
View Full Code Here

        if (runAnimation) {
            angle += timer.getTimePerFrame() * 50;
            angle %= 360;

            // move the end of the arm up and down.
            final Transform t1 = pose1.getLocalJointTransforms()[1];
            t1.setTranslation(t1.getTranslation().getX(), Math.sin(angle * MathUtils.DEG_TO_RAD) * 2, t1
                    .getTranslation().getZ());

            final Transform t2 = pose2.getLocalJointTransforms()[1];
            t2.setTranslation(t2.getTranslation().getX(), Math.cos(angle * MathUtils.DEG_TO_RAD) * 2, t2
                    .getTranslation().getZ());

            pose1.updateTransforms();
            pose2.updateTransforms();

View Full Code Here

    }

    private void addParticles(final SkinnedMesh mesh) {
        // find location of fist
        final SkeletonPose pose = mesh.getCurrentPose();
        final Transform loc = mesh.getWorldTransform().multiply(pose.getGlobalJointTransforms()[15], null);

        // Spawn a short lived explosion
        final ParticleSystem explosion = ParticleFactory.buildParticles("big", 80);
        explosion.setEmissionDirection(new Vector3(0.0f, 1.0f, 0.0f));
        explosion.setMaximumAngle(MathUtils.PI);
View Full Code Here

            ex1.printStackTrace();
        }

        // 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);
        // set transparency
        oval.setCompositeOverride(AbstractAwtElement.makeAlphaComposite(.75f));
        awtTextureSource.getProvider().addElement(oval);

        // add an image element to test.
        t = new Transform();
        t.setScale(2.0);
        t.translate(-250, 150, 0);
        addBubble(t);

        // Setup labels for presenting example info.
        final Node textNodes = new Node("Text");
        _root.attachChild(textNodes);
        textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);

        final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2;
        for (int i = 0; i < _exampleInfo.length; i++) {
            _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
            _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0));
            textNodes.attachChild(_exampleInfo[i]);
        }

        textNodes.updateGeometricState(0.0);
        updateText();

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                updateTerrain = !updateTerrain;
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(5);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(50);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(200);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(1000);
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                groundCamera = !groundCamera;
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                terrain.getTextureClipmap().setShowDebug(!terrain.getTextureClipmap().isShowDebug());
                terrain.reloadShader();
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                terrain.reloadShader();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                for (final TextureClipmap clipmap : terrain.getTextureClipmaps()) {
                    clipmap.setScale(terrain.getTextureClipmap().getScale() / 2);
                }
                terrain.reloadShader();
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                for (final TextureClipmap clipmap : terrain.getTextureClipmaps()) {
                    clipmap.setScale(terrain.getTextureClipmap().getScale() * 2);
                }
                terrain.reloadShader();
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final Camera camera = _canvas.getCanvasRenderer().getCamera();
                camera.setLocation(-5000, 500, -5000);
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final Camera camera = _canvas.getCanvasRenderer().getCamera();
                camera.setLocation(5000, 500, 5000);
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final Camera camera = _canvas.getCanvasRenderer().getCamera();
                camera.setLocation(camera.getLocation().getX(), camera.getLocation().getY(), camera.getLocation()
                        .getZ() + 1500.0);
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final Transform t = new Transform();
                t.setScale(MathUtils.nextRandomDouble() * 4.9 + 0.1);
                t.translate(MathUtils.nextRandomDouble() * 500 - 250, MathUtils.nextRandomDouble() * 500 - 250, 0);
                addBubble(t);
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
View Full Code Here

        // Calculate a rotation to go from one direction to the other and set that rotation on a blank transform.
        calcQuat1.fromVectorToVector(forwardDirection, cameraDirection);
        calcQuat1.slerpLocal(Quaternion.IDENTITY, calcQuat1, targetStrength);

        final Transform subTransform = calcTrans2.setIdentity();
        subTransform.setRotation(calcQuat1);

        // Calculate a global version of that transform, as if it were attached to the neck
        final Transform subGlobal = neckBindGlobalTransform.multiply(subTransform, calcTrans3);

        // now remove the global/world transform of the neck's parent bone, leaving us with just the local transform of
        // neck + rotation.
        final Transform local = joints[parentIndex].getInverseBindPose().multiply(subGlobal, calcTrans2);

        // set that as the neck's transform
        transforms[jointIndex].set(local);
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.math.Transform

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.