Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.FloatBufferData


    /**
     * Set the basic data for this mesh such as texture coordinates, index mode and our vertex buffer.
     */
    private void initialize() {
        _meshData.setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(4), 2));
        final FloatBuffer tbuf = BufferUtils.createVector2Buffer(4);
        _meshData.setTextureBuffer(tbuf, 0);

        tbuf.put(0).put(1);
        tbuf.put(0).put(0);
View Full Code Here


        FloatBuffer crdBuf = getMeshData().getVertexBuffer();
        if (crdBuf == null || totalVerts != crdBuf.limit() / 3) { // allocate new buffers
            getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(totalVerts * 3));
            getMeshData().setNormalBuffer(BufferUtils.createFloatBuffer(totalVerts * 3));
            getMeshData().setTextureCoords(new FloatBufferData(BufferUtils.createFloatBuffer(totalVerts * 2), 2), 0);
            crdBuf = getMeshData().getVertexBuffer();
        }
        final FloatBuffer nrmBuf = getMeshData().getNormalBuffer();
        final FloatBufferData tc = getMeshData().getTextureCoords(0);
        final FloatBuffer txcBuf = tc.getBuffer();
        calculateVertexData(_tessRings, numPairs, totalVerts, crdBuf, nrmBuf, txcBuf);

        updateModelBound();
    }
View Full Code Here

            final FloatBuffer mmTexs = _morphMesh.getMeshData().getTextureCoords(0).getBuffer();
            mmTexs.clear();
            if (dcTexs == null || dcTexs.capacity() != mmTexs.capacity()) {
                dcTexs = BufferUtils.createFloatBuffer(mmTexs.capacity());
                dcTexs.clear();
                dataCopy.getMeshData().setTextureCoords(new FloatBufferData(dcTexs, 2), 0);
            }

            dcTexs.put(mmTexs);
            dcTexs.flip();
        }
View Full Code Here

    }

    private void setTextureData() {
        if (getMeshData().getTextureCoords(0) == null) {
            final FloatBuffer tex = BufferUtils.createVector2Buffer(trailVertices);
            getMeshData().setTextureCoords(new FloatBufferData(tex, 2), 0);
            for (int i = 0; i < nrTrailSections; i++) {
                tex.put((float) i / nrTrailSections).put(0);
                tex.put((float) i / nrTrailSections).put(1);
            }
        }
View Full Code Here

                meshes[i] = new Mesh(frames[i].name);
                mData = meshes[i].getMeshData();
                mData.setIndexLengths(counts);
                mData.setIndexModes(modes);

                final FloatBufferData verts = new FloatBufferData(vertexCount * 3, 3);
                final FloatBufferData norms = new FloatBufferData(vertexCount * 3, 3);
                final FloatBufferData texs = new FloatBufferData(vertexCount * 3, 2);
                mData.setVertexCoords(verts);
                mData.setNormalCoords(norms);
                mData.setTextureCoords(texs, 0);

                // go through the triangle strips/fans and add them in
                // first the strips
                if (stripIndices.size() != 0) {
                    for (int maxJ = stripIndices.size(), j = 0; j < maxJ; j++) {
                        cmd = commands[stripIndices.get(j)];
                        if (cmd.vertIndices.length < 3) {
                            continue;
                        }

                        addVert(cmd, frame, 0, verts);
                        norms.getBuffer().put(0).put(0).put(0);
                        texs.getBuffer().put(0).put(0);

                        // add strip verts / normals
                        for (int k = 0; k < cmd.vertIndices.length; k++) {
                            addVert(cmd, frame, k, verts);
                            addNormal(cmd, frame, k, norms);
                        }

                        // add strip tex coords
                        texs.getBuffer().put(cmd.texCoords);

                        // if we're not the last strip, add a vert or two for degenerate triangle connector
                        if (j != maxJ - 1) {
                            addVert(cmd, frame, cmd.vertIndices.length - 1, verts);
                            norms.getBuffer().put(0).put(0).put(0);
                            texs.getBuffer().put(0).put(0);
                            if (cmd.vertIndices.length % 2 == 1) {
                                // extra vert to maintain wind order
                                addVert(cmd, frame, cmd.vertIndices.length - 1, verts);
                                norms.getBuffer().put(0).put(0).put(0);
                                texs.getBuffer().put(0).put(0);
                            }
                        }
                    }
                }
                // Now the fans
                // XXX: could add these to the strip instead
                for (final int j : fanIndices) {
                    cmd = commands[j];
                    texs.getBuffer().put(cmd.texCoords[0]).put(cmd.texCoords[1]);
                    addNormal(cmd, frame, 0, norms);
                    addVert(cmd, frame, 0, verts);
                    for (int k = cmd.vertIndices.length; --k >= 1;) {
                        texs.getBuffer().put(cmd.texCoords[k * 2]).put(cmd.texCoords[k * 2 + 1]);
                        addNormal(cmd, frame, k, norms);
                        addVert(cmd, frame, k, verts);
                    }
                }
            }
View Full Code Here

        // we'll use the params from the common technique accessor:
        final int size = _paramCount * numEntries;
        switch (_type) {
            case POSITION:
                _buffer = BufferUtils.createFloatBuffer(size);
                meshData.setVertexCoords(new FloatBufferData(_buffer, _paramCount));
                break;
            case NORMAL:
                _buffer = BufferUtils.createFloatBuffer(size);
                meshData.setNormalCoords(new FloatBufferData(_buffer, _paramCount));
                break;
            case TEXCOORD:
                _buffer = BufferUtils.createFloatBuffer(size);
                meshData.setTextureCoords(new FloatBufferData(_buffer, _paramCount), _texCoord);
                break;
            case COLOR:
                _buffer = BufferUtils.createFloatBuffer(size);
                meshData.setColorCoords(new FloatBufferData(_buffer, _paramCount));
                cache.getParsedVertexColors().put(meshData, _buffer);
                break;
            case TEXTANGENT:
                _buffer = BufferUtils.createFloatBuffer(size);
                meshData.setTangentCoords(new FloatBufferData(_buffer, _paramCount));
                break;
            // case TEXBINORMAL:
            // _buffer = BufferUtils.createFloatBuffer(size);
            // meshData.setTangentBuffer(_buffer);
            // break;
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.FloatBufferData

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.