Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: useless stuff :)

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