diff options
Diffstat (limited to 'libs/rs/rsMesh.h')
-rw-r--r-- | libs/rs/rsMesh.h | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/libs/rs/rsMesh.h b/libs/rs/rsMesh.h index 5201abd..410b70b 100644 --- a/libs/rs/rsMesh.h +++ b/libs/rs/rsMesh.h @@ -26,65 +26,67 @@ namespace renderscript { // An element is a group of Components that occupies one cell in a structure. -class Mesh : public ObjectBase -{ +class Mesh : public ObjectBase { public: Mesh(Context *); ~Mesh(); - struct Verticies_t - { - Allocation ** mAllocations; - uint32_t mAllocationCount; - - size_t mVertexDataSize; - - size_t mOffsetCoord; - size_t mOffsetTex; - size_t mOffsetNorm; - - size_t mSizeCoord; - size_t mSizeTex; - size_t mSizeNorm; - - uint32_t mBufferObject; - }; + // Contains vertex data + // Position, normal, texcoord, etc could either be strided in one allocation + // of provided separetely in multiple ones + ObjectBaseRef<Allocation> *mVertexBuffers; + uint32_t mVertexBufferCount; + // Either mIndexBuffer, mPrimitiveBuffer or both could have a NULL reference + // If both are null, mPrimitive only would be used to render the mesh struct Primitive_t { - RsPrimitive mType; - Verticies_t *mVerticies; - - uint32_t mIndexCount; - uint16_t *mIndicies; + ObjectBaseRef<Allocation> mIndexBuffer; - uint32_t mRestartCounts; - uint16_t *mRestarts; + RsPrimitive mPrimitive; + uint32_t mGLPrimitive; }; - Verticies_t * mVerticies; - uint32_t mVerticiesCount; - Primitive_t ** mPrimitives; uint32_t mPrimitivesCount; + void render(Context *) const; + void renderPrimitive(Context *, uint32_t primIndex) const; + void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const; + void uploadAll(Context *); + void updateGLPrimitives(); + + virtual void serialize(OStream *stream) const; + virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } + static Mesh *createFromStream(Context *rsc, IStream *stream); + + // Bounding volumes + float mBBoxMin[3]; + float mBBoxMax[3]; + void computeBBox(); + void initVertexAttribs(); - void analyzeElement(); protected: + bool isValidGLComponent(const Element *elem, uint32_t fieldIdx); + // Attribues that allow us to map to GL + VertexArray::Attrib *mAttribs; + // This allows us to figure out which allocation the attribute + // belongs to. In the event the allocation is uploaded to GL + // buffer, it lets us properly map it + uint32_t *mAttribAllocationIndex; + uint32_t mAttribCount; }; -class MeshContext -{ +class MeshContext { public: MeshContext(); ~MeshContext(); - }; - } } #endif //ANDROID_RS_TRIANGLE_MESH_H + |