40 : region(trgn), patches(0), water_patches(0), water(0),
41 aprons(0), clouds(0), terrain_normals(0)
49 for (
int i = 0; i < 2; i++) {
93 for (i = 0; i < 8; i++)
101 for (i = 0; i < 6; i++)
163 for (i = 0; i < 6; i++) {
175 layer->max_height =
layers.
at(i+1)->min_height;
177 layer->max_height = 1e6;
179 if (layer->tile_name.
length())
180 loader->
LoadTexture(layer->tile_name, layer->tile_texture);
182 if (layer->detail_name.
length())
183 loader->
LoadTexture(layer->detail_name, layer->detail_texture);
193 int j1 = subdivisions - j;
194 Rect rect(j * patch_size, i * patch_size, patch_size, patch_size);
195 Point p1((j1 + offset )*dx, 0, (i + offset )*dz);
198 int index = i*subdivisions+j;
213 double xoffset = offset + 1.0/16.0;
217 for (i = 0; i < 3; i++) {
218 for (j = 0; j < 3; j++) {
220 if (i != 1 || j1 != 1) {
221 Rect rect(j * subdivisions, i * subdivisions, subdivisions, subdivisions);
222 Point p1((j1 + xoffset )*dx, 0, (i + offset )*dz);
242 for (i = 0; i < 3; i++) {
243 for (j = 0; j < 3; j++) {
246 double xloc = (j-1) * 75000 + (rand()/32768.0 - 0.5) * 50000;
247 double yloc = (i-1) * 75000 + (rand()/32768.0 - 0.5) * 50000;
257 for (i = 0; i < 3; i++) {
258 for (j = 0; j < 3; j++) {
261 double xloc = (j-1) * 75000 + (rand()/32768.0 - 0.5) * 50000;
262 double yloc = (i-1) * 75000 + (rand()/32768.0 - 0.5) * 50000;
287 BYTE* alt =
new(__FILE__,__LINE__) BYTE[h*w];
295 for (i = 0; i < w; i++) {
297 alt [(h-1)*w + i] = 0;
299 terrain_normals[(h-1)*w + i] =
Vec3B(128,128,255);
302 for (i = 0; i < h; i++) {
304 alt [i*w + (w-1)] = 0;
306 terrain_normals[i*w + (w-1)] =
Vec3B(128,128,255);
309 for (y = 1; y < h-1; y++) {
310 for (x = 1; x < w-1; x++) {
311 alt[y*w+x] = (BYTE) pix[y*w+x].Red();
315 for (y = 1; y < h-1; y++) {
316 for (x = 1; x < w-1; x++) {
317 double dx = (alt[y*w + (x-1)] - alt[y*w + (x+1)]) * scale +
318 (alt[(y-1)*w + (x-1)] - alt[(y-1)*w + (x+1)]) * scale * 0.5 +
319 (alt[(y+1)*w + (x-1)] - alt[(y+1)*w + (x+1)]) * scale * 0.5;
321 double dy = (alt[(y-1)*w + x ] - alt[(y+1)*w + x ]) * scale +
322 (alt[(y-1)*w + (x-1)] - alt[(y+1)*w + (x-1)]) * scale * 0.5 +
323 (alt[(y-1)*w + (x+1)] - alt[(y+1)*w + (x+1)]) * scale * 0.5;
330 tnorm->
x = (BYTE) (norm.
x * 127 + 128);
331 tnorm->
y = (BYTE) (norm.
y * 127 + 128);
332 tnorm->
z = (BYTE) (norm.
z * 127 + 128);
372 for (i = 0; i < 8; i++)
416 for (i = 0; i < 8; i++)
441 for (
int i = 0; i < 6; i++) {
467 float radius = patch->
Radius();
469 if (loc.
length() < 2*radius) {
474 double threshold = 4;
477 double feature_size = radius / (1 << level);
479 if (projector->
ApparentRadius(loc, (
float) feature_size) > threshold)
516 int iy = (int) floor(y / (
patch_size * scale));
531 h = patch->
Height(px, py);
545 if (detail >= 1 && detail <= 4) {