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 | \brief 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 <vector> |
---|
27 | #include <math.h> |
---|
28 | #include <SDL_image.h> |
---|
29 | |
---|
30 | using namespace std; |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | //! this is a small and performant 3D vector |
---|
35 | typedef float sVec3D[3]; |
---|
36 | |
---|
37 | |
---|
38 | //! small and performant 2D vector |
---|
39 | typedef 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 |
---|
43 | typedef 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 |
---|
51 | typedef 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 |
---|
59 | typedef 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 |
---|
69 | typedef struct |
---|
70 | { |
---|
71 | short indexToVertices[3]; //!< index to the verteces of the triangle |
---|
72 | short indexToTexCoor[3]; //!< index to the texture coordinates |
---|
73 | } sTriangle; |
---|
74 | |
---|
75 | |
---|
76 | //! the command list of the md2 model, very md2 specific |
---|
77 | typedef struct |
---|
78 | { |
---|
79 | float s; //!< texture coordinate 1 |
---|
80 | float t; //!< texture coordinate 2 |
---|
81 | int vertexIndex; //!< index of the vertex in the vertex list |
---|
82 | } glCommandVertex; |
---|
83 | |
---|
84 | |
---|
85 | //! a md2 animation definition |
---|
86 | typedef struct |
---|
87 | { |
---|
88 | int firstFrame; //!< first frame of the animation |
---|
89 | int lastFrame; //!< last frame of the animation |
---|
90 | int fps; //!< speed: number of frames per second |
---|
91 | } sAnim; |
---|
92 | |
---|
93 | |
---|
94 | //! animation state definition |
---|
95 | typedef struct |
---|
96 | { |
---|
97 | int startFrame; //!< the start frame of an animation |
---|
98 | int endFrame; //!< last frame of the animation |
---|
99 | int fps; //!< fps of the animaion (speed) |
---|
100 | |
---|
101 | float localTime; //!< the local time |
---|
102 | float lastTime; //!< last time stamp |
---|
103 | float interpolationState; //!< the state of the animation [0..1] |
---|
104 | |
---|
105 | int type; //!< animation type |
---|
106 | |
---|
107 | int currentFrame; //!< the current frame |
---|
108 | int nextFrame; //!< the next frame in the list |
---|
109 | } sAnimState; |
---|
110 | |
---|
111 | |
---|
112 | //! This class defines the basic components of a model |
---|
113 | class AbstractModel : public BaseObject { |
---|
114 | |
---|
115 | public: |
---|
116 | AbstractModel() {} |
---|
117 | virtual ~AbstractModel() {} |
---|
118 | }; |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | #endif /* _ABSTRACT_MODEL_H */ |
---|