Package com.ardor3d.math.type

Examples of com.ardor3d.math.type.ReadOnlyMatrix4


            return true;
        }
        if (!(o instanceof ReadOnlyMatrix4)) {
            return false;
        }
        final ReadOnlyMatrix4 comp = (ReadOnlyMatrix4) o;
        if (Math.abs(getM00() - comp.getM00()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM01() - comp.getM01()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM02() - comp.getM02()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM03() - comp.getM03()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM10() - comp.getM10()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM11() - comp.getM11()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM12() - comp.getM12()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM13() - comp.getM13()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM20() - comp.getM20()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM21() - comp.getM21()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM22() - comp.getM22()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM23() - comp.getM23()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM30() - comp.getM30()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM31() - comp.getM31()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM32() - comp.getM32()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        } else if (Math.abs(getM33() - comp.getM33()) > Matrix4.ALLOWED_DEVIANCE) {
            return false;
        }

        return true;
    }
View Full Code Here


            return true;
        }
        if (!(o instanceof ReadOnlyMatrix4)) {
            return false;
        }
        final ReadOnlyMatrix4 comp = (ReadOnlyMatrix4) o;
        if (getM00() != comp.getM00()) {
            return false;
        } else if (getM01() != comp.getM01()) {
            return false;
        } else if (getM02() != comp.getM02()) {
            return false;
        } else if (getM03() != comp.getM03()) {
            return false;
        } else if (getM10() != comp.getM10()) {
            return false;
        } else if (getM11() != comp.getM11()) {
            return false;
        } else if (getM12() != comp.getM12()) {
            return false;
        } else if (getM13() != comp.getM13()) {
            return false;
        } else if (getM20() != comp.getM20()) {
            return false;
        } else if (getM21() != comp.getM21()) {
            return false;
        } else if (getM22() != comp.getM22()) {
            return false;
        } else if (getM23() != comp.getM23()) {
            return false;
        } else if (getM30() != comp.getM30()) {
            return false;
        } else if (getM31() != comp.getM31()) {
            return false;
        } else if (getM32() != comp.getM32()) {
            return false;
        } else if (getM33() != comp.getM33()) {
            return false;
        }

        return true;
    }
View Full Code Here

        // new contents of the ModelView matrix. If you want to update the
        // light's position, you must again specify the light position with a
        // call to glLightfv(GL_LIGHT_POSITION,...).

        // XXX: This is a hack until we get a better lighting model up
        final ReadOnlyMatrix4 modelViewMatrix = Camera.getCurrentCamera().getModelViewMatrix();

        if (!record.isValid() || lr.position.getXf() != positionX || lr.position.getYf() != positionY
                || lr.position.getZf() != positionZ || lr.position.getWf() != positionW
                || !lr.modelViewMatrix.equals(modelViewMatrix)) {
View Full Code Here

        _corners[4].addLocal(-_extents.getX(), _extents.getY(), _extents.getZ());
        _corners[5].addLocal(-_extents.getX(), -_extents.getY(), _extents.getZ());
        _corners[6].addLocal(-_extents.getX(), _extents.getY(), -_extents.getZ());
        _corners[7].addLocal(-_extents.getX(), -_extents.getY(), -_extents.getZ());

        final ReadOnlyMatrix4 mvMatrix = getModelViewMatrix();
        double optimalCameraNear = Double.MAX_VALUE;
        double optimalCameraFar = -Double.MAX_VALUE;
        final Vector4 position = Vector4.fetchTempInstance();
        for (int i = 0; i < _corners.length; i++) {
            position.set(_corners[i].getX(), _corners[i].getY(), _corners[i].getZ(), 1);
            mvMatrix.applyPre(position, position);

            optimalCameraNear = Math.min(-position.getZ(), optimalCameraNear);
            optimalCameraFar = Math.max(-position.getZ(), optimalCameraFar);
        }
        Vector4.releaseTempInstance(position);
View Full Code Here

        Matrix4.releaseTempInstance(texMat);
    }

    public void updateTextureMatrix(final Matrix4 matrixStore) {
        update();
        final ReadOnlyMatrix4 projectorView = getModelViewMatrix();
        final ReadOnlyMatrix4 projectorProjection = getProjectionMatrix();
        matrixStore.set(projectorView).multiplyLocal(projectorProjection).multiplyLocal(BIAS);
    }
View Full Code Here

        // new contents of the ModelView matrix. If you want to update the
        // light's position, you must again specify the light position with a
        // call to glLightfv(GL_LIGHT_POSITION,...).

        // XXX: This is a hack until we get a better lighting model up
        final ReadOnlyMatrix4 modelViewMatrix = Camera.getCurrentCamera().getModelViewMatrix();

        if (!record.isValid() || lr.position.getXf() != positionX || lr.position.getYf() != positionY
                || lr.position.getZf() != positionZ || lr.position.getWf() != positionW
                || !lr.modelViewMatrix.equals(modelViewMatrix)) {
View Full Code Here

    private void modifyProjectionMatrix(final Vector4 clipPlane) {
        // Get the current projection matrix
        projectionMatrix = cam.getProjectionMatrix().toArray(projectionMatrix);

        // Get the inverse transpose of the current modelview matrix
        final ReadOnlyMatrix4 modelViewMatrixInvTrans = tRenderer.getCamera().getModelViewMatrix().invert(tmpMatrix)
                .transposeLocal();
        modelViewMatrixInvTrans.applyPre(clipPlane, clipPlane);

        // Calculate the clip-space corner point opposite the clipping plane
        // as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and
        // transform it into camera space by multiplying it
        // by the inverse of the projection matrix
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;
        double minY = Double.MAX_VALUE;
        double maxY = -Double.MAX_VALUE;
        for (int i = 0; i < nrPoints; i++) {
            if (intersections[i].getX() < minX) {
                minX = intersections[i].getX();
            }
            if (intersections[i].getX() > maxX) {
                maxX = intersections[i].getX();
            }
            if (intersections[i].getY() < minY) {
                minY = intersections[i].getY();
            }
            if (intersections[i].getY() > maxY) {
                maxY = intersections[i].getY();
            }
        }

        // create range matrix
        rangeMatrix.setIdentity();
        rangeMatrix.setM00(maxX - minX);
        rangeMatrix.setM11(maxY - minY);
        rangeMatrix.setM30(minX);
        rangeMatrix.setM31(minY);

        final ReadOnlyMatrix4 modelViewProjectionInverseMatrix = projectorCamera.getModelViewProjectionInverseMatrix();
        rangeMatrix.multiplyLocal(modelViewProjectionInverseMatrix);

        // convert screen coords to homogenous world coords with new range matrix
        source.set(0.5, 0.5);
        getWorldIntersectionHomogenous(0.0, source, rangeMatrix, intersectBottomLeft);
View Full Code Here

        _corners[4].addLocal(-_extents.getX(), _extents.getY(), _extents.getZ());
        _corners[5].addLocal(-_extents.getX(), -_extents.getY(), _extents.getZ());
        _corners[6].addLocal(-_extents.getX(), _extents.getY(), -_extents.getZ());
        _corners[7].addLocal(-_extents.getX(), -_extents.getY(), -_extents.getZ());

        final ReadOnlyMatrix4 mvMatrix = getModelViewMatrix();
        double optimalCameraNear = Double.MAX_VALUE;
        double optimalCameraFar = -Double.MAX_VALUE;
        final Vector4 position = Vector4.fetchTempInstance();
        for (int i = 0; i < _corners.length; i++) {
            position.set(_corners[i].getX(), _corners[i].getY(), _corners[i].getZ(), 1);
            mvMatrix.applyPre(position, position);

            optimalCameraNear = Math.min(-position.getZ(), optimalCameraNear);
            optimalCameraFar = Math.max(-position.getZ(), optimalCameraFar);
        }
        Vector4.releaseTempInstance(position);
View Full Code Here

        double fMinY = Double.POSITIVE_INFINITY;
        double fMaxY = Double.NEGATIVE_INFINITY;
        double fMinZ = Double.POSITIVE_INFINITY;
        double fMaxZ = Double.NEGATIVE_INFINITY;

        final ReadOnlyMatrix4 lightviewproj = shadowCam.getModelViewProjectionMatrix();

        final Vector4 position = Vector4.fetchTempInstance();
        for (final Vector3 frustumCorner : frustumCorners) {
            position.set(frustumCorner.getX(), frustumCorner.getY(), frustumCorner.getZ(), 1);
            lightviewproj.applyPre(position, position);

            position.setX(position.getX() / position.getW());
            position.setY(position.getY() / position.getW());
            position.setZ(position.getZ());
View Full Code Here

TOP

Related Classes of com.ardor3d.math.type.ReadOnlyMatrix4

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.