terrain!?!?
i want to make a loop that will creat terrain using a .raw displacement map, like this:
glBegin(GL_QUADS); for( x = 0; x < 64; x++ )
{
for( z = 0; z < 64; z++ )
{
float_x = float(x)/64.0f; float_y = float(y)/64.0f;
float_xb = float(x+1)/64.0f; //For textures
float_yb = float(y+1)/64.0f; //For textures
glTexCoord2f( float_x, float_y); )
glVertex3f(x, y, z);
glTexCoord2f( float_x, float_yb );
glVertex3f(x, y, z);
glTexCoord2f( float_xb, float_yb );
glVertex3f(x, y, z);
glTexCoord2f( float_xb, float_y );
glVertex3f(x, y, z);
}
}
glEnd();
i want it to find a value for y by using the .raw disp map, is this possible, if so, how can i do this??
any help is really appreciated, samith
ps. sorry if this code is just waaaay out of the ball park, im relativly new to OpenGL
if your raw image buffer already is 64 x 64, just lookup the value at x+y*64 . or have i misunderstood your question ??
Well, I can''t see any array of RAW data there. Your creating the x and z values ok ( although you may want to add a spacing value between the vertices ). The y value should be some scale of the value of the RAW data array at (x,z). So, the y position at the point (x,z) in the 1D RAW data array would be:
"width" is the width of the raw data.
Also, the way you generate texture coodinates would produce pretty awful results. It''d look ok on a flatish terrain, but anything with any kind of gradient would look awful. Try it, you''ll soon see why
y = raw_array[x+z*width]
"width" is the width of the raw data.
Also, the way you generate texture coodinates would produce pretty awful results. It''d look ok on a flatish terrain, but anything with any kind of gradient would look awful. Try it, you''ll soon see why
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement