Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/mount_points/src/lib/graphics/importer/model.h @ 10184

Last change on this file since 10184 was 10184, checked in by patrick, 17 years ago

extended model again, added mounting point generation procedures now working on a nicer interface

File size: 4.2 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
28
29//! holds the information about a triangle
30typedef struct
31{
[6308]32  unsigned int   indexToVertices[3];   //!< index to the vertices of the triangle
[4802]33  unsigned int   indexToNormals[3];    //!< index to the normals of the triangle
[4794]34  unsigned int   indexToTexCoor[3];    //!< index to the texture coordinates
35} sTriangleExt;
36
37
[5430]38//! Model Information definitions
[4804]39typedef struct
40{
[5430]41  unsigned int     numVertices;          //!< number of Vertices in the Model
42  unsigned int     numTriangles;         //!< number of triangles in the Model
43  unsigned int     numNormals;           //!< how many Normals in the Model
[6008]44  unsigned int     numTexCoor;           //!< how many Texture Coordinates in the Model
[4804]45
[7193]46  const float*     pVertices;            //!< array of the Vertices
[5430]47  sTriangleExt*    pTriangles;           //!< array of all triangles
48  const float*     pNormals;             //!< array of the Normals
49  const float*     pTexCoor;             //!< array of the Texture Coordinates
[4804]50
51} modelInfo;
52
53
[10182]54//! skeleton informations for all mount points
55typedef struct
56{
[10184]57  std::string      name;                 //!< the name of the mount point
[10182]58  Vector           up;                   //!< the up vector
59  Vector           forward;              //!< the forward vector
60  Vector           center;               //!< the center vector
61} mountPointSkeleton;
62
63
64
[4245]65//! This class defines the basic components of a model
[7193]66class Model : virtual public BaseObject {
[9869]67  ObjectListDeclaration(Model);
[4245]68
[10182]69  typedef std::list<mountPointSkeleton>   mpList;
70
[4806]71  public:
[6021]72    virtual ~Model();
[4806]73
[6033]74    virtual void draw() const;
[6021]75
[6008]76    inline const modelInfo* getModelInfo() const { return &this->pModelInfo; }
[4806]77
[6008]78    /** @returns a Pointer to the Vertex-Array, if it was deleted it returns NULL */
79    inline const float* getVertexArray() const { return this->pModelInfo.pVertices; };
80    /** @returns the VertexCount of this Model */
81    inline unsigned int getVertexCount() const { return this->pModelInfo.numVertices; };
[4806]82
[6008]83    /** @returns a Pointer to the Normals-Array, if it was deleted it returns NULL */
84    inline const float* getNormalsArray() const { return this->pModelInfo.pNormals; };
85    /** @returns the NormalsCount of this Model */
86    inline unsigned int getNormalsCount() const { return this->pModelInfo.numNormals; };
87
88    /** @returns a Pointer to the TexCoord-Array, if it was deleted it returns NULL */
89    inline const float* getTexCoordArray() const { return this->pModelInfo.pTexCoor; };
90    /** @returns the TexCoord-Count of this Model */
91    inline unsigned int getTexCoordCount() const { return this->pModelInfo.numTexCoor; };
92
93    /** @returns the Array of triangles */
94    inline sTriangleExt* getTriangles() const { return this->pModelInfo.pTriangles; };
95    /** @returns the Count of Faces of this Model */
[6308]96    inline unsigned int getTriangleCount() const { return this->pModelInfo.numTriangles; };
[6008]97
[10147]98    /** function to extract the mount points from the model data */
99    virtual void extractMountPoints() {}
[10182]100    /** @returns a list of mounting points */
101    inline const mpList& getMountPoints() const { return this->mountPoints; }
102    /** adds a mounting point to the model @param up up vector @param forward forward vector @param center center vector */
[10184]103    inline void addMountPoint(const Vector& up, const Vector& forward, const Vector& center, const std::string& name)
104    { mountPointSkeleton mps; mps.up = up; mps.forward = forward; mps.center = center; mps.name = name; }
[10147]105
106
[7123]107  protected:
108    Model();
[6009]109
[7123]110
[4806]111  protected:
[10182]112    modelInfo                        pModelInfo;      //!< Reference to the modelInfo
113    mpList                           mountPoints;     //!< a list of all mounting point skeletons
[4245]114};
115
[6021]116#endif /* _MODEL_H */
Note: See TracBrowser for help on using the repository browser.