1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef _ADV_TREE_GENERATOR_H
4 #define _ADV_TREE_GENERATOR_H
5 
6 #include "Rendering/GL/myGL.h"
7 
8 // XXX This has a duplicate in ITreeDrawer.h
9 #define MAX_TREE_HEIGHT 60
10 
11 class CVertexArray;
12 
13 namespace Shader {
14 	struct IProgramObject;
15 }
16 
17 class CAdvTreeGenerator
18 {
19 public:
20 	CAdvTreeGenerator();
21 	virtual ~CAdvTreeGenerator();
22 
23 	void Draw() const;
24 
25 	GLuint barkTex;
26 	GLuint farTex[2];
27 	unsigned int leafDL;
28 	unsigned int pineDL;
29 
30 	CVertexArray* va;
31 	CVertexArray* barkva;
32 
33 	void MainTrunk(int numBranch, float height, float width);
34 	void CreateFarTex(Shader::IProgramObject*);
35 	void CreateFarView(unsigned char* mem, int dx, int dy, unsigned int displist);
36 
37 private:
38 	void CreateLeaves(const float3& start, const float3& dir, float length, float3& orto1, float3& orto2);
39 	void TrunkIterator(const float3& start, const float3& dir, float length, float size, int depth);
40 	void DrawTrunk(const float3& start, const float3& end, const float3& orto1, const float3& orto2, float size);
41 	void DrawPineTrunk(const float3& start, const float3& end, float size);
42 	void DrawPineBranch(const float3& start, const float3& dir, float size);
43 	void CreateGranTexBranch(const float3& start, const float3& end);
44 	void CreateGranTex(unsigned char* data, int xpos, int ypos, int xsize);
45 	void PineTree(int numBranch, float height);
46 	float fRand(float size);
47 	void CreateLeafTex(unsigned int baseTex, int xpos, int ypos, unsigned char buf[256][2048][4]);
48 };
49 
50 extern CAdvTreeGenerator* treeGen;
51 
52 #endif // _ADV_TREE_GENERATOR_H
53 
54