File: SmoothHeightMesh.h

package info (click to toggle)
spring 0.81.2.1%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,496 kB
  • ctags: 37,096
  • sloc: cpp: 238,659; ansic: 13,784; java: 12,175; awk: 3,428; python: 1,159; xml: 738; perl: 405; sh: 297; makefile: 267; pascal: 228; objc: 192
file content (58 lines) | stat: -rw-r--r-- 1,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef SMOOTHHEIGHTMESH_H
#define SMOOTHHEIGHTMESH_H

#include "Map/Ground.h"

/** This class requires that BaseMesh objects support GetHeight(float x, float y) method.

Provides a GetHeight(x, y) of its own that smooths the mesh.
*/

class SmoothHeightMesh
{
protected:
	int maxx, maxy;
	float fmaxx, fmaxy;
	float resolution;
	float smoothRadius;

	float *mesh;
	float *origMesh;

public:
	bool drawEnabled;

	SmoothHeightMesh(const CGround* ground, float maxx_, float maxy_, float resolution_,
			 float smoothRadius_):
			fmaxx(maxx_), fmaxy(maxy_), resolution(resolution_),
			smoothRadius(smoothRadius_),
			mesh(0), origMesh(0),
			drawEnabled(false)
	{
		maxx = fmaxx/resolution + 1;
		maxy = fmaxy/resolution + 1;
		MakeSmoothMesh(ground);
	};
	~SmoothHeightMesh() { delete[] mesh; mesh = 0; delete[] origMesh; origMesh = 0; }

	void MakeSmoothMesh(const CGround* ground);

	float GetHeight(float x, float y);
	float SetHeight(int index, float h);
	float AddHeight(int index, float h);
	float SetMaxHeight(int index, float h);

	int GetMaxX() { return maxx; }
	int GetMaxY() { return maxy; }
	float GetResolution() { return resolution; }

	float* GetMeshData() { return mesh; }
	float* GetOriginalMeshData() { return origMesh; }

	void DrawWireframe(float yoffset);
};


extern SmoothHeightMesh *smoothGround;

#endif // SMOOTHHEIGHTMESH_H