1 /* 2 * Copyright 2006 Sony Computer Entertainment Inc. 3 * 4 * Licensed under the MIT Open Source License, for details please see license.txt or the website 5 * http://www.opensource.org/licenses/mit-license.php 6 * 7 */ 8 9 #ifndef _COLLADA_GEOMETRY_H_ 10 #define _COLLADA_GEOMETRY_H_ 11 12 #include <dae.h> 13 #include <dom/domCOLLADA.h> 14 #include <vector> 15 #include <string> 16 17 #include "rsContext.h" 18 #include "rsMesh.h" 19 #include "SimpleMesh.h" 20 21 using namespace android; 22 using namespace android::renderscript; 23 24 25 class ColladaGeometry { 26 public: 27 ColladaGeometry(); 28 bool init(domGeometryRef geometry); 29 getMesh()30 SimpleMesh *getMesh() { 31 return &mConvertedMesh; 32 } 33 34 private: 35 36 //Store some collada stuff 37 domMesh *mMesh; 38 39 // Cache the pointers to the collada version of the data 40 // This contains raw vertex data that is not necessarily the same size for all 41 // Offset refers to the way collada packs each triangle's index to position / normal / etc. 42 domListOfFloats *mPositionFloats; 43 int mPositionOffset; 44 domListOfFloats *mNormalFloats; 45 int mNormalOffset; 46 domListOfFloats *mTangentFloats; 47 int mTangentOffset; 48 domListOfFloats *mBinormalFloats; 49 int mBinormalOffset; 50 domListOfFloats *mTexture1Floats; 51 int mTexture1Offset; 52 53 // In the list of triangles, collada uses multiple indecies per triangle to point to the correct 54 // index in all the different arrays. We need to know the total number of these guys so we can 55 // just to the next triangle to process 56 int mMultiIndexOffset; 57 58 // All these vectors would contain the same number of "points" 59 // index*stride would properly get to the uv, normal etc. 60 // collada, like maya and many others keep point array, normal array etc 61 // different size in the cases the same vertex produces divergent normals for different faces 62 std::vector<float> *mPositions; 63 unsigned int mPositionsStride; 64 std::vector<float> *mNormals; 65 unsigned int mNormalsStride; 66 std::vector<float> *mTextureCoords; 67 unsigned int mTextureCoordsStride; 68 std::vector<float> *mTangents; 69 unsigned int mTangentssStride; 70 std::vector<float> *mBinormals; 71 unsigned int mBinormalsStride; 72 73 SimpleMesh mConvertedMesh; 74 75 // This vector is used to remap a position index into a list of all divergent vertices 76 std::vector<std::vector<unsigned int> > mVertexRemap; 77 78 void addTriangles(domTriangles * colladaTriangles); 79 void cacheOffsetsAndDataPointers(domTriangles * colladaTriangles); 80 int remapIndexAndStoreData(const domListOfUInts &colladaIndexList, int indexToRemap); 81 82 }; 83 84 #endif //COLLADA_TO_A3D_GEOMETRY 85