00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _MODEL_
00019 #define _MODEL_
00020
00021 #include <list>
00022 #include <vector>
00023
00024 #include <boost/shared_ptr.hpp>
00025
00026 #include "util/Colour.h"
00027 #include "util/Material.h"
00028 #include "util/Macros.h"
00029 #include "util/Vector2.h"
00030
00031 struct PTVertex
00032 {
00033 PTVertex()
00034 :_fU(0.0f), _fV(0.0f)
00035 {
00036 }
00037
00038 Vector2 _position;
00039 Colour _colour;
00040 float _fU;
00041 float _fV;
00042 };
00043
00044 typedef std::vector<PTVertex> PTPolygon;
00045 typedef std::vector<PTPolygon> PTPolygonVector;
00046
00047 class PTSubmesh
00048 {
00049 public:
00050 PTPolygonVector _polygons;
00051 Material _material;
00052
00053 PTPolygon & CreatePolygon()
00054 {
00055 _polygons.push_back(PTPolygon());
00056
00057 return _polygons[_polygons.size() - 1];
00058 }
00059
00060 PTPolygon & CreateTriangle(const PTVertex& v0, const PTVertex& v1, const PTVertex& v2)
00061 {
00062 PTPolygon & poly = CreatePolygon();
00063
00064 poly.push_back(v0);
00065 poly.push_back(v1);
00066 poly.push_back(v2);
00067
00068 return poly;
00069 }
00070
00071 };
00072
00073 typedef std::vector<PTSubmesh*> PTSubmeshVector;
00074
00075 class PTModel
00076 {
00077 public:
00078 std::string _name;
00079 PTSubmeshVector _submeshes;
00080
00081 ~PTModel()
00082 {
00083 FOREACH(PTSubmeshVector, i, _submeshes)
00084 {
00085 delete (*i);
00086 }
00087
00088 _submeshes.clear();
00089 }
00090
00091 PTSubmesh & CreateSubmesh()
00092 {
00093 PTSubmesh * pMesh = new PTSubmesh();
00094
00095 _submeshes.push_back(pMesh);
00096
00097 return *pMesh;
00098 }
00099
00100 };
00101
00102 typedef boost::shared_ptr<PTModel> ModelPtr;
00103
00104 PTModel* CreateBoxModel(const float fWidth, const float fHeight, const Material & mat, bool bTriangulate);
00105 PTModel* CreateEllipseModel(const float fSemiMinor, const float fSemiMajor, int nSegments, const Material & mat, bool bTriangulate);
00106
00107 #endif