Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/abstract_model.h @ 5723

Last change on this file since 5723 was 5672, checked in by patrick, 19 years ago

orxonox/trunk: removed the modelinfo from the includes of vector.h

File size: 4.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer:
14*/
15
16/*!
17 * @file abstract_model.h
18 *  Definition of an abstract model. containing all needed for other model
19 */
20
21#ifndef _ABSTRACT_MODEL_H
22#define _ABSTRACT_MODEL_H
23
24#include "base_object.h"
25#include "vector.h"
26
27using namespace std;
28
29
30
31//! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
32typedef struct
33{
34  char             v[3];                 //!< the vector of the vertex
35  unsigned char    lightNormalIndex;     //!< the index of the light normal
36} sVertex;
37
38
39//! compressed texture offset data: coords scaled by the texture size. Only for loading
40typedef struct
41{
42  short            s;                    //!< the s,t coordinates of a texture
43  short            t;                    //!< the s,t coordinates of a texture
44} sTexCoor;
45
46
47//! holds tha informations about a md2 frame
48typedef struct
49{
50  sVec3D           scale;                //!< scales values of the model
51  sVec3D           translate;            //!< translates the model
52  char             name[16];             //!< frame name: something like "run32"
53  sVertex          pVertices[1];         //!< first vertex of thes frame
54} sFrame;
55
56
57//! holds the information about a triangle
58typedef struct
59{
60  unsigned short   indexToVertices[3];   //!< index to the verteces of the triangle
61  unsigned short   indexToTexCoor[3];    //!< index to the texture coordinates
62} sTriangle;
63
64
65//! holds the information about a triangle
66typedef struct
67{
68  unsigned int   indexToVertices[3];   //!< index to the verteces of the triangle
69  unsigned int   indexToNormals[3];    //!< index to the normals of the triangle
70  unsigned int   indexToTexCoor[3];    //!< index to the texture coordinates
71} sTriangleExt;
72
73
74//! the command list of the md2 model, very md2 specific
75typedef struct
76{
77  float            s;                    //!< texture coordinate 1
78  float            t;                    //!< texture coordinate 2
79  int              vertexIndex;          //!< index of the vertex in the vertex list
80} glCommandVertex;
81
82
83//! a md2 animation definition
84typedef struct
85{
86  int              firstFrame;           //!< first frame of the animation
87  int              lastFrame;            //!< last frame of the animation
88  int              fps;                  //!< speed: number of frames per second
89} sAnim;
90
91
92//! animation state definition
93typedef struct
94{
95  int              startFrame;           //!< the start frame of an animation
96  int              endFrame;             //!< last frame of the animation
97  int              fps;                  //!< fps of the animaion (speed)
98
99  float            localTime;            //!< the local time
100  float            lastTime;             //!< last time stamp
101  float            interpolationState;   //!< the state of the animation [0..1]
102
103  int              type;                 //!< animation type
104
105  int              currentFrame;         //!< the current frame
106  int              nextFrame;            //!< the next frame in the list
107} sAnimState;
108
109//! Model Information definitions
110typedef struct
111{
112  unsigned int     numVertices;          //!< number of Vertices in the Model
113  unsigned int     numTriangles;         //!< number of triangles in the Model
114  unsigned int     numNormals;           //!< how many Normals in the Model
115  unsigned int     numTexCoor;
116
117  const float*     pVertices;            //!< array of the Vertives
118  sTriangleExt*    pTriangles;           //!< array of all triangles
119  const float*     pNormals;             //!< array of the Normals
120  const float*     pTexCoor;             //!< array of the Texture Coordinates
121
122} modelInfo;
123
124
125
126//! This class defines the basic components of a model
127class AbstractModel : public BaseObject {
128
129  public:
130    AbstractModel() {}
131    virtual ~AbstractModel() {}
132
133    inline const modelInfo* getModelInfo() const { return this->pModelInfo; }
134
135
136  protected:
137    modelInfo*     pModelInfo;      //!< Reference to the modelInfo
138};
139
140#endif /* _ABSTRACT_MODEL_H */
Note: See TracBrowser for help on using the repository browser.