Package com.ardor3d.bounding

Examples of com.ardor3d.bounding.BoundingBox


        UIComponent.setUseTransparency(true);

        // Add a spinning 3D box to show behind UI.
        final Box box = new Box("Box", new Vector3(0, 0, 0), 5, 5, 5);
        box.setModelBound(new BoundingBox());
        box.setTranslation(new Vector3(0, 0, -15));
        box.addController(new SpatialController<Box>() {
            private final Matrix3 rotate = new Matrix3();
            private double angle = 0;
            private final Vector3 axis = new Vector3(1, 1, 0.5f).normalizeLocal();
View Full Code Here


        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///////////////////
        if (pool.getLevel().getLevelID() == 0) {
            int numOfGrasses = verticesWithGrass.size();

            Mesh grassMesh = new Mesh();
            MeshData grassMeshData = grassMesh.getMeshData();

            FloatBuffer grassVertexBuffer = BufferUtils.createVector3Buffer(numOfGrasses * 4);
            IntBuffer grassIndexBuffer = BufferUtils.createIntBuffer(numOfGrasses * 6);
            FloatBuffer grassNormalBuffer = BufferUtils.createVector3Buffer(numOfGrasses * 4);
            FloatBuffer grassTexCoordBuffer = BufferUtils.createVector2Buffer(numOfGrasses * 4);
            //FloatBuffer grassBasePositionBuffer = BufferUtils.createVector2Buffer(numOfGrasses * 4);
            for (int i=0, size = verticesWithGrass.size(); i<size; i++) {

                int i3 = verticesWithGrass.get(i) * 3;
                int i4 = i * 4;

                float topY = 2.5f + (float) Math.random();
                float bottomY = -0.1f;
                float halfEidth = 1.5f + (float) Math.random();

                //double alpha = Math.random()*Math.PI;
                //float offsetX = (FastMath.sin(alpha) * halfEidth);
                //float offsetZ = (float)(FastMath.cos(alpha) * halfEidth);
                float offsetX = (float)Math.random()-0.5f;
                float offsetZ = (float)Math.random()-0.5f;
                grassVertexBuffer.put(vertexBuffer.get(i3 +0) + offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + bottomY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) + offsetZ);

                grassVertexBuffer.put(vertexBuffer.get(i3 +0) + offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + topY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) + offsetZ);

                grassVertexBuffer.put(vertexBuffer.get(i3 +0) + offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + topY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) + offsetZ);

                grassVertexBuffer.put(vertexBuffer.get(i3 +0) + offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + bottomY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) + offsetZ);
               
                /*grassVertexBuffer.put(vertexBuffer.get(i3 +0) + offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + bottomY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) + offsetZ);

                grassVertexBuffer.put(vertexBuffer.get(i3 +0) + offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + topY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) + offsetZ);

                grassVertexBuffer.put(vertexBuffer.get(i3 +0) - offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + topY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) - offsetZ);

                grassVertexBuffer.put(vertexBuffer.get(i3 +0) - offsetX);
                grassVertexBuffer.put(vertexBuffer.get(i3 +1) + bottomY);
                grassVertexBuffer.put(vertexBuffer.get(i3 +2) - offsetZ);*/

                float nx = normalBuffer.get(i3 +0);
                float ny = normalBuffer.get(i3 +1);
                float nz = normalBuffer.get(i3 +2);

                grassNormalBuffer.put(nx);
                grassNormalBuffer.put(ny);
                grassNormalBuffer.put(nz)
                grassNormalBuffer.put(nx);
                grassNormalBuffer.put(ny);
                grassNormalBuffer.put(nz)
                grassNormalBuffer.put(nx);
                grassNormalBuffer.put(ny);
                grassNormalBuffer.put(nz)
                grassNormalBuffer.put(nx);
                grassNormalBuffer.put(ny);
                grassNormalBuffer.put(nz)


                grassTexCoordBuffer.put(0);
                grassTexCoordBuffer.put(0);
                grassTexCoordBuffer.put(0);
                grassTexCoordBuffer.put(1);
                grassTexCoordBuffer.put(1);
                grassTexCoordBuffer.put(1);
                grassTexCoordBuffer.put(1);
                grassTexCoordBuffer.put(0);

                grassIndexBuffer.put(i4);
                grassIndexBuffer.put(i4+1);
                grassIndexBuffer.put(i4+2);
                grassIndexBuffer.put(i4);
                grassIndexBuffer.put(i4+2);
                grassIndexBuffer.put(i4+3);          
            }

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

            grassMeshData.setVertexBuffer(grassVertexBuffer);
            grassMeshData.setIndexBuffer(grassIndexBuffer);
            grassMeshData.setNormalBuffer(grassNormalBuffer);
            grassMeshData.setTextureBuffer(grassTexCoordBuffer,0);

            grassMesh.setModelBound(new BoundingBox(center, halfSize, halfSize, halfSize));

            block.getGrassNode().attachChild(grassMesh);           
        }
       
 
View Full Code Here

    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

    public Terrain(final Camera camera, final List<TerrainCache> cacheList, final int clipSideSize,
            final TerrainConfiguration terrainConfiguration) {
        _terrainCamera = camera;
        _clipSideSize = clipSideSize;

        _worldBound = new BoundingBox(Vector3.ZERO, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,
                Double.POSITIVE_INFINITY);

        getSceneHints().setRenderBucketType(RenderBucketType.Opaque);
        final CullState cs = new CullState();
        cs.setEnabled(true);
View Full Code Here

    private final Vector3 _boundsCenter = new Vector3();
    private final Vector3 _boundsExtents = new Vector3();

    @Override
    public void updateWorldBound(final boolean recurse) {
        final BoundingBox worldBound = (BoundingBox) _worldBound;
        final Vector3 center = _boundsCenter.set(_terrainCamera.getLocation());
        final double distanceToEdge = _clipSideSize * MathUtils.pow2(_clips.size() - 1) * 0.5;
        final double heightScale = _clips.get(0).getHeightScale();
        final double heightMin = _clips.get(0).getHeightRangeMin() * heightScale;
        final double heightMax = _clips.get(0).getHeightRangeMax() * heightScale;

        final Vector3 extents = _boundsExtents.set(distanceToEdge, (heightMax - heightMin) * 0.5, distanceToEdge);
        worldToLocal(center, center);
        worldBound.setXExtent(extents.getX());
        worldBound.setYExtent(extents.getY());
        worldBound.setZExtent(extents.getZ());
        worldBound.setCenter(center.getX(), (heightMax + heightMin) * 0.5, center.getZ());
        worldBound.transform(_worldTransform, worldBound);
        clearDirty(DirtyType.Bounding);
    }
View Full Code Here

        for (int i = 0; i < _corners.length; i++) {
            _corners[i].set(center);
        }

        if (sceneBounds instanceof BoundingBox) {
            final BoundingBox bbox = (BoundingBox) sceneBounds;
            bbox.getExtent(_extents);
        } else if (sceneBounds instanceof BoundingSphere) {
            final BoundingSphere bsphere = (BoundingSphere) sceneBounds;
            _extents.set(bsphere.getRadius(), bsphere.getRadius(), bsphere.getRadius());
        }
View Full Code Here

        _texture = new Texture2D();

        _imposterQuad = new Quad("ImposterQuad");
        _imposterQuad.resize(1, 1);
        _imposterQuad.setModelBound(new BoundingBox());
        _imposterQuad.getSceneHints().setTextureCombineMode(TextureCombineMode.Replace);
        _imposterQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off);
        super.attachChild(_imposterQuad);

        getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
View Full Code Here

        for (int i = 0; i < _corners.length; i++) {
            _corners[i].set(_center);
        }

        if (worldBound instanceof BoundingBox) {
            final BoundingBox bbox = (BoundingBox) worldBound;
            bbox.getExtent(_extents);
        } else if (worldBound instanceof BoundingSphere) {
            final BoundingSphere bsphere = (BoundingSphere) worldBound;
            _extents.set(bsphere.getRadius(), bsphere.getRadius(), bsphere.getRadius());
        }
View Full Code Here

                }
            }

            // Clone frame 0 as mesh for initial mesh
            final Mesh mesh = meshes[0].makeCopy(false);
            mesh.setModelBound(new BoundingBox());

            // Use resource name for mesh
            mesh.setName(resource.getName());

            // Add controller
View Full Code Here

    private void initExample() {
        // Make a box...
        final Box _box = new Box("Box", Vector3.ZERO, 5, 5, 5);

        // Setup a bounding box for it -- updateModelBound is called automatically internally.
        _box.setModelBound(new BoundingBox());

        // Set its location in space.
        _box.setTranslation(new Vector3(0, 0, -25));

        // Add to root.
View Full Code Here

TOP

Related Classes of com.ardor3d.bounding.BoundingBox

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.