Velocity Reviews > C++ > nested for/while loops

# nested for/while loops

Werner
Guest
Posts: n/a

 12-06-2011
On Dec 5, 4:19*pm, ahso <(E-Mail Removed)> wrote:
> Getting closer, now I have lines from top left to bottom right:
>
> * * * * for( int x=0; x< 16384; x++ ){
> draw x,y,z
>
> I need also a y for loop?
> Thanks
> Michael

Michael,

What you have given us is not code... It
is not even psuedo code.

Function...

Output [Appropriate Name] (All necessary input parameters).

Kind regards,

Werner

Nick Keighley
Guest
Posts: n/a

 12-06-2011
On Dec 6, 7:07*am, ahso <(E-Mail Removed)> wrote:

you said

****
So i give that function x,y,z coordinates and if it hits terrain I
get
a result. Now I see why i only get a few points to draw as it hits
around the viewer but loses ground contact in the mountains etc.
I want to get the z (ground contact) within a 128x128 square around
my
position, for a heightmap. (color z in different colors)
Many thanks indeed as I'm stuck...
***

you really do nedd to sit down and think about the problem. What is a
"rectangle"? What is "terrain". What is a "result"?

also: viewer, ground contact, mountains, heightmap, color...

you add new terminology faster tahn you generate sensible requirements

to me this sounds like you might be taking a "slice" though the
terrain. In general this will yield a series of closed curves. And
then finding the point on one of these closed curves that is nearest
to your X,Y position. but I'm doing a *lot* of guessing.

ahso
Guest
Posts: n/a

 12-06-2011
now I did a vector[x/y][rgb]
x or y and the color seems ok now how to draw this?

for( int laty=0; laty< Terrain_Size; laty++ ){
for( int lonx=0; lonx< Terrain_Size; lonx++ ){
draw in opengl colored points
}
}
doesn't obviously work. how should those for loops look like?
Thanks

Fred Zwarts \(KVI\)
Guest
Posts: n/a

 12-06-2011
"ahso" wrote in message
news:(E-Mail Removed)...
>
>now I did a vector[x/y][rgb]
>x or y and the color seems ok now how to draw this?
>
>for( int laty=0; laty< Terrain_Size; laty++ ){
> for( int lonx=0; lonx< Terrain_Size; lonx++ ){
>draw in opengl colored points
>}
>}
>doesn't obviously work. how should those for loops look like?
>Thanks

I don't understand your "obviously". Can you explain why it doesn't work?

Victor Bazarov
Guest
Posts: n/a

 12-06-2011
On 12/6/2011 8:02 AM, ahso wrote:
> now I did a vector[x/y][rgb]
> x or y and the color seems ok now how to draw this?
>
> for( int laty=0; laty< Terrain_Size; laty++ ){
> for( int lonx=0; lonx< Terrain_Size; lonx++ ){
> draw in opengl colored points
> }
> }
> doesn't obviously work.

"Obviously"?... Well, yes, the

draw in opengl colored points

is not C++ code (unless those are names of some macros that, when
substituted, produce compilable C++ code). Try replacing it with, say,

printf("point: %d %d\n", laty, lonx);

and see if it "works" then.

> how should those for loops look like?

The loops look OK, *given* certain assumptions. But my assumptions can
be totally different from yours. State yours, and we can verify.

Also visit: http://catb.org/~esr/faqs/smart-questions.html and
http://www.parashift.com/c++-faq-lite/how-to-post.html

V
--