PDA

View Full Version : c++ terrain loops

mikethebike
01-24-2012, 06:17 AM
Hi
i get z values by feeding/incrementing x and y. So i have for ex. 1-1386 z values and the question how to output those to a field of 128x128? (x/y)
Many thanks

BionicBytes
01-24-2012, 09:46 AM
Hang on a mo.
You posted a cryptic message in the Maths & Alg section

...and now you are doing the same thing again here.

</a>

thokra
01-24-2012, 11:14 AM
128x128 = 16384, so there is no way you're gonna get thos 1386 values assigned with a one to one mapping. You could randomly select 1386 vertices out of the range of [0, 128] but I doubt that makes any sense.

And I have to agree with BionicBytes. I had to read the above linked post of yours about 4 times before I kind of got what you wanted.

mikethebike
01-27-2012, 07:35 AM
for(loopz=0 ; loopz< MapReso; loopz++ ){
same for x...
function returning z WeltAlt
terrainMap[x][loopz][0] = x;
terrainMap[x][loopz][1] = dWeltAlt/100; //altitude
terrainMap[x][loopz][2] = -loopz;

I only need to get dWeltAlt into terrainMap[128][128][3] but
something is wrong....any ideas? Basically I'm following:
http://www.codeproject.com/Articles/14154/OpenGL-Terrain-Generation-An-Introduction
but without success.
Thanks

BionicBytes
01-27-2012, 12:42 PM
Well you could follow it more carefully ....
Seriously. Just how are you suggesting we go about commenting on what's wrong when we don't know what specifically is not working. We are not telepaths you know. you actually need to describe the issue and post relevant code sections.

mikethebike
01-27-2012, 11:12 PM
If I'd know I wouldn't need to ask...
I guess, at least that's what I don't understand is the z returning function takes 2 x and y arguments for each loop x and loopz.
for x
posx++
posy++
for loopz
posx++
posy++
return z (a struct with x,y,z etc values)
now for 2D I only read out those results while x<16384 but how to do alike in 3D?