rsMesh.h revision ba4aa5c768a498bc3fbb8cb5547b7a9ad6f4b771
1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_RS_MESH_H 18#define ANDROID_RS_MESH_H 19 20 21#include "RenderScript.h" 22 23// --------------------------------------------------------------------------- 24namespace android { 25namespace renderscript { 26 27 28// An element is a group of Components that occupies one cell in a structure. 29class Mesh : public ObjectBase 30{ 31public: 32 Mesh(Context *); 33 ~Mesh(); 34 35 // Contains vertex data 36 // Position, normal, texcoord, etc could either be strided in one allocation 37 // of provided separetely in multiple ones 38 ObjectBaseRef<Allocation> *mVertexBuffers; 39 uint32_t mVertexBufferCount; 40 41 // Either mIndexBuffer, mPrimitiveBuffer or both could have a NULL reference 42 // If both are null, mPrimitive only would be used to render the mesh 43 struct Primitive_t 44 { 45 ObjectBaseRef<Allocation> mIndexBuffer; 46 47 RsPrimitive mPrimitive; 48 uint32_t mGLPrimitive; 49 }; 50 51 Primitive_t ** mPrimitives; 52 uint32_t mPrimitivesCount; 53 54 void render(Context *) const; 55 void renderPrimitive(Context *, uint32_t primIndex) const; 56 void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const; 57 void uploadAll(Context *); 58 void updateGLPrimitives(); 59 60 virtual void serialize(OStream *stream) const; 61 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } 62 static Mesh *createFromStream(Context *rsc, IStream *stream); 63 64 // Bounding volumes 65 float mBBoxMin[3]; 66 float mBBoxMax[3]; 67 void computeBBox(); 68 69protected: 70}; 71 72class MeshContext 73{ 74public: 75 MeshContext(); 76 ~MeshContext(); 77 78}; 79 80 81} 82} 83#endif //ANDROID_RS_TRIANGLE_MESH_H 84 85 86 87