Heightmaps

Jaguar7

New member
Heightmaps

אני משתגע, אני כבר עובד הרבה מאוד זמן על פונקציה שאמורה לטעון heightmap. כבר כתבתי אותה פעמים מחדש. אולי מישהו יכול למצוא את הבעיה, נראה כאילו בכל Quad זה עובד על כל התמונה. int tri_x,tri_z; int map_x=0,map_y=0; int map_step=map_w/(step_size); float x=0,z=0; list_index=glGenLists(1); glNewList(list_index,GL_COMPILE); glBegin(GL_QUADS); for(tri_x=0;tri_x<tri_count_x;tri_x++) { for (tri_z=0;tri_z<tri_count_z;tri_z++) { glVertex3f(x,heightmap_data[map_x+map_y*map_w]/255,z); glVertex3f(x+step_size,heightmap_data[map_x+map_step+map_y*map_w]/255,z); glVertex3f(x+step_size,heightmap_data[map_x+map_step+(map_y+map_step)*map_w]/255,z+step_size); glVertex3f(x,heightmap_data[map_x+(map_y+map_step)*map_w]/255,z+step_size); map_x+=map_step; z+=step_size; } map_y+=map_step; x+=step_size; z=0; } glEnd(); glEndList();
 

Jaguar7

New member
יישור לשמאל

int tri_x,tri_z; int map_x=0,map_y=0; int map_step=map_w/(step_size); float x=0,z=0; list_index=glGenLists(1); glNewList(list_index,GL_COMPILE); glBegin(GL_QUADS); for(tri_x=0;tri_x<tri_count_x;tri_x++) { for (tri_z=0;tri_z<tri_count_z;tri_z++) { glVertex3f(x,heightmap_data[map_x+map_y*map_w]/255,z); glVertex3f(x+step_size,heightmap_data[map_x+map_step+map_y*map_w]/255,z); glVertex3f(x+step_size,heightmap_data[map_x+map_step+(map_y+map_step)*map_w]/255,z+step_size); glVertex3f(x,heightmap_data[map_x+(map_y+map_step)*map_w]/255,z+step_size); map_x+=map_step; z+=step_size; } map_y+=map_step; x+=step_size; z=0; } glEnd(); glEndList();​
 

ZDanielZ

New member
Well...

(My Hebrew doesn't work, don't know why). What's the data type and range of values in Heightmap_Data? Maybe, just maybe, you're dividing by 255 and the range of values is 255 as well (to get a value between 1 and 0). BUT, if you divide by 255, and the type of heightmap_data is int, you'll get 0 all the way, because it'll get calculated with integers, and be truncated to zero. In other words, try dividing by 255.0 instead of 255. Good luck, Daniel.​
 

selalerer

New member
הקוד:

int tri_x,tri_z; int map_x=0,map_y=0; int map_step=map_w/(step_size); float x=0,z=0; list_index=glGenLists(1); glNewList(list_index,GL_COMPILE); glBegin(GL_QUADS); for(tri_x=0;tri_x<tri_count_x;tri_x++) { for (tri_z=0;tri_z<tri_count_z;tri_z++) { glVertex3f(x,heightmap_data[map_x+map_y*map_w]/255,z); glVertex3f(x+step_size,heightmap_data[map_x+map_step+map_y*map_w]/255,z); glVertex3f(x+step_size,heightmap_data[map_x+map_step+(map_y+map_step)*map_w]/255,z+step_size); glVertex3f(x,heightmap_data[map_x+(map_y+map_step)*map_w]/255,z+step_size); map_x+=map_step; z+=step_size; } map_y+=map_step; x+=step_size; z=0; } glEnd(); glEndList();​
 
למעלה