~ubuntu-branches/ubuntu/edgy/pouetchess/edgy-updates

« back to all changes in this revision

Viewing changes to src/CLightWaveObject.h

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc (mr_pouit)
  • Date: 2006-07-15 15:45:57 UTC
  • Revision ID: james.westby@ubuntu.com-20060715154557-3paxq02hx4od0wm4
Tags: upstream-0.2.0
ImportĀ upstreamĀ versionĀ 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2006 by Frederic MARTIN                                 *
 
3
 *   martin-frederic@users.sourceforge.net                                 *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#ifndef CLIGHT_WAVE_OBJECT_H
 
22
#define CLIGHT_WAVE_OBJECT_H
 
23
 
 
24
#include <SDL/SDL.h>
 
25
#include "CVector.h"
 
26
 
 
27
 
 
28
struct stPolygon
 
29
{
 
30
        int *pointIndex;                                            // List of point indexes.
 
31
        int totalPoints;                                            // Total points of this poly.
 
32
        int surfaceIndex;                                           // Index into surface array.
 
33
    CVector4 normal;                                            // This poly's normal.
 
34
};
 
35
 
 
36
 
 
37
struct stSurface
 
38
{
 
39
        float red, green, blue;                                     // Color of surface.
 
40
        char name[40];                                              // Name of surface.
 
41
};
 
42
 
 
43
 
 
44
class CLightWaveObject
 
45
{
 
46
        public:
 
47
      CLightWaveObject();                                      // Contructor.
 
48
      ~CLightWaveObject();                                     // Destructor.
 
49
 
 
50
      bool LoadModel(char *filename);                          // Load a model into this class.
 
51
      void Shutdown();                                         // Release all resources.
 
52
 
 
53
   private:
 
54
      bool ReadShortFromFile(FILE *fp, unsigned short &value); // Read a short from a file.
 
55
      bool ReadIntFromFile(FILE *fp, int &value);              // Read a int from a file.
 
56
      bool ReadFloatFromFile(FILE *fp, float &value);          // Read a float from a file.
 
57
      bool ReadSubChunkFromFile(FILE *fp, char *buffer,
 
58
                                unsigned short &val);          // Read a sub chunk from file.
 
59
 
 
60
      bool LoadTags(FILE *fp);                                 // Load all tags.
 
61
           bool LoadSurfaces(FILE *fp);                             // Load all surfaces.
 
62
      int AddPolygon(FILE * fp);                               // Add a polygon to the list.
 
63
           bool FindChunk(FILE *fp, const char *chunk);             // Searches for a chunk.
 
64
           bool FindNextChunk(FILE *fp, const char *chunk);         // Searches for a chunk.
 
65
 
 
66
      void CalculateNormals();                                 // Calculate all polygon normals.
 
67
 
 
68
   public:
 
69
           CVector4 *m_vertices;                                    // List of vertex points.
 
70
           CVector4 *m_normals;                                                                         // List of normals
 
71
           stPolygon *m_polygons;                                   // List of polygons.
 
72
           stSurface *m_surfaces;                                   // List of surfaces.
 
73
 
 
74
      int m_totalPoints;                                       // Total num of vertex points.
 
75
      int m_totalPolygons;                                     // Total num of polygons.
 
76
      int m_totalSurfaces;                                     // Total num of surfaces.
 
77
};
 
78
 
 
79
#endif
 
80
 
 
81