FileDocCategorySizeDatePackage
Mesh.javaAPI DocAndroid 5.1 API26260Thu Mar 12 22:22:42 GMT 2015android.renderscript

Mesh

public class Mesh extends BaseObj
hide
deprecated
in API 16

This class is a container for geometric data displayed with RenderScript. Internally, a mesh is a collection of allocations that represent vertex data (positions, normals, texture coordinates) and index data such as triangles and lines.

Vertex data could either be interleaved within one allocation that is provided separately, as multiple allocation objects, or done as a combination of both. When a vertex channel name matches an input in the vertex program, RenderScript automatically connects the two together.

Parts of the mesh can be rendered with either explicit index sets or primitive types.

Fields Summary
Allocation[]
mVertexBuffers
Allocation[]
mIndexBuffers
Primitive[]
mPrimitives
Constructors Summary
Mesh(long id, RenderScript rs)

        super(id, rs);
    
Methods Summary
public AllocationgetIndexSetAllocation(int slot)

deprecated
in API 16
param
slot locaton within the list of index set allocation
return
allocation containing primtive index data or null if the index data is not specified explicitly

        return mIndexBuffers[slot];
    
public android.renderscript.Mesh$PrimitivegetPrimitive(int slot)

deprecated
in API 16
param
slot locaiton within the list of index set primitives
return
index set primitive type

        return mPrimitives[slot];
    
public intgetPrimitiveCount()

deprecated
in API 16
return
number of primitives or index sets in the mesh

        if(mIndexBuffers == null) {
            return 0;
        }
        return mIndexBuffers.length;
    
public AllocationgetVertexAllocation(int slot)

deprecated
in API 16
param
slot index in the list of allocations to return
return
vertex data allocation at the given index

        return mVertexBuffers[slot];
    
public intgetVertexAllocationCount()

deprecated
in API 16
return
number of allocations containing vertex data

        if(mVertexBuffers == null) {
            return 0;
        }
        return mVertexBuffers.length;
    
voidupdateFromNative()

        super.updateFromNative();
        int vtxCount = mRS.nMeshGetVertexBufferCount(getID(mRS));
        int idxCount = mRS.nMeshGetIndexCount(getID(mRS));

        long[] vtxIDs = new long[vtxCount];
        long[] idxIDs = new long[idxCount];
        int[] primitives = new int[idxCount];

        mRS.nMeshGetVertices(getID(mRS), vtxIDs, vtxCount);
        mRS.nMeshGetIndices(getID(mRS), idxIDs, primitives, idxCount);

        mVertexBuffers = new Allocation[vtxCount];
        mIndexBuffers = new Allocation[idxCount];
        mPrimitives = new Primitive[idxCount];

        for(int i = 0; i < vtxCount; i ++) {
            if(vtxIDs[i] != 0) {
                mVertexBuffers[i] = new Allocation(vtxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
                mVertexBuffers[i].updateFromNative();
            }
        }

        for(int i = 0; i < idxCount; i ++) {
            if(idxIDs[i] != 0) {
                mIndexBuffers[i] = new Allocation(idxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
                mIndexBuffers[i].updateFromNative();
            }
            mPrimitives[i] = Primitive.values()[primitives[i]];
        }