Package com.ardor3d.math.type

Examples of com.ardor3d.math.type.ReadOnlyVector3


        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;
            final ReadOnlyVector3 direction = spot.getDirection();
            setSpotCutoff(index, record, spot.getAngle(), lr);
            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


        _zAxis = zAxis;
    }

    @Override
    public void applyFilter(final InteractManager manager) {
        final ReadOnlyVector3 oldScale = manager.getSpatialTarget().getScale();
        final SpatialState state = manager.getSpatialState();
        final ReadOnlyVector3 scale = state.getTransform().getScale();

        state.getTransform().setScale( //
                _xAxis ? scale.getX() : oldScale.getX(), //
                _yAxis ? scale.getY() : oldScale.getY(), //
                _zAxis ? scale.getZ() : oldScale.getZ());
    }
View Full Code Here

    }

    @Override
    public void applyFilter(final InteractManager manager) {
        final SpatialState state = manager.getSpatialState();
        final ReadOnlyVector3 scale = state.getTransform().getScale();
        final double x = MathUtils.clamp(scale.getX(), _minScale.getX(), _maxScale.getX());
        final double y = MathUtils.clamp(scale.getY(), _minScale.getY(), _maxScale.getY());
        final double z = MathUtils.clamp(scale.getZ(), _minScale.getZ(), _maxScale.getZ());

        state.getTransform().setScale(x, y, z);
    }
View Full Code Here

        torus.addController(new SpatialController<PQTorus>() {
            private double currentTime;

            public void update(final double time, final PQTorus caller) {
                currentTime += time * 0.2;
                final ReadOnlyVector3 t = caller.getTranslation();
                caller.setTranslation(Math.sin(currentTime) * 10.0, t.getY(), t.getZ());
            }
        });

        final FloatBuffer color1 = torus.getMeshData().getColorBuffer();
        color1.clear();
View Full Code Here

    }

    @Override
    public void applyFilter(final InteractManager manager) {
        final SpatialState state = manager.getSpatialState();
        final ReadOnlyVector3 trans = state.getTransform().getTranslation();
        final double height = _terrain.getHeightAt(trans.getX(), trans.getZ());
        if (height != trans.getY()) {
            state.getTransform().translate(0, _offsetHeight + height - trans.getY(), 0);
        }
    }
View Full Code Here

            // Add colladaNode to root
            _root.attachChild(colladaNode);

            // Setup camera
            ReadOnlyVector3 upAxis = Vector3.UNIT_Y;
            if (storage.getAssetData().getUpAxis() != null) {
                upAxis = storage.getAssetData().getUpAxis();
            }

            positionCamera(upAxis);
View Full Code Here

    private void positionCamera(final ReadOnlyVector3 upAxis) {
        colladaNode.updateGeometricState(0.0);
        final BoundingVolume bounding = colladaNode.getWorldBound();
        if (bounding != null) {
            final ReadOnlyVector3 center = bounding.getCenter();
            double radius = 0;
            if (bounding instanceof BoundingSphere) {
                radius = ((BoundingSphere) bounding).getRadius();
            } else if (bounding instanceof BoundingBox) {
                final BoundingBox boundingBox = (BoundingBox) bounding;
View Full Code Here

            final SkinData skinData = skinDataList.get(0);
            final SkeletonPose pose = skinData.getPose();

            final double time = timer.getTimeInSeconds();
            ballSphere.setTranslation(Math.sin(time) * 5, Math.cos(time) * 5 + 10, 5);
            final ReadOnlyVector3 ballPos = ballSphere.getTranslation();

            // Neck
            targetJoint(pose, 13, Vector3.UNIT_Z, ballPos, 1.0);

            // Right arm
View Full Code Here

    private void positionCamera() {
        colladaNode.updateGeometricState(0.0);
        final BoundingVolume bounding = colladaNode.getWorldBound();
        if (bounding != null) {
            final ReadOnlyVector3 center = bounding.getCenter();
            double radius = 0;
            if (bounding instanceof BoundingSphere) {
                radius = ((BoundingSphere) bounding).getRadius();
            } else if (bounding instanceof BoundingBox) {
                final BoundingBox boundingBox = (BoundingBox) bounding;
View Full Code Here

            mainCamera.setUp(tmp);
            getWorldTransform().applyInverseVector(mainCamera.getDirection(), tmp);
            mainCamera.setDirection(tmp);
        }

        final ReadOnlyVector3 mainCameraLocation = mainCamera.getLocation();
        if (mainCameraLocation.getY() > 0.0 && mainCameraLocation.getY() < upperBound + mainCamera.getFrustumNear()) {
            mainCamera.setLocation(mainCameraLocation.getX(), upperBound + mainCamera.getFrustumNear(),
                    mainCameraLocation.getZ());
        } else if (mainCameraLocation.getY() < 0.0
                && mainCameraLocation.getY() > -upperBound - mainCamera.getFrustumNear()) {
            mainCamera.setLocation(mainCameraLocation.getX(), -upperBound - mainCamera.getFrustumNear(),
                    mainCameraLocation.getZ());
        }
        mainCamera.calculateFrustum();
        final Vector3[] corners = mainCamera.getCorners();

        int nrPoints = 0;

        // check intersections of frustum connections with upper and lower bound
        final Vector3 tmpStorage = Vector3.fetchTempInstance();
        for (int i = 0; i < 8; i++) {
            final int source = connections[i * 2];
            final int destination = connections[i * 2 + 1];

            if (corners[source].getY() > upperBound && corners[destination].getY() < upperBound
                    || corners[source].getY() < upperBound && corners[destination].getY() > upperBound) {
                getWorldIntersection(upperBound, corners[source], corners[destination], intersections[nrPoints++],
                        tmpStorage);
            }
            if (corners[source].getY() > -upperBound && corners[destination].getY() < -upperBound
                    || corners[source].getY() < -upperBound && corners[destination].getY() > -upperBound) {
                getWorldIntersection(-upperBound, corners[source], corners[destination], intersections[nrPoints++],
                        tmpStorage);
            }
        }
        // check if any of the frustums corner vertices lie between the upper and lower bound planes
        for (int i = 0; i < 8; i++) {
            if (corners[i].getY() < upperBound && corners[i].getY() > -upperBound) {
                intersections[nrPoints++].set(corners[i]);
            }
        }

        if (nrPoints == 0) {
            // No intersection, grid not visible
            return false;
        }

        // set projector
        projectorCamera.set(mainCamera);

        // force the projector to point at the plane
        if (projectorCamera.getLocation().getY() > 0.0 && projectorCamera.getDirection().getY() > 0.0
                || projectorCamera.getLocation().getY() < 0.0 && projectorCamera.getDirection().getY() < 0.0) {
            projectorCamera.setDirection(new Vector3(projectorCamera.getDirection().getX(), -projectorCamera
                    .getDirection().getY(), projectorCamera.getDirection().getZ()));
            projectorCamera.setUp(projectorCamera.getDirection().cross(projectorCamera.getLeft(), null)
                    .normalizeLocal());
        }

        // find the plane intersection point
        source.set(0.5, 0.5);
        getWorldIntersection(0.0, source, projectorCamera.getModelViewProjectionInverseMatrix(), planeIntersection);

        // force the projector to be a certain distance above the plane
        final ReadOnlyVector3 cameraLocation = projectorCamera.getLocation();
        if (cameraLocation.getY() > 0.0 && cameraLocation.getY() < projectorMinHeight * 2) {
            final double delta = (projectorMinHeight * 2 - cameraLocation.getY()) / (projectorMinHeight * 2);

            projectorCamera.setLocation(cameraLocation.getX(), projectorMinHeight * 2 - projectorMinHeight * delta,
                    cameraLocation.getZ());
        } else if (cameraLocation.getY() < 0.0 && cameraLocation.getY() > -projectorMinHeight * 2) {
            final double delta = (-projectorMinHeight * 2 - cameraLocation.getY()) / (-projectorMinHeight * 2);

            projectorCamera.setLocation(cameraLocation.getX(), -projectorMinHeight * 2 + projectorMinHeight * delta,
                    cameraLocation.getZ());
        }

        // restrict the intersection point to be a certain distance from the camera in plane coords
        planeIntersection.subtractLocal(projectorCamera.getLocation());
        planeIntersection.setY(0.0);
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.