1 #ifndef CLIGHT_WAVE_OBJECT_H
2 #define CLIGHT_WAVE_OBJECT_H
3 
4 #include <SDL/SDL.h>
5 #include "CVector.h"
6 
7 
8 struct stPolygon
9 {
10 	int *pointIndex;                                            // List of point indexes.
11 	int totalPoints;                                            // Total points of this poly.
12 	int surfaceIndex;                                           // Index into surface array.
13     CVector4 normal;                                            // This poly's normal.
14 };
15 
16 
17 struct stSurface
18 {
19 	float red, green, blue;                                     // Color of surface.
20 	char name[40];                                              // Name of surface.
21 };
22 
23 
24 class CLightWaveObject
25 {
26 	public:
27       CLightWaveObject();                                      // Contructor.
28       ~CLightWaveObject();                                     // Destructor.
29 
30       bool LoadModel(char *filename);                          // Load a model into this class.
31       void Shutdown();                                         // Release all resources.
32 
33    private:
34       bool ReadShortFromFile(FILE *fp, unsigned short &value); // Read a short from a file.
35       bool ReadIntFromFile(FILE *fp, int &value);              // Read a int from a file.
36       bool ReadFloatFromFile(FILE *fp, float &value);          // Read a float from a file.
37       bool ReadSubChunkFromFile(FILE *fp, char *buffer,
38                                 unsigned short &val);          // Read a sub chunk from file.
39 
40       bool LoadTags(FILE *fp);                                 // Load all tags.
41 	   bool LoadSurfaces(FILE *fp);                             // Load all surfaces.
42       int AddPolygon(FILE * fp);                               // Add a polygon to the list.
43 	   bool FindChunk(FILE *fp, const char *chunk);             // Searches for a chunk.
44 	   bool FindNextChunk(FILE *fp, const char *chunk);         // Searches for a chunk.
45 
46       void CalculateNormals();                                 // Calculate all polygon normals.
47 
48    public:
49 	   CVector4 *m_vertices;                                    // List of vertex points.
50 	   CVector4 *m_normals;										// List of normals
51 	   stPolygon *m_polygons;                                   // List of polygons.
52 	   stSurface *m_surfaces;                                   // List of surfaces.
53 
54       int m_totalPoints;                                       // Total num of vertex points.
55       int m_totalPolygons;                                     // Total num of polygons.
56       int m_totalSurfaces;                                     // Total num of surfaces.
57 };
58 
59 #endif
60 
61 
62