Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Mesh


            mesh.setMeshData(data);
            return mesh;
        }

        public Mesh getCombinedMesh() {
            final Mesh mesh = getMesh();

            // set our bounding volume using the volume type of our first source found above.
            mesh.setModelBound(volumeType);

            // set the render states from the first mesh
            for (final RenderState state : states.values()) {
                mesh.setRenderState(state);
            }

            return mesh;
        }
View Full Code Here


        public Mesh area;

        public AreaEntry(final int maxSamples, final StatType type) {
            this.maxSamples = maxSamples;

            area = new Mesh("a");
            area.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(maxSamples * 2));
            area.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
            area.getMeshData().setIndexMode(IndexMode.LineStrip);

            area.setDefaultColor(getColorConfig(type, ConfigKeys.Color.name(), new ColorRGBA(ColorRGBA.LIGHT_GRAY)));
View Full Code Here

    protected Mesh getFullScreenQuad() {
        if (_fsq != null) {
            return _fsq;
        }

        _fsq = new Mesh("fsq");
        _fsq.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1));
        _fsq.getMeshData().setTextureBuffer(BufferUtils.createFloatBuffer(0, 0, 1, 0, 1, 1, 0, 1), 0);
        _fsq.getMeshData().setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 1, 2, 3 }, 3));

        _fsq.getSceneHints().setCullHint(CullHint.Never);
View Full Code Here

                for (int i = 0; i < node.getNumberOfChildren(); i++) {
                    PickingUtil.findCollisions(node.getChild(i), scene, results);
                }
            }
        } else if (spatial instanceof Mesh) {
            final Mesh mesh = (Mesh) spatial;

            if (mesh.getWorldBound().intersects(scene.getWorldBound())) {
                if (scene instanceof Node) {
                    final Node parent = (Node) scene;
                    for (int i = 0; i < parent.getNumberOfChildren(); i++) {
                        PickingUtil.findCollisions(mesh, parent.getChild(i), results);
                    }
View Full Code Here

                        return true;
                    }
                }
            }
        } else if (spatial instanceof Mesh) {
            final Mesh mesh = (Mesh) spatial;

            if (mesh.getWorldBound().intersects(scene.getWorldBound())) {
                if (scene instanceof Node) {
                    final Node parent = (Node) scene;
                    for (int i = 0; i < parent.getNumberOfChildren(); i++) {
                        if (PickingUtil.hasCollision(mesh, parent.getChild(i), checkPrimitives)) {
                            return true;
View Full Code Here

    private final boolean prepareForInstancing(final Spatial spatial) {
        boolean skipRenderQueue = false;

        if (spatial instanceof Mesh) {
            final Mesh mesh = (Mesh) spatial;
            final InstancingManager instancing = mesh.getMeshData().getInstancingManager();
            // Only one instance needs to be added to the render queue
            if (instancing != null) {
                skipRenderQueue = instancing.isAddedToRenderQueue();
                instancing.registerMesh(mesh);
            }
View Full Code Here

            return stack.peek();
        }

        final LightCombineMode mode = spat.getSceneHints().getLightCombineMode();

        final Mesh mesh = (Mesh) spat;
        LightState lightState = mesh.getLightState();
        if (lightState == null) {
            lightState = new LightState();
            mesh.setLightState(lightState);
        }

        lightState.detachAll();

        if (mode == LightCombineMode.Replace || (mode != LightCombineMode.Off && stack.size() == 1)) {
View Full Code Here

                // check for one of the two pass types...
                if (renderType != TransparencyType.OnePass) {

                    // get handle to Mesh
                    final Mesh mesh = (Mesh) spatial;

                    // check if we have a Cull state set or enforced. If one is explicitly set and is not Face.None,
                    // we'll not do two-pass transparency.
                    RenderState setState = context.hasEnforcedStates() ? context.getEnforcedState(StateType.Cull)
                            : null;
                    if (setState == null) {
                        setState = mesh.getWorldRenderState(RenderState.StateType.Cull);
                    }

                    // Do the described check.
                    if (setState == null || ((CullState) setState).getCullFace() == Face.None) {

                        // pull any currently enforced cull or zstate. We'll put them back afterwards
                        final RenderState oldCullState = context.getEnforcedState(StateType.Cull);
                        final RenderState oldZState = context.getEnforcedState(StateType.ZBuffer);

                        // enforce our cull and zstate. The zstate is setup to respect depth, but not write to it.
                        context.enforceState(_tranparentCull);
                        context.enforceState(_transparentZBuff);

                        // first render back-facing tris only
                        _tranparentCull.setCullFace(CullState.Face.Front);
                        mesh.draw(renderer);

                        // revert z state
                        context.clearEnforcedState(StateType.ZBuffer);
                        if (oldZState != null) {
                            context.enforceState(oldZState);
                        }

                        // render front-facing tris
                        _tranparentCull.setCullFace(CullState.Face.Back);
                        mesh.draw(renderer);

                        // revert cull state
                        if (oldCullState != null) {
                            context.enforceState(oldCullState);
                        } else {
View Full Code Here

        _deleter = deleter;
    }

    public void visit(final Spatial spatial) {
        if (spatial instanceof Mesh) {
            final Mesh mesh = (Mesh) spatial;
            _deleter.deleteVBOs(mesh.getMeshData().getVertexCoords());
            _deleter.deleteVBOs(mesh.getMeshData().getIndices());
            _deleter.deleteVBOs(mesh.getMeshData().getInterleavedData());
            _deleter.deleteVBOs(mesh.getMeshData().getNormalCoords());
            _deleter.deleteVBOs(mesh.getMeshData().getTangentCoords());
            for (final FloatBufferData coords : mesh.getMeshData().getTextureCoords()) {
                _deleter.deleteVBOs(coords);
            }
            _deleter.deleteVBOs(mesh.getMeshData().getColorCoords());
            _deleter.deleteVBOs(mesh.getMeshData().getFogCoords());
        }
    }
View Full Code Here

        SolidBorder._colors[i + 3] = color.getAlpha() * pAlpha;
    }

    private static Mesh createMesh() {
        // create a triangle strip of 8 triangles.
        final Mesh mesh = new Mesh();
        mesh.getMeshData().setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2));
        mesh.getMeshData().setColorBuffer(BufferUtils.createColorBuffer(8));
        mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip);
        final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(10, 7);
        indices.put(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 });
        mesh.getMeshData().setIndices(indices);

        // set up alpha blending.
        final BlendState blend = new BlendState();
        blend.setBlendEnabled(true);
        blend.setSourceFunction(SourceFunction.SourceAlpha);
        blend.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha);
        mesh.setRenderState(blend);

        // use flat shade so our borders will have a solid color.
        final ShadingState shading = new ShadingState();
        shading.setShadingMode(ShadingMode.Flat);
        mesh.setRenderState(shading);

        mesh.updateWorldRenderStates(false);

        return mesh;
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.Mesh

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.