00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SOLAR_MODEL_H
00018 #define SOLAR_MODEL_H
00019
00020 #include <Solar/BoundingBox.hpp>
00021 #include <Solar/Garbage.hpp>
00022
00023 #include <Fluid/Matrix3.hpp>
00024
00025 #include <vector>
00026 #include <string>
00027
00028 namespace Solar {
00029
00030 class Graphic;
00031 class Renderer;
00032
00042 class Model : public Garbage
00043 {
00044 public:
00045 Model();
00046 ~Model();
00047
00048 virtual void setGarbageBin(GarbageBin *bin);
00049
00050 void render(Renderer *);
00051 void scale(const Fluid::Vector3 &);
00052 void scale(float s) { scale(Fluid::Vector3(s, s, s)); }
00053 void move(const Fluid::Vector3 &);
00054 void transform(const Fluid::Matrix3 &);
00055
00056 void addGraphic(Graphic *);
00057
00058 void clear();
00059
00060 void merge(Model *);
00061
00063 uint subObjectCount() const { return m_graphics.size(); }
00064
00066 Graphic *getSubObject(uint i) { return m_graphics[i]; }
00067
00068 void calculateBoundingBox();
00069
00070 const BoundingBox & boundingBox() const { return m_boundingBox; }
00071
00072 void normalize(float maximumSpan, bool center);
00073
00074 void centralize();
00075
00076 int nofPrimitives() const;
00077
00078
00079 void createPyramid(float size, const std::string &baseMaterial,
00080 bool shareMaterials = false);
00081 void createCube(float size, const std::string &baseMaterial,
00082 bool shareMaterials = false);
00083
00084 void createFromHeightMap(const unsigned char *map,
00085 unsigned w, unsigned h,
00086 const char * material = "ground");
00087
00088 protected:
00089 std::vector<Graphic *> m_graphics;
00090
00091 BoundingBox m_boundingBox;
00092
00093 private:
00094 Model(const Model &) {}
00095 Model & operator = (const Model &) { return *this; }
00096 };
00097
00098 }
00099
00100 #endif