Package com.ardor3d.math

Examples of com.ardor3d.math.Vector3


                       
                        vertexBuffer.put(i3+0, voxel.vertexPosition.getXf());
                        vertexBuffer.put(i3+1, voxel.vertexPosition.getYf());
                        vertexBuffer.put(i3+2, voxel.vertexPosition.getZf());

                        Vector3 normal = computeVoxelNormal(x,y,z,voxel.vertexPosition);
                        normalBuffer.put(i3+0, normal.getXf());
                        normalBuffer.put(i3+1, normal.getYf());
                        normalBuffer.put(i3+2, normal.getZf());  
                       
                        int i4 = voxel.index * 4;
                        colorBuffer.put(i4+0, voxel.materials.getXf());
                        colorBuffer.put(i4+1, voxel.materials.getYf());
                        colorBuffer.put(i4+2, voxel.materials.getZf());
                        colorBuffer.put(i4+3, voxel.materials.getWf());
                       
                        ///GRASS 
                        if (voxel.vertexPosition.getY() > 33 && voxel.vertexPosition.getYf() < 210 && normal.getY() > 0.7)
                            verticesWithGrass.add(voxel.index);
                    }
                }
            }
        }

        for (int q = 0; q < quads.size(); q++) {
            Quad quad = quads.get(q);

            indexBuffer.put(quad.voxel1.index);
            indexBuffer.put(quad.voxel2.index);
            indexBuffer.put(quad.voxel3.index);
            indexBuffer.put(quad.voxel1.index);
            indexBuffer.put(quad.voxel3.index);
            indexBuffer.put(quad.voxel4.index);
        }

        indexBuffer.rewind();
        //colorBuffer.flip();

        meshData.setVertexBuffer(vertexBuffer);
        meshData.setIndexBuffer(indexBuffer);
        meshData.setNormalBuffer(normalBuffer);
        meshData.setColorBuffer(colorBuffer);


        // meshData.setColorBuffer(colorBuffer);

        block.numOfTriangles = quads.size()*2;
        block.numOfVertices = voxelCounter;

        Vector3 center = basePosition;
        double halfSize = pool.getLevel().getScale() * VoxelWorld.BLOCK_SIZE / 2.0;
        center.addLocal(halfSize, halfSize, halfSize);
        mesh.setModelBound(new BoundingBox(center, halfSize, halfSize, halfSize));

        block.getVoxelNode().attachChild(mesh);
       
        //////////GRASS///////////////////
View Full Code Here


        setSpeedReflection(0.02);
        setSpeedReflection(-0.01);

        // setting to default value just to show
        this.waterHeight = waterHeight;
        setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), waterHeight));

        // Create a quad to use as geometry for the water.
        waterQuad = new Quad("waterQuad", 1, 1);
        // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as
        // we move this is more convenient than rotating the quad.
View Full Code Here

        quadHalfSize = farPlane;
    }

    public void update(final ReadOnlyTimer timer, Camera camera ) {
        final Vector3 transVec = new Vector3(camera.getLocation().getX(), getWaterHeight(), camera
                .getLocation().getZ());
        setTextureCoords(0, transVec.getX(), -transVec.getZ(), textureScale);
        setVertexCoords(transVec.getXf(), transVec.getYf(), transVec.getZf());
        update(timer.getTimePerFrame());
    }
View Full Code Here

        double scale = level.getScale();
        int blockSize = VoxelWorld.BLOCK_SIZE;

        if (hasBoundingBox()) {
            Vector3 lower = getLowerBound();
            lower.subtractLocal(basePosition);
            Vector3 upper = getUpperBound();
            upper.subtractLocal(basePosition);
            minX = Math.max(0,(int)Math.floor(lower.getX() / scale));
            minY = Math.max(0,(int)Math.floor(lower.getY() / scale));
            minZ = Math.max(0,(int)Math.floor(lower.getZ() / scale));
            maxX = Math.min(blockSize+1,(int)Math.ceil(upper.getX() / scale));
            maxY = Math.min(blockSize+1,(int)Math.ceil(upper.getY() / scale));
            maxZ = Math.min(blockSize+1,(int)Math.ceil(upper.getZ() / scale));
        } else {
            minX = 0;
            minY = 0;
            minZ = 0;
            maxX = blockSize+1;
            maxY = blockSize+1;
            maxZ = blockSize+1;
        }


        Vector3 localPos = new Vector3();

        for (int x =minX; x <= maxX; x++) {
            for (int y = minY; y <= maxY; y++) {
                for (int z = minZ; z <= maxZ; z++) {
                    localPos.set(x*scale,y*scale,z*scale);
                    localPos.addLocal(basePosition);
                    float newDensity = getDensity(localPos, layerBlock, x,y,z,level);
                    if (newDensity >= densities[x][y][z]) {
                        densities[x][y][z] = newDensity;
                        densitySources[x][y][z] = this;
                    }
View Full Code Here

    }

    @Override
    public Vector3 getAsWorldCoords(DetailLevel level) {
        double scale = VoxelWorld.BLOCK_SIZE*level.getScale();
        return new Vector3(x*scale, y*scale, z*scale);
    }
View Full Code Here

        this.z = layerBlockPosition.z;
    }
   
    @Override
    public boolean isInBlock(ReadOnlyVector3 positionInWorldCoords, DetailLevel level) {
        Vector3 blockCornerInWorldCoords = getAsWorldCoords(level);
       
        if (positionInWorldCoords.getX() < blockCornerInWorldCoords.getX()
                || positionInWorldCoords.getY() < blockCornerInWorldCoords.getY()
                || positionInWorldCoords.getZ() < blockCornerInWorldCoords.getZ() )
           
        return false;
       
        double blockSize = VoxelWorld.BLOCK_SIZE * level.getScale();
      
        if (positionInWorldCoords.getX() >= blockCornerInWorldCoords.getX() + blockSize
                || positionInWorldCoords.getY() >= blockCornerInWorldCoords.getY() + blockSize
                || positionInWorldCoords.getZ() >= blockCornerInWorldCoords.getZ() + blockSize)
        return false;
       
        return true;
    }
View Full Code Here

        return terrain.getClipmaps().get(0).getCache().getSubHeight(heightCalc.getXf(), heightCalc.getZf());
    }

    private NominalHeightGenerator heightGenerator = new NominalHeightGenerator();
    private Vector3 getTerrainSurfacePoint(final double x, final double z) {
        return new Vector3(x,heightGenerator.getHeight(x, z),z);
    }
View Full Code Here

    private NominalHeightGenerator heightGenerator = new NominalHeightGenerator();
    private Vector3 getTerrainSurfacePoint(final double x, final double z) {
        return new Vector3(x,heightGenerator.getHeight(x, z),z);
    }
    protected void initCamera(Camera camera) {
        camera.setLocation(new Vector3(0, 1, 0));
        camera.lookAt(new Vector3(1, 1, 1), Vector3.UNIT_Y);
        camera.setFrustumPerspective(70.0, (float) camera.getWidth() / camera.getHeight(), 1.0f, farPlane);
    }
View Full Code Here

        while (counter < 1000) {
            double x = Math.random() * 200.0 - 100.0;
            double y = Math.random() * 200.0 - 100.0;
            double width = Math.random() * 5.0 + 2.0;
            double height = Math.random() * 10.0 + 2.0;
            Vector3 v = getTerrainSurfacePoint(x,y);
            if (v.getY() > 0.0) {
                forest.attachChild(new BillboardTree(v,width,height));
                counter ++;
            }
        }
        root.attachChild(forest);
View Full Code Here

  setDudvMapTextureString("images/water/dudvmap.png");
        setFallbackMapTextureString("images/water/water2.png");
        setFoamMapTextureString("images/water/oceanfoam.png");
       
        this.waterHeight = waterHeight;
        setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), waterHeight));
       
        useFadeToFogColor(true);
       

       
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.