Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/model.h @ 6080

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

orxonox/trunk: model now also implements a Draw function, based on what it knows and patrick did

File size: 5.5 KB
RevLine 
[4794]1/*
[4245]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
[4794]13   co-programmer:
[4245]14*/
15
[4794]16/*!
[6021]17 * @file model.h
18 *  Definition of an abstract model.
19 *  containing all needed for other models
[5435]20 */
[4245]21
[6021]22#ifndef _MODEL_H
23#define _MODEL_H
[4245]24
25#include "base_object.h"
[5672]26#include "vector.h"
[4245]27
28using namespace std;
29
30
31
32//! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
33typedef struct
34{
[5427]35  char             v[3];                 //!< the vector of the vertex
[4467]36  unsigned char    lightNormalIndex;     //!< the index of the light normal
[4245]37} sVertex;
38
[4467]39
[4245]40//! compressed texture offset data: coords scaled by the texture size. Only for loading
41typedef struct
42{
[4467]43  short            s;                    //!< the s,t coordinates of a texture
44  short            t;                    //!< the s,t coordinates of a texture
[4245]45} sTexCoor;
46
47
48//! holds tha informations about a md2 frame
49typedef struct
50{
[4467]51  sVec3D           scale;                //!< scales values of the model
52  sVec3D           translate;            //!< translates the model
53  char             name[16];             //!< frame name: something like "run32"
54  sVertex          pVertices[1];         //!< first vertex of thes frame
[4245]55} sFrame;
56
57
58//! holds the information about a triangle
59typedef struct
60{
[4787]61  unsigned short   indexToVertices[3];   //!< index to the verteces of the triangle
62  unsigned short   indexToTexCoor[3];    //!< index to the texture coordinates
[4245]63} sTriangle;
64
65
[4794]66//! holds the information about a triangle
67typedef struct
68{
69  unsigned int   indexToVertices[3];   //!< index to the verteces of the triangle
[4802]70  unsigned int   indexToNormals[3];    //!< index to the normals of the triangle
[4794]71  unsigned int   indexToTexCoor[3];    //!< index to the texture coordinates
72} sTriangleExt;
73
74
[4467]75//! the command list of the md2 model, very md2 specific
[4245]76typedef struct
77{
[4467]78  float            s;                    //!< texture coordinate 1
79  float            t;                    //!< texture coordinate 2
80  int              vertexIndex;          //!< index of the vertex in the vertex list
[4245]81} glCommandVertex;
82
83
84//! a md2 animation definition
85typedef struct
86{
[4467]87  int              firstFrame;           //!< first frame of the animation
88  int              lastFrame;            //!< last frame of the animation
89  int              fps;                  //!< speed: number of frames per second
[4245]90} sAnim;
91
[4467]92
[4245]93//! animation state definition
94typedef struct
95{
[4467]96  int              startFrame;           //!< the start frame of an animation
97  int              endFrame;             //!< last frame of the animation
98  int              fps;                  //!< fps of the animaion (speed)
[4245]99
[4467]100  float            localTime;            //!< the local time
101  float            lastTime;             //!< last time stamp
102  float            interpolationState;   //!< the state of the animation [0..1]
[4794]103
[4467]104  int              type;                 //!< animation type
[4245]105
[4467]106  int              currentFrame;         //!< the current frame
107  int              nextFrame;            //!< the next frame in the list
[4245]108} sAnimState;
109
[5430]110//! Model Information definitions
[4804]111typedef struct
112{
[5430]113  unsigned int     numVertices;          //!< number of Vertices in the Model
114  unsigned int     numTriangles;         //!< number of triangles in the Model
115  unsigned int     numNormals;           //!< how many Normals in the Model
[6008]116  unsigned int     numTexCoor;           //!< how many Texture Coordinates in the Model
[4804]117
[5430]118  const float*     pVertices;            //!< array of the Vertives
119  sTriangleExt*    pTriangles;           //!< array of all triangles
120  const float*     pNormals;             //!< array of the Normals
121  const float*     pTexCoor;             //!< array of the Texture Coordinates
[4804]122
123} modelInfo;
124
125
126
[4245]127//! This class defines the basic components of a model
[6021]128class Model : public BaseObject {
[4245]129
[4806]130  public:
[6021]131    Model();
132    virtual ~Model();
[4806]133
[6033]134    virtual void draw() const;
[6021]135
[6008]136    inline const modelInfo* getModelInfo() const { return &this->pModelInfo; }
[4806]137
[6008]138    /** @returns a Pointer to the Vertex-Array, if it was deleted it returns NULL */
139    inline const float* getVertexArray() const { return this->pModelInfo.pVertices; };
140    /** @returns the VertexCount of this Model */
141    inline unsigned int getVertexCount() const { return this->pModelInfo.numVertices; };
[4806]142
[6008]143    /** @returns a Pointer to the Normals-Array, if it was deleted it returns NULL */
144    inline const float* getNormalsArray() const { return this->pModelInfo.pNormals; };
145    /** @returns the NormalsCount of this Model */
146    inline unsigned int getNormalsCount() const { return this->pModelInfo.numNormals; };
147
148    /** @returns a Pointer to the TexCoord-Array, if it was deleted it returns NULL */
149    inline const float* getTexCoordArray() const { return this->pModelInfo.pTexCoor; };
150    /** @returns the TexCoord-Count of this Model */
151    inline unsigned int getTexCoordCount() const { return this->pModelInfo.numTexCoor; };
152
153    /** @returns the Array of triangles */
154    inline sTriangleExt* getTriangles() const { return this->pModelInfo.pTriangles; };
155    /** @returns the Count of Faces of this Model */
156    inline unsigned int getFaceCount() const { return this->pModelInfo.numTriangles; };
157
[6009]158
[4806]159  protected:
[6008]160    modelInfo      pModelInfo;      //!< Reference to the modelInfo
[4245]161};
162
[6021]163#endif /* _MODEL_H */
Note: See TracBrowser for help on using the repository browser.