Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5452 was 5435, checked in by bensch, 19 years ago

orxonox/trunk: power-ups implemented (simple-mode)

File size: 4.4 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
26
27using namespace std;
28
29class Quadtree;
30
31
32//! this is a small and performant 3D vector
33typedef float sVec3D[3];
34
35
36//! small and performant 2D vector
37typedef float sVec2D[2];
38
39
40//! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
41typedef struct
42{
43  char             v[3];                 //!< the vector of the vertex
44  unsigned char    lightNormalIndex;     //!< the index of the light normal
45} sVertex;
46
47
48//! compressed texture offset data: coords scaled by the texture size. Only for loading
49typedef struct
50{
51  short            s;                    //!< the s,t coordinates of a texture
52  short            t;                    //!< the s,t coordinates of a texture
53} sTexCoor;
54
55
56//! holds tha informations about a md2 frame
57typedef struct
58{
59  sVec3D           scale;                //!< scales values of the model
60  sVec3D           translate;            //!< translates the model
61  char             name[16];             //!< frame name: something like "run32"
62  sVertex          pVertices[1];         //!< first vertex of thes frame
63} sFrame;
64
65
66//! holds the information about a triangle
67typedef struct
68{
69  unsigned short   indexToVertices[3];   //!< index to the verteces of the triangle
70  unsigned short   indexToTexCoor[3];    //!< index to the texture coordinates
71} sTriangle;
72
73
74//! holds the information about a triangle
75typedef struct
76{
77  unsigned int   indexToVertices[3];   //!< index to the verteces of the triangle
78  unsigned int   indexToNormals[3];    //!< index to the normals of the triangle
79  unsigned int   indexToTexCoor[3];    //!< index to the texture coordinates
80} sTriangleExt;
81
82
83//! the command list of the md2 model, very md2 specific
84typedef struct
85{
86  float            s;                    //!< texture coordinate 1
87  float            t;                    //!< texture coordinate 2
88  int              vertexIndex;          //!< index of the vertex in the vertex list
89} glCommandVertex;
90
91
92//! a md2 animation definition
93typedef struct
94{
95  int              firstFrame;           //!< first frame of the animation
96  int              lastFrame;            //!< last frame of the animation
97  int              fps;                  //!< speed: number of frames per second
98} sAnim;
99
100
101//! animation state definition
102typedef struct
103{
104  int              startFrame;           //!< the start frame of an animation
105  int              endFrame;             //!< last frame of the animation
106  int              fps;                  //!< fps of the animaion (speed)
107
108  float            localTime;            //!< the local time
109  float            lastTime;             //!< last time stamp
110  float            interpolationState;   //!< the state of the animation [0..1]
111
112  int              type;                 //!< animation type
113
114  int              currentFrame;         //!< the current frame
115  int              nextFrame;            //!< the next frame in the list
116} sAnimState;
117
118//! Model Information definitions
119typedef struct
120{
121  unsigned int     numVertices;          //!< number of Vertices in the Model
122  unsigned int     numTriangles;         //!< number of triangles in the Model
123  unsigned int     numNormals;           //!< how many Normals in the Model
124  unsigned int     numTexCoor;
125
126  const float*     pVertices;            //!< array of the Vertives
127  sTriangleExt*    pTriangles;           //!< array of all triangles
128  const float*     pNormals;             //!< array of the Normals
129  const float*     pTexCoor;             //!< array of the Texture Coordinates
130
131} modelInfo;
132
133
134
135//! This class defines the basic components of a model
136class AbstractModel : public BaseObject {
137
138  public:
139    AbstractModel() {}
140    virtual ~AbstractModel() {}
141
142    inline const modelInfo* getModelInfo() const { return this->pModelInfo; }
143
144
145  protected:
146    modelInfo*     pModelInfo;      //!< Reference to the modelInfo
147};
148
149#endif /* _ABSTRACT_MODEL_H */
Note: See TracBrowser for help on using the repository browser.