Package com.jme3.scene.mesh

Examples of com.jme3.scene.mesh.IndexBuffer


        Plane up = new Plane();
        up.setPlanePoints(Vector3f.UNIT_X, Vector3f.ZERO, Vector3f.UNIT_Z);
        up.getNormal();
        float minNormalY = (float)Math.cos(Math.abs(maxSlope)/180 * Math.PI);

        IndexBuffer ib = mesh.getIndexBuffer();
        FloatBuffer pb = mesh.getFloatBuffer(Type.Position);
        pb.clear();
        for (int i = 0; i < mesh.getTriangleCount()*3; i+=3){
          total++;
            int i1 = ib.get(i+0);
            int i2 = ib.get(i+1);
            int i3 = ib.get(i+2);
            Vector3f a = new Vector3f();
            Vector3f b = new Vector3f();
            Vector3f c = new Vector3f();
            BufferUtils.populateFromBuffer(a, pb, i1);
            BufferUtils.populateFromBuffer(b, pb, i2);
View Full Code Here


        for(int i=0; i<bu.capacity(); i+=3) {
          p.printf(Locale.ENGLISH,"vn %.4f %.4f %.4f\n", bu.get(), bu.get(), bu.get());
        }
      }
      //indices
      IndexBuffer ib = mesh.getIndexBuffer();
      if(ib != null){
        p.printf(Locale.ENGLISH,"#faces\n");
        switch(mesh.getMode()){
        case Triangles: writeTriangleBuffer(ib,p); break;
        case TriangleStrip:  writeTriangleStripBuffer(ib,p); break;
View Full Code Here

        for(int i=0; i<bu.capacity(); i+=3) {
          p.printf(Locale.ENGLISH,"vn %.4f %.4f %.4f\n", bu.get(), bu.get(), bu.get());
        }
      }
      //indices
      IndexBuffer ib = mesh.getIndexBuffer();
      if(ib != null){
        p.printf(Locale.ENGLISH,"#faces\n");
        switch(mesh.getMode()){
        case Triangles: writeTriangleBuffer(ib,p); break;
        case TriangleStrip:  writeTriangleStripBuffer(ib,p); break;
View Full Code Here

        for(int i=0; i<bu.capacity(); i+=3) {
          p.printf(Locale.ENGLISH,"vn %.4f %.4f %.4f\n", bu.get(), bu.get(), bu.get());
        }
      }
      //indices
      IndexBuffer ib = mesh.getIndexBuffer();
      if(ib != null){
        p.printf(Locale.ENGLISH,"#faces\n");
        switch(mesh.getMode()){
        case Triangles: writeTriangleBuffer(ib,p); break;
        case TriangleStrip:  writeTriangleStripBuffer(ib,p); break;
View Full Code Here

                }

                if (VertexBuffer.Type.Index.ordinal() == bufType) {
                    int components = compsForBuf[bufType];

                    IndexBuffer inIdx = inMesh.getIndicesAsList();
                    IndexBuffer outIdx = outMesh.getIndexBuffer();

                    for (int tri = 0; tri < geomTriCount; tri++) {
                        for (int comp = 0; comp < components; comp++) {
                            int idx = inIdx.get(tri * components + comp) + globalVertIndex;
                            outIdx.put((globalTriIndex + tri) * components + comp, idx);
                        }
                    }
                } else if (VertexBuffer.Type.Position.ordinal() == bufType) {
                    FloatBuffer inPos = (FloatBuffer) inBuf.getData();
                    FloatBuffer outPos = (FloatBuffer) outBuf.getData();
View Full Code Here

        int numVertices = mesh.getVertexCount();
        int vertexStride = 12; //3 verts * 4 bytes per.
        int numTriangles = mesh.getTriangleCount();
        int triangleIndexStride = 12; //3 index entries * 4 bytes each.

        IndexBuffer indices = mesh.getIndicesAsList();
        FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
        vertices.rewind();

        int verticesLength = mesh.getVertexCount() * 3;
        for (int i = 0; i < verticesLength; i++) {
            float tempFloat = vertices.get();
            vertexBase.putFloat(tempFloat);
        }

        int indicesLength = mesh.getTriangleCount() * 3;
        for (int i = 0; i < indicesLength; i++) {
            triangleIndexBase.putInt(indices.get(i));
        }
        vertices.rewind();
        vertices.clear();

        return createTriangleIndexVertexArray(triangleIndexBase, vertexBase, numTriangles, numVertices, vertexStride, triangleIndexStride);
View Full Code Here

            pb.put(0).put(0).put(halfHeight); // top center
            nb.put(0).put(0).put(1 * (inverted ? -1 : 1));
            tb.put(0.5f).put(1);
        }

        IndexBuffer ib = getIndexBuffer();
        int index = 0;
        // Connectivity
        for (int axisCount = 0, axisStart = 0; axisCount < axisSamples - 1; axisCount++) {
            int i0 = axisStart;
            int i1 = i0 + 1;
            axisStart += radialSamples + 1;
            int i2 = axisStart;
            int i3 = i2 + 1;
            for (int i = 0; i < radialSamples; i++) {
                if (closed && axisCount == 0) {
                    if (!inverted) {
                        ib.put(index++, i0++);
                        ib.put(index++, vertCount - 2);
                        ib.put(index++, i1++);
                    } else {
                        ib.put(index++, i0++);
                        ib.put(index++, i1++);
                        ib.put(index++, vertCount - 2);
                    }
                } else if (closed && axisCount == axisSamples - 2) {
                    ib.put(index++, i2++);
                    ib.put(index++, inverted ? vertCount - 1 : i3++);
                    ib.put(index++, inverted ? i3++ : vertCount - 1);
                } else {
                    ib.put(index++, i0++);
                    ib.put(index++, inverted ? i2 : i1);
                    ib.put(index++, inverted ? i1 : i2);
                    ib.put(index++, i1++);
                    ib.put(index++, inverted ? i2++ : i3++);
                    ib.put(index++, inverted ? i3++ : i2++);
                }
            }
        }

        updateBound();
View Full Code Here

        ts.setStitchStrips(stitch);
        ts.setCacheSize(cacheSize);
        ts.setListsOnly(listOnly);
        ts.setMinStripSize(minStripSize);

        IndexBuffer ib = mesh.getIndicesAsList();
        int[] indices = new int[ib.size()];
        for (int i = 0; i < indices.length; i++)
            indices[i] = ib.get(i);

        PrimitiveGroup[] groups = ts.generateStrips(indices);
        Arrays.sort(groups, primComp);

        int numElements = 0;
        for (PrimitiveGroup group : groups)
            numElements += group.numIndices;

        VertexBuffer original = mesh.getBuffer(Type.Index);
        Buffer buf = VertexBuffer.createBuffer(original.getFormat(),
                                               original.getNumComponents(),
                                               numElements);
        original.updateData(buf);
        ib = mesh.getIndexBuffer();

        int curIndex = 0;
        int[] modeStart = new int[]{ -1, -1, -1 };
        int[] elementLengths = new int[groups.length];
        for (int i = 0; i < groups.length; i++){
            PrimitiveGroup group = groups[i];
            elementLengths[i] = group.numIndices;

            if (modeStart[group.type] == -1){
                modeStart[group.type] = i;
            }

            int[] trimmedIndices = group.getTrimmedIndices();
            for (int j = 0; j < trimmedIndices.length; j++){
                ib.put(curIndex + j, trimmedIndices[j]);
            }

            curIndex += group.numIndices;
        }
View Full Code Here

            targetFmt = Format.UnsignedByte;
        }else{
            return;
        }

        IndexBuffer src = mesh.getIndexBuffer();
        Buffer newBuf = VertexBuffer.createBuffer(targetFmt, vb.getNumComponents(), src.size());

        VertexBuffer newVb = new VertexBuffer(Type.Index);
        newVb.setupData(vb.getUsage(), vb.getNumComponents(), targetFmt, newBuf);
        mesh.clearBuffer(Type.Index);
        mesh.setBuffer(newVb);

        IndexBuffer dst = mesh.getIndexBuffer();
        for (int i = 0; i < src.size(); i++){
            dst.put(i, src.get(i));
        }
    }
View Full Code Here

        }

        bihSwapTmp = new float[9];

        FloatBuffer vb = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
        IndexBuffer ib = mesh.getIndexBuffer();
        if (ib == null) {
            ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode());
        } else if (mesh.getMode() != Mode.Triangles) {
            ib = new WrappedIndexBuffer(mesh);
        }

        numTris = ib.size() / 3;
        initTriList(vb, ib);
    }
View Full Code Here

TOP

Related Classes of com.jme3.scene.mesh.IndexBuffer

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.