00001 // 3dsmodel.h 00002 // 00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net> 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 00010 #ifndef _3DSMODEL_H_ 00011 #define _3DSMODEL_H_ 00012 00013 #include <vector> 00014 #include <string> 00015 #include <celutil/basictypes.h> 00016 #include <celmath/vecmath.h> 00017 00018 class M3DColor 00019 { 00020 public: 00021 M3DColor(); 00022 M3DColor(float, float, float); 00023 00024 public: 00025 float red, green, blue; 00026 }; 00027 00028 00029 class M3DMaterial 00030 { 00031 public: 00032 M3DMaterial(); 00033 00034 std::string getName() const; 00035 void setName(std::string); 00036 M3DColor getAmbientColor() const; 00037 void setAmbientColor(M3DColor); 00038 M3DColor getDiffuseColor() const; 00039 void setDiffuseColor(M3DColor); 00040 M3DColor getSpecularColor() const; 00041 void setSpecularColor(M3DColor); 00042 float getShininess() const; 00043 void setShininess(float); 00044 float getOpacity() const; 00045 void setOpacity(float); 00046 std::string getTextureMap() const; 00047 void setTextureMap(const std::string&); 00048 00049 private: 00050 std::string name; 00051 std::string texmap; 00052 M3DColor ambient; 00053 M3DColor diffuse; 00054 M3DColor specular; 00055 float shininess; 00056 float opacity; 00057 }; 00058 00059 00060 class M3DTriangleMesh 00061 { 00062 public: 00063 M3DTriangleMesh(); 00064 ~M3DTriangleMesh(); 00065 00066 Mat4f getMatrix() const; 00067 void setMatrix(const Mat4f&); 00068 00069 Point3f getVertex(uint16) const; 00070 uint16 getVertexCount() const; 00071 void addVertex(Point3f); 00072 00073 Point2f getTexCoord(uint16) const; 00074 uint16 getTexCoordCount() const; 00075 void addTexCoord(Point2f); 00076 00077 void getFace(uint16, uint16&, uint16&, uint16&) const; 00078 uint16 getFaceCount() const; 00079 void addFace(uint16, uint16, uint16); 00080 00081 void addSmoothingGroups(uint32); 00082 uint32 getSmoothingGroups(uint16) const; 00083 uint16 getSmoothingGroupCount() const; 00084 00085 std::string getMaterialName() const; 00086 void setMaterialName(std::string); 00087 00088 private: 00089 std::vector<Point3f> points; 00090 std::vector<Point2f> texCoords; 00091 std::vector<uint16> faces; 00092 std::vector<uint32> smoothingGroups; 00093 Mat4f matrix; 00094 std::string materialName; 00095 }; 00096 00097 00098 class M3DModel 00099 { 00100 public: 00101 M3DModel(); 00102 ~M3DModel(); 00103 00104 M3DTriangleMesh* getTriMesh(uint32); 00105 uint32 getTriMeshCount(); 00106 void addTriMesh(M3DTriangleMesh*); 00107 void setName(const std::string); 00108 const std::string getName() const; 00109 00110 private: 00111 std::string name; 00112 std::vector<M3DTriangleMesh*> triMeshes; 00113 }; 00114 00115 00116 class M3DScene 00117 { 00118 public: 00119 M3DScene(); 00120 ~M3DScene(); 00121 00122 M3DModel* getModel(uint32) const; 00123 uint32 getModelCount() const; 00124 void addModel(M3DModel*); 00125 00126 M3DMaterial* getMaterial(uint32) const; 00127 uint32 getMaterialCount() const; 00128 void addMaterial(M3DMaterial*); 00129 00130 M3DColor getBackgroundColor() const; 00131 void setBackgroundColor(M3DColor); 00132 00133 private: 00134 std::vector<M3DModel*> models; 00135 std::vector<M3DMaterial*> materials; 00136 M3DColor backgroundColor; 00137 }; 00138 00139 #endif // _3DSMODEL_H_
1.4.1