aboutsummaryrefslogtreecommitdiff
path: root/samples/OpenGL/qt_terr/terrain.cpp
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2014-10-07 03:38:55 +0200
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2014-10-07 03:38:55 +0200
commit1e387fc8eee4925616967edd26de0ee416dbce3f (patch)
treef6be0b844c724d6c4891f325912bb4f3f2f26c4b /samples/OpenGL/qt_terr/terrain.cpp
parent3ce7214d2300e2769667649625d160dcdc01499c (diff)
parentb62b7bf28ec0069e6f460fa0f07b64a0dba72557 (diff)
downloadcodesamples-1e387fc8eee4925616967edd26de0ee416dbce3f.tar.gz
codesamples-1e387fc8eee4925616967edd26de0ee416dbce3f.tar.bz2
Merge branch 'master' of git://github.com/datenwolf/codesamples
Diffstat (limited to 'samples/OpenGL/qt_terr/terrain.cpp')
-rw-r--r--samples/OpenGL/qt_terr/terrain.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/samples/OpenGL/qt_terr/terrain.cpp b/samples/OpenGL/qt_terr/terrain.cpp
new file mode 100644
index 0000000..e18efe4
--- /dev/null
+++ b/samples/OpenGL/qt_terr/terrain.cpp
@@ -0,0 +1,36 @@
+#include "terrain.h"
+
+void Terrain::split()
+{
+ if(is_split())
+ return;
+
+ quads[0][0] = new Terrain(V);
+ quads[0][1] = new Terrain(V);
+ quads[1][0] = new Terrain(V);
+ quads[1][1] = new Terrain(V);
+
+ quads[0][0]->set_range(*x1(), *x_mid(), *y1(), *y_mid());
+ quads[0][1]->set_range(*x_mid(), *x2(), *y1(), *y_mid());
+ quads[1][0]->set_range(*x1(), *x_mid(), *y_mid(), *y2());
+ quads[1][1]->set_range(*x_mid(), *x2(), *y_mid(), *y2());
+}
+
+void Terrain::track_down(double x, double y, double nz, int levels)
+{
+ if( levels > 0 ) {
+ int a = ( x < *x_mid() ) ? 0 : 1;
+ int b = ( y < *y_mid() ) ? 0 : 1;
+
+ if( !is_split() )
+ split();
+
+ dynamic_cast<Terrain*>(quads[b][a])->track_down(x, y, nz, levels-1);
+ }
+ else {
+ z[0][0]=
+ z[0][1]=
+ z[1][1]=
+ z[1][0] = z_mean_ = nz;
+ }
+}