Package com.ardor3d.math

Examples of com.ardor3d.math.Vector3


        set(source);
    }

    public Vector3 applyPost(final ReadOnlyVector3 vector, Vector3 store) {
        if (store == null) {
            store = new Vector3();
        }

        final double x = vector.getX();
        final double y = vector.getY();
        final double z = vector.getZ();
View Full Code Here


        setM33(1.0);

    }

    public Vector3 getTranslation() {
        return new Vector3(getM03(), getM13(), getM23());
    }
View Full Code Here

 
    private final FszMatrix4 transform;
   
    public float getDensity(final ReadOnlyVector3 p, LayerBlock layerBlock, int x, int y, int z, DetailLevel level) {

        Vector3 temp = transform.applyPost(p, null);
       
        double fox = Math.abs(temp.getX() / outerHalfSizeX);
        double foy = Math.abs(temp.getY() / outerHalfSizeY);
        double foz = Math.abs(temp.getZ() / outerHalfSizeZ);
       
        double fix = Math.abs(temp.getX() / innerHalfSizeX);
        double fiy = Math.abs(temp.getY() / innerHalfSizeY);
        double fiz = Math.abs(temp.getZ() / innerHalfSizeZ);
       
       
        double fo = 1.0 - (fox > foy ? ( fox > foz ? fox : foz )
                                    : ( foy > foz ? foy : foz ));
       
View Full Code Here

            init();

            status = GeneratorStatus.DENSITY_GENERATION;
           
            DetailLevel level = pool.getLevel();
            Vector3 basePosition = block.getPosition().getAsWorldCoords(level);
            double scale = level.getScale();
            double baseX = basePosition.getX();
            double baseZ = basePosition.getZ();
            float h;
            double xPos, zPos;
            boolean first = true;
           
            int blockSize = VoxelWorld.BLOCK_SIZE;
View Full Code Here

    Box box;
   
    public void initBox(){
           
            // Create a new box centered at (0,0,0) with width/height/depth of size 10.
            box = new Box("Box", new Vector3(0, 0, 0), 5, 5, 5);
            // Set a bounding box for frustum culling.
            box.setModelBound(new BoundingBox());
            // Move the box out from the camera 15 units.
            box.setTranslation(new Vector3(0, 0, 0));
            // Give the box some nice colors.
            box.setSolidColor(ColorRGBA.BLUE);
            // Attach the box to the scenegraph root.
    }
View Full Code Here

   
    private final FszMatrix4 transform;
 
    public float getDensity(final ReadOnlyVector3 p, LayerBlock layerBlock, int x, int y, int z, DetailLevel level ) {

        Vector3 pp = transform.applyPost(p, null);
       
        double fx = Math.abs(pp.getX() / halfSizeX);
        double fy = Math.abs(pp.getY() / halfSizeY);
        double fz = Math.abs(pp.getZ() / halfSizeZ);
       
        double f = fx > fy ? ( fx > fz ? 1.0 - fx : 1.0 - fz )
                           : ( fy > fz ? 1.0 - fy : 1.0 - fz );
       
        return (float)f;
View Full Code Here

    public TerrainConfiguration(final int totalNrClipmapLevels, final int cacheGridSize, final ReadOnlyVector3 scale,
            final float heightRangeMin, final float heightRangeMax, final boolean onlyPositiveQuadrant) {
        this.totalNrClipmapLevels = totalNrClipmapLevels;
        this.cacheGridSize = cacheGridSize;
        this.scale = new Vector3(scale);
        this.heightRangeMin = heightRangeMin;
        this.heightRangeMax = heightRangeMax;
        this.onlyPositiveQuadrant = onlyPositiveQuadrant;
    }
View Full Code Here

     * @return the normal image.
     */
    public static Image constructNormalMap(final float[] heightmap, final int side, final double heightScale,
            final double xGridSpacing, final double zGridSpacing) {
        int x, z;
        final Vector3 n = new Vector3();
        final Vector3 n2 = new Vector3();
        final ByteBuffer data = ByteBuffer.allocateDirect(side * side * 3);
        final Image normalMap = new Image(ImageDataFormat.RGB, PixelDataType.UnsignedByte, side, side, data, null);
        for (z = 0; z < side; ++z) {
            for (x = 0; x < side; ++x) {
                if (x == 0 || z == 0 || x == side - 1 || z == side - 1) {
                    n.set(0, 0, 1);
                } else {
                    // change across "x" from point to our "left" to point on our "right"
                    double dXh = heightmap[z * side + x - 1] - heightmap[z * side + x + 1];
                    if (dXh != 0) {
                        // alter by our height scale
                        dXh *= heightScale;
                        // determine slope of perpendicular line
                        final double slopeX = 2.0 * xGridSpacing / dXh;
                        // now plug into cos(arctan(x)) to get unit length vector
                        n.setX(Math.copySign(1.0 / Math.sqrt(1 + slopeX * slopeX), dXh));
                        n.setY(0);
                        n.setZ(Math.abs(slopeX * n.getX()));
                    } else {
                        n.set(0, 0, 1);
                    }

                    // change across "z" from point "above" us to point "below" us
                    double dZh = heightmap[(z - 1) * side + x] - heightmap[(z + 1) * side + x];
                    if (dZh != 0) {
                        // alter by our height scale
                        dZh *= heightScale;
                        // determine slope of perpendicular line
                        final double slopeZ = 2.0 * zGridSpacing / dZh;
                        // now plug into cos(arctan(x)) to get unit length vector
                        n2.setX(0);
                        n2.setY(Math.copySign(1.0 / Math.sqrt(1 + slopeZ * slopeZ), dZh));
                        n2.setZ(Math.abs(slopeZ * n2.getY()));
                    } else {
                        n2.set(0, 0, 1);
                    }

                    // add together the vectors across X and Z and normalize to get final normal
                    n.addLocal(n2).normalizeLocal();
                }
View Full Code Here

        // 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

        return _stepXDirection == 0 && _stepZDirection == 0;
    }

    @Override
    public Vector3 get3DPoint(final double gridX, final double gridY, final double height, final Vector3 store) {
        final Vector3 rVal = store != null ? store : new Vector3();

        return rVal.set(gridX, height, gridY);
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.math.Vector3

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.