source: GTP/trunk/App/Demos/Geom/OgreLodStripsLibrary.h @ 1029

Revision 1029, 4.4 KB checked in by gumbau, 18 years ago (diff)

LodStrips? Ogre demo initial import

Line 
1/*      ==========================================================================
2 *      (C) 2006 Universidad Jaime I
3 *      ==========================================================================
4 *      PROYECT:        GAME TOOLS
5 *      ==========================================================================*/
6/**     CONTENT:
7        *
8        *
9        *       @file   OgreLodStripsLibrary.h
10/*===========================================================================*/
11
12// For integrating the library in the Ogre engine,
13// we have modified the class constructor and also the GoToLod function
14
15#include        "Ogre.h"
16#include        <vector>
17
18
19typedef unsigned long   SmallInt;
20typedef unsigned long   ULong;
21typedef long                    Long;
22
23typedef struct
24{
25        SmallInt strip;
26        SmallInt position;
27        SmallInt rep; //For the vertex repetition
28} PositionType;
29
30typedef struct
31{
32        unsigned        long    strip;
33        char                                            position;
34        char                                            vertexRepetition;
35        char                                            edgeRepetition;
36}       LODRegisterType;
37
38typedef struct
39{
40        float Vertex[3];
41        SmallInt Next;
42} VertexType;
43
44typedef std::vector     <SmallInt>                              SmallIntVector;
45typedef std::vector     <LODRegisterType>       LODRegisterVector;
46typedef std::vector     <Long>                                          LongVector;
47
48/// LodStripsLibrary interface class.
49/** This module contains functions that handle the levels of detail of the input multiresolution objects made of polygonal meshes. For any given resolution and object, this module returns a set of triangle strips representing the object at that resolution, that is, at the level of detail requested. These models use triangle strips to reduce storage usage and to speed up realistic rendering.
50\n\n
51
52Inputs:\n
53- The module receives a file describing a multiresolution object.
54.
55
56Outputs:\n
57- The module returns a strip set that represents the level of detail requested.
58.
59
60*/
61class LodStripsLibrary
62{
63        private:
64
65                ///Structures with the data read from the file
66                ///We won't work with these structures
67                SmallIntVector                                          mFileVertices;
68                std::vector     <LODRegisterType>               mFileChangesLOD;
69                std::vector     <SmallIntVector>                mFileStrips;
70                LongVector                                                      mData;
71
72                ///Structures with the data to work with
73                SmallInt        mTotalStrips;           ///Total strips of the multiresolution object.
74                SmallInt        mTotalVertices; ///Total vertices of the multiresolution object.
75                SmallInt        mTotalChanges;  ///Total changes of the multiresolution object.
76                SmallInt        mLods;                                  ///Available Lods.
77
78
79
80                //      For the efficient version.
81                SmallInt                                mTotalFaces;
82                SmallInt                                *mCurrentData;
83                SmallInt                                *mDataBegin;
84                LODRegisterType                 *mCurrentRegLOD;
85                LODRegisterType                 *mRegLODBegin;
86                SmallInt                                *mVertex;
87
88       
89                //      Changes of Strips in LOD file (p).
90                SmallInt        *mPChanges;
91
92                //      Strips vector.
93                SmallIntVector  *mStrips;       
94
95                ///Total of vertices shown at the moment.
96                long    int     mTotal;
97
98                /*
99                        Copa STL vectors to C arrays.
100                */
101                void    CopyVectors2Arrays();
102
103                /*
104                        Loads Mesh
105                */
106                void    LoadStripMesh(char *name, Ogre::Mesh *geomesh);
107
108                Ogre::Mesh* original_mesh;
109
110                //Number of strips in each submesh
111                int* mStripsSubmesh;
112               
113        public:
114
115                SmallInt        mMaxLod;                                ///Max level of detail.
116                SmallInt        mMinLod;                                ///Min level of detail.
117
118                SmallInt        mCurrentLod;            ///Current Lod.
119
120                /// Constructor, receives as a parameter the name of the file including the multiresolution object.
121                LodStripsLibrary(std::string, Ogre::Mesh *geomesh);
122
123                /// Destructor.
124                ~LodStripsLibrary(void);
125
126                /// Copy constructor
127                //LodStripsLibrary(const LodStripsLibrary&);
128
129                /// Assignment operator
130                //LodStripsLibrary& operator =(const LodStripsLibrary&);
131
132                /// Returns the highest LOD.
133                Ogre::uint32    MaxLod();
134
135                /// Returns the lowest LOD.
136                Ogre::uint32    MinLod();
137
138                /// Returns de current LOD and changes to the specified LOD.
139                Ogre::uint32    GoToLod(Ogre::uint32);
140
141                /// Establishes the new LOD range.
142                /// Only the LODs in that range are stored and used.
143                void            TrimByLod(Ogre::uint32, Ogre::uint32);
144
145                /// Returns the number of triangles of the highest LOD.
146                Ogre::uint32    MaxFaces();
147
148                /// Returns the number of triangles of the lowest LOD.
149                Ogre::uint32    MinFaces();
150
151                /// Returns the number of vertices of the highest LOD.
152                Ogre::uint32    MaxVertices();
153
154                /// Returns the number of vertices of the lowest LOD.
155                Ogre::uint32    MinVertices();
156
157                //      (New)   Get the number of strips.
158                Ogre::uint32    GetStripCount() const;
159                Ogre::uint32  GetIndexCountByStrip(Ogre::uint32) const;
160};
Note: See TracBrowser for help on using the repository browser.