00001 // model.h 00002 // 00003 // Copyright (C) 2004, 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 _CELENGINE_MODEL_H_ 00011 #define _CELENGINE_MODEL_H_ 00012 00013 #include "mesh.h" 00014 00024 class Model 00025 { 00026 public: 00027 Model(); 00028 ~Model(); 00029 00033 const Mesh::Material* getMaterial(uint32) const; 00034 00038 uint32 addMaterial(const Mesh::Material*); 00039 00043 Mesh* getMesh(uint32) const; 00044 00048 uint32 addMesh(Mesh*); 00049 00055 bool pick(const Ray3d& r, double& distance) const; 00056 00058 void render(RenderContext&); 00059 00064 void normalize(const Vec3f& centerOffset); 00065 00070 bool usesTextureType(Mesh::TextureSemantic) const; 00071 00072 class MeshComparator 00073 { 00074 public: 00075 virtual bool operator()(const Mesh&, const Mesh&) const = 0; 00076 }; 00077 00079 void sortMeshes(const MeshComparator&); 00080 00090 class OpacityComparator : public MeshComparator 00091 { 00092 public: 00093 OpacityComparator(const Model&); 00094 00095 virtual bool operator()(const Mesh&, const Mesh&) const; 00096 00097 private: 00098 float getOpacity(const Mesh& mesh) const; 00099 00100 const Model& model; 00101 }; 00102 00103 private: 00104 std::vector<const Mesh::Material*> materials; 00105 std::vector<Mesh*> meshes; 00106 00107 bool textureUsage[Mesh::TextureSemanticMax]; 00108 }; 00109 00110 #endif // !_CELENGINE_MODEL_H_
1.4.1