summaryrefslogtreecommitdiff
path: root/common/terrain.h
diff options
context:
space:
mode:
authordocwhat1999-11-14 06:43:18 +0000
committerdocwhat1999-11-14 06:43:18 +0000
commitd71eec8062e852e56f03102ba4b4e87dc485821d (patch)
tree452368ad0e7e24627e517a0c88c2508d02cea6dc /common/terrain.h
parent2046090b7ce8dd901ce43e650be5acf44016d714 (diff)
Initial revision
git-svn-id: http://svn.leocad.org/trunk@2 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/terrain.h')
-rw-r--r--common/terrain.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/common/terrain.h b/common/terrain.h
new file mode 100644
index 0000000..9c41e29
--- /dev/null
+++ b/common/terrain.h
@@ -0,0 +1,92 @@
+//
+// terrain.h
+////////////////////////////////////////////////////
+
+#ifndef _TERRAIN_H_
+#define _TERRAIN_H_
+
+#include "defines.h"
+
+typedef struct {
+ float corners[8][3];
+ float minX, minY, minZ;
+ float maxX, maxY, maxZ;
+
+ void InitBox(float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
+} PATCHBOX;
+
+typedef struct PATCH
+{
+ PATCH()
+ {
+ vertex = NULL;
+ normals = NULL;
+ coords = NULL;
+ index = NULL;
+ steps = 10;
+ visible = true;
+ };
+
+ float control[48]; // 4x4 grid
+ unsigned short steps;
+
+ float* vertex;
+ float* normals;
+ float* coords;
+ unsigned short* index;
+
+ PATCHBOX box;
+ bool visible;
+ void Tesselate(bool bNormals);
+ void FreeMemory();
+} PATCH;
+
+class File;
+class Camera;
+class Texture;
+
+class Terrain
+{
+public:
+ Terrain();
+ ~Terrain();
+ Terrain& operator=(const Terrain& source);
+
+ void LoadTexture(bool bLinear);
+ void Render(Camera* pCam, float aspect);
+ void LoadDefaults(bool bLinear);
+ void SetSize(float uSize, float vSize);
+ void GetSize(float *uSize, float *vSize);
+ void FileLoad(File* file);
+ void FileSave(File* file);
+ void Tesselate();
+ void SetControlPoints();
+ void GenerateRandom();
+
+ void SetPatchCount(int uPatches, int vPatches);
+ void GetPatchCount(int *uCount, int *vCount);
+ int GetCountU()
+ { return m_uPatches != 0 ? m_uPatches*3 + 1 : 0; }
+ int GetCountV()
+ { return m_vPatches != 0 ? m_vPatches*3 + 1 : 0; }
+ float** GetControlPoints()
+ { return m_pControl; }
+
+ unsigned long m_nOptions;
+ char m_strTexture[LC_MAXPATH];
+ float m_fColor[3];
+
+protected:
+ void FreeMemory();
+ void FindVisiblePatches(Camera* pCam, float aspect);
+
+ float** m_pControl;
+ PATCH** m_Patches;
+ int m_uPatches;
+ int m_vPatches;
+ float m_uSize;
+ float m_vSize;
+ Texture* m_pTexture;
+};
+
+#endif // _TERRAIN_H_