source: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h @ 3282

Revision 3282, 3.4 KB checked in by mattausch, 15 years ago (diff)

probably found export error

RevLine 
[3235]1#ifndef _VISIBILITYSOLUTIONCONVERTER_H
2#define _VISIBILITYSOLUTIONCONVERTER_H
[3234]3
[3235]4
[3241]5#include "Vector3.h"
6#include "Triangle3.h"
[3234]7#include <string>
8#include <vector>
[3240]9#include "AxisAlignedBox3.h"
[3234]10
[3241]11       
[3234]12
[3241]13typedef std::vector<CHCDemoEngine::Vector3> VertexArray;
[3235]14typedef std::pair<float, float> TexCoord;
[3234]15
16class ogzstream;
[3239]17struct BvhInterior;
[3235]18
[3241]19
20
21struct Geometry
22{
23        CHCDemoEngine::Vector3 *mVertices;
24        CHCDemoEngine::Vector3 *mNormals;
25        TexCoord *mTexCoords;
26
27        int mVertexCount;
28        int mTexcoordCount;
29};
30
31
[3235]32struct BvhNode
33{
34        int id;
35        char axis;
36        unsigned char depth;
37        short flags;
38
39        // indices to first and last triangle in the triangle array
40        // assumes the traingle are placed in continuous chunk of memory
41        // however this need not be a global array!
42        int first;
43        // one after the last triangle!
44        int last;
45
46        BvhNode(): axis(-1), first(-1), flags(0) {}
47
48        bool IsLeaf() { return axis == -1; }
49        bool Empty() const { return first == -1; }
50        int Count() const { return last - first + 1; }
51
[3241]52        CHCDemoEngine::AxisAlignedBox3 box;
[3239]53
54        BvhInterior *parent;
[3235]55        std::vector<int> mTriangleIds;
56};
57
58
59struct BvhInterior: public BvhNode
60{
61        BvhInterior():back(NULL), front(NULL) { }
62        BvhNode *back;
63        BvhNode *front;
64};
65
66
67struct BvhLeaf: public BvhNode
68{
[3242]69        BvhLeaf(): BvhNode() {}
[3235]70};
71
72
[3234]73/** Converts obj format into objects readable by our format
74*/
[3235]75class VisibilitySolutionConverter
[3234]76{
77public:
78
[3235]79        VisibilitySolutionConverter();
[3234]80
[3235]81        ~VisibilitySolutionConverter();
[3234]82
[3235]83        bool Convert(const std::string &sceneInputFilename,
84                                 const std::string &sceneOutputFilename,
85                                 const std::string &bvhInputFilename,
86                         const std::string &bvhOutputFilename);
87       
[3234]88
89protected:
90
91
[3235]92        void LoadShape(const VertexArray &vertices,
93                           const VertexArray &normals,
94                                   const std::vector<TexCoord> &texCoords);
[3234]95
96        void WriteGeometry(ogzstream &str, Geometry *geom);
97
[3235]98        bool ReadScene(const std::string &iFilename);
[3234]99
[3235]100        bool WriteScene(const std::string &oFilename);
[3234]101
[3235]102        bool ReadBvh(FILE *fr);
103
104        bool WriteBvh(const std::string &oFilename);
105
106        void ConstructBvhObjects(const VertexArray &vertices,
107                                     const VertexArray &normals,
108                                                         const std::vector<TexCoord> &texCoords);
109
110        bool LoadSolution(const std::string &filename);
111
112        BvhNode *LoadNode(FILE *fr, int depth);
113
114        bool ReadDummyTree(FILE *fr);
115
[3238]116        bool ReadObj(const std::string &filename,
117                         VertexArray &vertices,
118                                 VertexArray &normals,
119                                 std::vector<TexCoord> &texcoords);
[3235]120
[3238]121        bool ReadBinObj(const std::string &filename,
[3246]122                    VertexArray &vertices);
[3235]123
[3239]124        bool WriteBinObj(const std::string &filename,
125                             const VertexArray &vertices);
126
[3238]127        bool ExportBinObj(const std::string &filename,
[3239]128                              const VertexArray &vertices);
[3238]129
[3240]130        void WriteNextNode(ogzstream &stream, BvhNode *parent);
[3239]131
[3241]132        void UpdateLeafBox(BvhLeaf *leaf);
[3242]133        /** Prepare bvh for exporting.
134        */
135        void UpdateBvh(BvhNode *node);
[3239]136
[3272]137        bool LoadSolutionTest(const std::string &filename);
[3239]138
[3243]139
[3277]140        bool ReadObjSimple(const std::string &filename,
141                std::vector<CHCDemoEngine::Triangle3 *> &triangles);
142
143        void ConstructBvhObjects2(const std::vector<CHCDemoEngine::Triangle3 *> &triangles);
144
145
146
[3235]147        //////////////////////////////////
148
[3234]149        std::vector<Geometry *> mGeometry;
150
151        int mNumShapes;
[3235]152
153        std::vector<int> mGlobalTriangleIds;
154
[3241]155        std::vector<BvhLeaf *> mBvhLeaves;
[3235]156
157        BvhNode *mRoot;
158
159        int mNumNodes;
[3234]160};
161
162
163
164#endif
Note: See TracBrowser for help on using the repository browser.