1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D 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 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(__INCLUDE_ModelRendererMeshh_INCLUDE__)
22 #define __INCLUDE_ModelRendererMeshh_INCLUDE__
23 
24 #include <graph/ModelRenderer.h>
25 #include <3dsparse/Model.h>
26 
27 class GLTexture;
28 class ModelRendererMesh : public ModelRenderer
29 {
30 public:
31 	ModelRendererMesh(Model *model);
32 	virtual ~ModelRendererMesh();
33 
34 	virtual void draw(float currentFrame,
35 		float distance, float fade, bool setState);
36 	virtual void drawBottomAligned(float currentFrame,
37 		float distance, float fade, bool setState);
38 
getModel()39 	virtual Model *getModel() { return model_; }
40 
41 	virtual Mesh *drawModel(float currentFrame,
42 		float distance, float fade, bool setState,
43 		std::vector<Mesh *> &meshes, Mesh *lastMesh);
44 
setVertexTranslation(FixedVector & translation)45 	void setVertexTranslation(FixedVector &translation) { vertexTranslation_ = translation; }
46 
47 protected:
48 	struct MeshFrameInfo
49 	{
MeshFrameInfoMeshFrameInfo50 		MeshFrameInfo() : displayList(0) {}
51 
52 		unsigned int displayList;
53 	};
54 
55 	Model *model_;
56 	std::vector<BoneType *> boneTypes_;
57 	std::vector<MeshFrameInfo> frameInfos_;
58 	FixedVector vertexTranslation_;
59 
60 	struct TriangleInfo
61 	{
62 		Vector position;
63 		Vector normal;
64 		Vector color;
65 		float texCoordx, texCoordy;
66 	};
67 
68 	virtual void drawMesh(Mesh *mesh, Mesh *lastMesh,
69 		int frame, bool useTextures, bool vertexLighting);
70 	virtual void drawVerts(Mesh *mesh, bool vertexLighting, int frame);
71 	virtual void setup();
72 };
73 
74 #endif // __INCLUDE_ModelRendererMeshh_INCLUDE__
75