Package com.ardor3d.math.type

Examples of com.ardor3d.math.type.ReadOnlyVector3


     * @param to
     *            the destination vector into which to rotate the source vector
     * @return this quaternion for chaining
     */
    public Quaternion fromVectorToVector(final ReadOnlyVector3 from, final ReadOnlyVector3 to) {
        final ReadOnlyVector3 a = from;
        final ReadOnlyVector3 b = to;
        final double factor = a.length() * b.length();
        if (Math.abs(factor) > MathUtils.EPSILON) {
            // Vectors have length > 0
            final Vector3 pivotVector = Vector3.fetchTempInstance();
            try {
                final double dot = a.dot(b) / factor;
View Full Code Here


            return true;
        }
        if (!(o instanceof ReadOnlyVector3)) {
            return false;
        }
        final ReadOnlyVector3 comp = (ReadOnlyVector3) o;
        return getX() == comp.getX() && getY() == comp.getY() && getZ() == comp.getZ();
    }
View Full Code Here

     * @throws NullPointerException
     *             if the plane is null.
     */
    @Override
    public boolean intersectsPlane(final ReadOnlyPlane plane, final Vector3 locationStore) {
        final ReadOnlyVector3 normal = plane.getNormal();
        final double denominator = normal.dot(_direction);

        if (denominator > -MathUtils.EPSILON && denominator < MathUtils.EPSILON) {
            return false; // coplanar
        }

        final double numerator = -normal.dot(_origin) + plane.getConstant();
        final double ratio = numerator / denominator;

        if (ratio < MathUtils.EPSILON) {
            return false; // intersects behind _origin
        }
View Full Code Here

        if (normalsMode != NormalsMode.Off) {
            final ContextCapabilities caps = context.getCapabilities();
            switch (normalsMode) {
                case NormalizeIfScaled:
                    if (worldTransform.isRotationMatrix()) {
                        final ReadOnlyVector3 scale = worldTransform.getScale();
                        if (!(scale.getX() == 1.0 && scale.getY() == 1.0 && scale.getZ() == 1.0)) {
                            if (scale.getX() == scale.getY() && scale.getY() == scale.getZ()
                                    && caps.isOpenGL1_2Supported()
                                    && rendRecord.getNormalMode() != GL12.GL_RESCALE_NORMAL) {
                                if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                                    GL11.glDisable(GL11.GL_NORMALIZE);
                                }
View Full Code Here

    public void startWalk(final Ray3 walkRay) {
        // store ray
        _walkRay.set(walkRay);

        // simplify access to direction
        final ReadOnlyVector3 direction = _walkRay.getDirection();

        // Move start point to grid space
        final Vector3 start = _walkRay.getOrigin().subtract(_gridOrigin, null);

        _gridLocation[0] = (int) MathUtils.floor(start.getX() / _gridSpacing.getX());
        _gridLocation[1] = (int) MathUtils.floor(start.getZ() / _gridSpacing.getZ());

        final double invDirX = 1.0 / direction.getX();
        final double invDirZ = 1.0 / direction.getZ();

        // Check which direction on the X world axis we are moving.
        if (direction.getX() > BresenhamYUpGridTracer.TOLERANCE) {
            _distToNextXIntersection = ((_gridLocation[0] + 1) * _gridSpacing.getX() - start.getX()) * invDirX;
            _distBetweenXIntersections = _gridSpacing.getX() * invDirX;
            _stepXDirection = 1;
        } else if (direction.getX() < -BresenhamYUpGridTracer.TOLERANCE) {
            _distToNextXIntersection = (start.getX() - _gridLocation[0] * _gridSpacing.getX()) * -direction.getX();
            _distBetweenXIntersections = -_gridSpacing.getX() * invDirX;
            _stepXDirection = -1;
        } else {
            _distToNextXIntersection = Double.MAX_VALUE;
            _distBetweenXIntersections = Double.MAX_VALUE;
            _stepXDirection = 0;
        }

        // Check which direction on the Z world axis we are moving.
        if (direction.getZ() > BresenhamYUpGridTracer.TOLERANCE) {
            _distToNextZIntersection = ((_gridLocation[1] + 1) * _gridSpacing.getZ() - start.getZ()) * invDirZ;
            _distBetweenZIntersections = _gridSpacing.getZ() * invDirZ;
            _stepZDirection = 1;
        } else if (direction.getZ() < -BresenhamYUpGridTracer.TOLERANCE) {
            _distToNextZIntersection = (start.getZ() - _gridLocation[1] * _gridSpacing.getZ()) * -direction.getZ();
            _distBetweenZIntersections = -_gridSpacing.getZ() * invDirZ;
            _stepZDirection = -1;
        } else {
            _distToNextZIntersection = Double.MAX_VALUE;
            _distBetweenZIntersections = Double.MAX_VALUE;
View Full Code Here

    public void startWalk(final Ray3 walkRay) {
        // store ray
        _walkRay.set(walkRay);

        // simplify access to direction
        final ReadOnlyVector3 direction = _walkRay.getDirection();

        // Move start point to grid space
        final Vector3 start = _walkRay.getOrigin().subtract(_gridOrigin, null);

        _gridLocation[0] = (int) MathUtils.floor(start.getX() / _gridSpacing.getX());
        _gridLocation[1] = (int) MathUtils.floor(start.getY() / _gridSpacing.getY());

        final double invDirX = 1.0 / direction.getX();
        final double invDirY = 1.0 / direction.getY();

        // Check which direction on the X world axis we are moving.
        if (direction.getX() > BresenhamZUpGridTracer.TOLERANCE) {
            _distToNextXIntersection = ((_gridLocation[0] + 1) * _gridSpacing.getX() - start.getX()) * invDirX;
            _distBetweenXIntersections = _gridSpacing.getX() * invDirX;
            _stepXDirection = 1;
        } else if (direction.getX() < -BresenhamZUpGridTracer.TOLERANCE) {
            _distToNextXIntersection = (start.getX() - _gridLocation[0] * _gridSpacing.getX()) * -direction.getX();
            _distBetweenXIntersections = -_gridSpacing.getX() * invDirX;
            _stepXDirection = -1;
        } else {
            _distToNextXIntersection = Double.MAX_VALUE;
            _distBetweenXIntersections = Double.MAX_VALUE;
            _stepXDirection = 0;
        }

        // Check which direction on the Y world axis we are moving.
        if (direction.getY() > BresenhamZUpGridTracer.TOLERANCE) {
            _distToNextYIntersection = ((_gridLocation[1] + 1) * _gridSpacing.getY() - start.getY()) * invDirY;
            _distBetweenYIntersections = _gridSpacing.getY() * invDirY;
            _stepYDirection = 1;
        } else if (direction.getY() < -BresenhamZUpGridTracer.TOLERANCE) {
            _distToNextYIntersection = (start.getY() - _gridLocation[1] * _gridSpacing.getY()) * -direction.getY();
            _distBetweenYIntersections = -_gridSpacing.getY() * invDirY;
            _stepYDirection = -1;
        } else {
            _distToNextYIntersection = Double.MAX_VALUE;
            _distBetweenYIntersections = Double.MAX_VALUE;
View Full Code Here

        switch (light.getType()) {
            case Directional: {
                final DirectionalLight dirLight = (DirectionalLight) light;

                final ReadOnlyVector3 direction = dirLight.getDirection();
                setPosition(index, record, -direction.getXf(), -direction.getYf(), -direction.getZf(), 0, lr);
                break;
            }
            case Point:
            case Spot: {
                final PointLight pointLight = (PointLight) light;
                final ReadOnlyVector3 location = pointLight.getLocation();
                setPosition(index, record, location.getXf(), location.getYf(), location.getZf(), 1, lr);
                break;
            }
        }

        if (light.getType() == Light.Type.Spot) {
            final SpotLight spot = (SpotLight) light;
            setSpotCutoff(index, record, spot.getAngle(), lr);
            final ReadOnlyVector3 direction = spot.getDirection();
            setSpotDirection(index, record, direction.getXf(), direction.getYf(), direction.getZf(), 0);
            setSpotExponent(index, record, spot.getExponent(), lr);
        } else {
            // set the cutoff to 180, which causes the other spot params to be
            // ignored.
            setSpotCutoff(index, record, 180, lr);
View Full Code Here

        final Vector3 vector = new Vector3();
        final Vector3 direction = new Vector3();
        final Quaternion rotation = new Quaternion();

        for (int i = 0; i < path.size(); i++) {
            final ReadOnlyVector3 point = path.get(i);
            shapeBuffer.rewind();
            if (shapeNormalBuffer != null) {
                shapeNormalBuffer.rewind();
            }
            int shapeVertice = 0;
            do {
                final ReadOnlyVector3 nextPoint = i < path.size() - 1 ? path.get(i + 1) : closed ? path.get(0) : null;
                final ReadOnlyVector3 lastPoint = i > 0 ? path.get(i - 1) : null;
                if (nextPoint != null) {
                    direction.set(nextPoint).subtractLocal(point);
                } else {
                    direction.set(point).subtractLocal(lastPoint);
                }
View Full Code Here

        final double x[] = new double[np]; // x-coordinates of nodes

        final List<ReadOnlyVector3> path = new ArrayList<ReadOnlyVector3>();

        for (int i = 0; i < np; i++) {
            ReadOnlyVector3 p;
            if (!closed) {
                p = points.get(i);
            } else {
                if (i == 0) {
                    p = points.get(points.size() - 1);
                } else if (i >= np - 2) {
                    p = points.get(i - np + 2);
                } else {
                    p = points.get(i - 1);
                }
            }
            x[i] = i;
            d[0][i] = p.getX();
            d[1][i] = p.getY();
            d[2][i] = p.getZ();
        }

        if (np > 1) {
            final double[][] a = new double[3][np];
            final double h[] = new double[np];
View Full Code Here

     *
     * @param sceneBounds
     *            the scene bounds
     */
    public void pack(final BoundingVolume sceneBounds) {
        final ReadOnlyVector3 center = sceneBounds.getCenter();
        for (int i = 0; i < _corners.length; i++) {
            _corners[i].set(center);
        }

        if (sceneBounds instanceof BoundingBox) {
View Full Code Here

TOP

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

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.