[3235] | 1 | #ifndef _VISIBILITYSOLUTIONCONVERTER_H
|
---|
| 2 | #define _VISIBILITYSOLUTIONCONVERTER_H
|
---|
[3234] | 3 |
|
---|
[3235] | 4 |
|
---|
[3234] | 5 | #include "SimpleVec.h"
|
---|
| 6 | #include <string>
|
---|
| 7 | #include <vector>
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | typedef std::vector<SimpleVec> VertexArray;
|
---|
[3235] | 12 | typedef std::pair<float, float> TexCoord;
|
---|
[3234] | 13 |
|
---|
| 14 | class ogzstream;
|
---|
| 15 |
|
---|
[3235] | 16 |
|
---|
| 17 | struct BvhNode
|
---|
| 18 | {
|
---|
| 19 | int id;
|
---|
| 20 | char axis;
|
---|
| 21 | unsigned char depth;
|
---|
| 22 | short flags;
|
---|
| 23 |
|
---|
| 24 | // indices to first and last triangle in the triangle array
|
---|
| 25 | // assumes the traingle are placed in continuous chunk of memory
|
---|
| 26 | // however this need not be a global array!
|
---|
| 27 | int first;
|
---|
| 28 | // one after the last triangle!
|
---|
| 29 | int last;
|
---|
| 30 |
|
---|
| 31 | BvhNode(): axis(-1), first(-1), flags(0) {}
|
---|
| 32 |
|
---|
| 33 | bool IsLeaf() { return axis == -1; }
|
---|
| 34 | bool Empty() const { return first == -1; }
|
---|
| 35 | int Count() const { return last - first + 1; }
|
---|
| 36 |
|
---|
| 37 | std::vector<int> mTriangleIds;
|
---|
| 38 | };
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | struct BvhInterior: public BvhNode
|
---|
| 42 | {
|
---|
| 43 | BvhInterior():back(NULL), front(NULL) { }
|
---|
| 44 | BvhNode *back;
|
---|
| 45 | BvhNode *front;
|
---|
| 46 | };
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | struct BvhLeaf: public BvhNode
|
---|
| 50 | {
|
---|
| 51 | //Color color;
|
---|
| 52 | int texture;
|
---|
| 53 |
|
---|
| 54 | BvhLeaf(): BvhNode(), texture(0) {}
|
---|
| 55 | };
|
---|
| 56 |
|
---|
| 57 |
|
---|
[3234] | 58 | /** Converts obj format into objects readable by our format
|
---|
| 59 | */
|
---|
[3235] | 60 | class VisibilitySolutionConverter
|
---|
[3234] | 61 | {
|
---|
| 62 | public:
|
---|
| 63 |
|
---|
[3235] | 64 | VisibilitySolutionConverter();
|
---|
[3234] | 65 |
|
---|
[3235] | 66 | ~VisibilitySolutionConverter();
|
---|
[3234] | 67 |
|
---|
[3235] | 68 | bool Convert(const std::string &sceneInputFilename,
|
---|
| 69 | const std::string &sceneOutputFilename,
|
---|
| 70 | const std::string &bvhInputFilename,
|
---|
| 71 | const std::string &bvhOutputFilename);
|
---|
| 72 |
|
---|
[3234] | 73 |
|
---|
[3235] | 74 |
|
---|
[3234] | 75 | protected:
|
---|
| 76 |
|
---|
| 77 | struct Geometry
|
---|
| 78 | {
|
---|
| 79 | SimpleVec *mVertices;
|
---|
| 80 | SimpleVec *mNormals;
|
---|
[3235] | 81 | TexCoord *mTexCoords;
|
---|
[3234] | 82 |
|
---|
| 83 | int mVertexCount;
|
---|
| 84 | int mTexcoordCount;
|
---|
| 85 | };
|
---|
| 86 |
|
---|
[3235] | 87 | void LoadShape(const VertexArray &vertices,
|
---|
| 88 | const VertexArray &normals,
|
---|
| 89 | const std::vector<TexCoord> &texCoords);
|
---|
[3234] | 90 |
|
---|
| 91 | void WriteGeometry(ogzstream &str, Geometry *geom);
|
---|
| 92 |
|
---|
[3235] | 93 | bool ReadScene(const std::string &iFilename);
|
---|
[3234] | 94 |
|
---|
[3235] | 95 | bool WriteScene(const std::string &oFilename);
|
---|
[3234] | 96 |
|
---|
[3235] | 97 | bool ReadBvh(FILE *fr);
|
---|
| 98 |
|
---|
| 99 | bool WriteBvh(const std::string &oFilename);
|
---|
| 100 |
|
---|
| 101 | void ConstructBvhObjects(const VertexArray &vertices,
|
---|
| 102 | const VertexArray &normals,
|
---|
| 103 | const std::vector<TexCoord> &texCoords);
|
---|
| 104 |
|
---|
| 105 | bool LoadSolution(const std::string &filename);
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | BvhNode *LoadNode(FILE *fr, int depth);
|
---|
| 109 |
|
---|
| 110 | bool ReadDummyTree(FILE *fr);
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | //////////////////////////////////
|
---|
| 115 |
|
---|
[3234] | 116 | std::vector<Geometry *> mGeometry;
|
---|
| 117 |
|
---|
| 118 | int mNumShapes;
|
---|
[3235] | 119 |
|
---|
| 120 | std::vector<int> mGlobalTriangleIds;
|
---|
| 121 |
|
---|
| 122 | std::vector<BvhNode *> mBvhNodes;
|
---|
| 123 |
|
---|
| 124 | BvhNode *mRoot;
|
---|
| 125 |
|
---|
| 126 | int mNumNodes;
|
---|
[3234] | 127 | };
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 | #endif
|
---|