Package com.ardor3d.math

Examples of com.ardor3d.math.Vector4


    public void setEnvPlaneT(final ReadOnlyVector4 plane) {
        if (plane == null) {
            _envPlaneT = null;
            return;
        } else if (_envPlaneT == null) {
            _envPlaneT = new Vector4(plane);
        } else {
            _envPlaneT.set(plane);
        }
    }
View Full Code Here


    public void setEnvPlaneR(final ReadOnlyVector4 plane) {
        if (plane == null) {
            _envPlaneR = null;
            return;
        } else if (_envPlaneR == null) {
            _envPlaneR = new Vector4(plane);
        } else {
            _envPlaneR.set(plane);
        }
    }
View Full Code Here

    public void setEnvPlaneQ(final ReadOnlyVector4 plane) {
        if (plane == null) {
            _envPlaneQ = null;
            return;
        } else if (_envPlaneQ == null) {
            _envPlaneQ = new Vector4(plane);
        } else {
            _envPlaneQ.set(plane);
        }
    }
View Full Code Here

    public Vector3 getWorldCoordinates(final ReadOnlyVector2 screenPosition, final double zDepth, Vector3 store) {
        if (store == null) {
            store = new Vector3();
        }
        checkInverseModelViewProjection();
        final Vector4 position = Vector4.fetchTempInstance();
        position.set((screenPosition.getX() / getWidth() - _viewPortLeft) / (_viewPortRight - _viewPortLeft) * 2 - 1,
                (screenPosition.getY() / getHeight() - _viewPortBottom) / (_viewPortTop - _viewPortBottom) * 2 - 1,
                zDepth * 2 - 1, 1);
        _modelViewProjectionInverse.applyPre(position, position);
        position.multiplyLocal(1.0 / position.getW());
        store.setX(position.getX());
        store.setY(position.getY());
        store.setZ(position.getZ());

        Vector4.releaseTempInstance(position);
        return store;
    }
View Full Code Here

    public Vector3 getNormalizedDeviceCoordinates(final ReadOnlyVector3 worldPosition, Vector3 store) {
        if (store == null) {
            store = new Vector3();
        }
        checkModelViewProjection();
        final Vector4 position = Vector4.fetchTempInstance();
        position.set(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), 1);
        _modelViewProjection.applyPre(position, position);
        position.multiplyLocal(1.0 / position.getW());
        store.setX(position.getX());
        store.setY(position.getY());
        store.setZ(position.getZ());
        Vector4.releaseTempInstance(position);

        return store;
    }
View Full Code Here

        for (final TransformElement transform : transforms) {
            final double[] array = transform.getArray();
            final TransformElementType type = transform.getType();
            if (type == TransformElementType.Translation) {
                workingMat.setIdentity();
                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)) {
                    logger.warning("transform not currently supported: " + transform.getClass().getCanonicalName());
                }
View Full Code Here

        finalMat.setIdentity();
        for (final Element transform : transforms) {
            final double[] array = _colladaDOMUtil.parseDoubleArray(transform);
            if ("translate".equals(transform.getName())) {
                workingMat.setIdentity();
                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

                waterShader.setUniform("heightFalloffStart", (float) heightFalloffStart);
                waterShader.setUniform("heightFalloffSpeed", (float) heightFalloffSpeed);
            }

            final double heightTotal = clipBias + waterMaxAmplitude - waterPlane.getConstant();
            final Vector4 clipPlane = Vector4.fetchTempInstance();

            if (useReflection) {
                clipPlane.set(waterPlane.getNormal().getX(), waterPlane.getNormal().getY(), waterPlane.getNormal()
                        .getZ(), heightTotal);
                renderReflection(clipPlane);
            }

            if (useRefraction && aboveWater) {
                clipPlane.set(-waterPlane.getNormal().getX(), -waterPlane.getNormal().getY(), -waterPlane.getNormal()
                        .getZ(), -waterPlane.getConstant());
                renderRefraction(clipPlane);
            }
        }
View Full Code Here

        cornerPoint.setY((sign(clipPlane.getY()) + projectionMatrix[9]) / projectionMatrix[5]);
        cornerPoint.setZ(-1.0);
        cornerPoint.setW((1.0 + projectionMatrix[10]) / projectionMatrix[14]);

        // Calculate the scaled plane vector
        final Vector4 scaledPlaneVector = clipPlane.multiply((2.0 / clipPlane.dot(cornerPoint)), cornerPoint);

        // Replace the third row of the projection matrix
        projectionMatrix[2] = scaledPlaneVector.getX();
        projectionMatrix[6] = scaledPlaneVector.getY();
        projectionMatrix[10] = scaledPlaneVector.getZ() + 1.0;
        projectionMatrix[14] = scaledPlaneVector.getW();

        // Load it back into OpenGL
        final Matrix4 newProjectionMatrix = tmpMatrix.fromArray(projectionMatrix);
        tRenderer.getCamera().setProjectionMatrix(newProjectionMatrix);
    }
View Full Code Here

        // point projector at the new intersection point
        projectorCamera.lookAt(planeIntersection, Vector3.UNIT_Y);

        // transform points to projector space
        final ReadOnlyMatrix4 modelViewProjectionMatrix = projectorCamera.getModelViewProjectionMatrix();
        final Vector4 spaceTransformation = new Vector4();
        for (int i = 0; i < nrPoints; i++) {
            spaceTransformation.set(intersections[i].getX(), 0.0, intersections[i].getZ(), 1.0);
            modelViewProjectionMatrix.applyPre(spaceTransformation, spaceTransformation);
            intersections[i].set(spaceTransformation.getX(), spaceTransformation.getY(), 0);
            intersections[i].divideLocal(spaceTransformation.getW());
        }

        // find min/max in projector space
        double minX = Double.MAX_VALUE;
        double maxX = -Double.MAX_VALUE;
View Full Code Here

TOP

Related Classes of com.ardor3d.math.Vector4

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.