Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 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 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
| 27 | |
| 28 | // An element is a group of Components that occupies one cell in a structure. |
| 29 | class Mesh : public ObjectBase |
| 30 | { |
| 31 | public: |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 32 | Mesh(Context *); |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 33 | ~Mesh(); |
| 34 | |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 35 | struct Verticies_t |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 36 | { |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 37 | Allocation ** mAllocations; |
| 38 | uint32_t mAllocationCount; |
| 39 | |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 40 | size_t mVertexDataSize; |
| 41 | |
| 42 | size_t mOffsetCoord; |
| 43 | size_t mOffsetTex; |
| 44 | size_t mOffsetNorm; |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 45 | |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 46 | size_t mSizeCoord; |
| 47 | size_t mSizeTex; |
| 48 | size_t mSizeNorm; |
| 49 | |
| 50 | uint32_t mBufferObject; |
| 51 | }; |
| 52 | |
| 53 | struct Primitive_t |
| 54 | { |
| 55 | RsPrimitive mType; |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 56 | Verticies_t *mVerticies; |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 57 | |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 58 | uint32_t mIndexCount; |
| 59 | uint16_t *mIndicies; |
Jason Sams | 7aa4f3a | 2009-07-10 17:32:40 -0700 | [diff] [blame] | 60 | |
| 61 | uint32_t mRestartCounts; |
| 62 | uint16_t *mRestarts; |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 65 | Verticies_t ** mVerticies; |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 66 | uint32_t mVerticiesCount; |
| 67 | |
| 68 | Primitive_t ** mPrimitives; |
| 69 | uint32_t mPrimitivesCount; |
| 70 | |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 71 | void analyzeElement(); |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 72 | virtual void serialize(OStream *stream) const; |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 73 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 74 | static Mesh *createFromStream(Context *rsc, IStream *stream); |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 75 | |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 76 | protected: |
| 77 | }; |
| 78 | |
| 79 | class MeshContext |
| 80 | { |
| 81 | public: |
| 82 | MeshContext(); |
| 83 | ~MeshContext(); |
| 84 | |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | } |
| 89 | } |
| 90 | #endif //ANDROID_RS_TRIANGLE_MESH_H |
| 91 | |
| 92 | |