codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
RenderStatusEnum Renderer::DisplayHeightMap(int id) { float heights[2][2]; float scale, yscale; float xx, zz; Vector* normals; unsigned char* hm_data; normals = hm_value->GetNormals(); hm_data = hm_value->GetData(); int hm_size = hm_value->GetSize(); //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glEnable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); scale = 1; yscale = 0.1; glDisable(GL_LIGHTING); // Draw debug guide if(1) { // First draw X Y Z glColor4f(1, 0, 0,1); glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(hm_size * scale,0,0); glEnd(); glColor4f(0, 1, 0,1); glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(0,hm_size * scale,0); glEnd(); glColor4f(0, 0, 1, 1); glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(0,0,hm_size * scale); glEnd(); glColor4f(0, 0, 0.4, 1); for(int i=0; i< hm_size+1; i++) { glBegin(GL_LINES); glVertex3f(i*scale, 0, 0); glVertex3f(i*scale, 0, hm_size * scale); glVertex3f(0, 0, i*scale); glVertex3f(hm_size * scale, 0, i*scale); glEnd(); } for(int i=0; i< hm_size+1; i++) { glBegin(GL_LINES); glVertex3f(0, i*scale, 0); glVertex3f(hm_size * scale, i*scale, 0); glVertex3f(i*scale, 0, 0); glVertex3f(i*scale, hm_size * scale, 0); glEnd(); } for(int i=0; i< hm_size+1; i++) { glBegin(GL_LINES); glVertex3f(0, i*scale, 0); glVertex3f(0, i*scale, hm_size * scale); glVertex3f(0, 0, i*scale); glVertex3f(0, hm_size * scale, i*scale); glEnd(); } } float specref[] = {1, 1, 1, 1}; glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); for(int x=0; x < hm_size-1; x++) { for(int z=0; z < hm_size-1; z++) { Vector n1; Vector n2; heights[0][0] = (float)hm_data[ x + ((z) * hm_size)]; heights[1][0] = (float)hm_data[ x+1 + ((z) * hm_size)]; heights[0][1] = (float)hm_data[ x + ((z+1) * hm_size)]; heights[1][1] = (float)hm_data[ x+1 + ((z+1) * hm_size)]; n1 = normals[(x + (z * hm_size)) * 2 + 0]; n2 = normals[(x + (z * hm_size)) * 2 + 1]; /*if(n1.y != -1) m_console->printf("Normal: %f %f %f", n1.x, n1.y, n1.z);*/ xx = x * scale; zz = z * scale; glColor4f(0, 1, 0, 1); glBegin(GL_TRIANGLES); glNormal3f(n1.x, n1.y, n1.z); glVertex3f(xx, heights[0][0] * yscale, zz); glVertex3f(xx+ scale, heights[1][0] * yscale, zz); glVertex3f(xx, heights[0][1] * yscale, zz + scale); glEnd(); // Draw the normal ticks /*glPushMatrix(); glColor4f(1, 1, 0, 1); glDisable(GL_LIGHTING); glBegin(GL_LINES); glVertex3f(xx, heights[0][0] * yscale, zz); glVertex3f(xx - n1.x, heights[0][0] * yscale - n1.y, zz - n1.z); glEnd(); glEnable(GL_LIGHTING); glPopMatrix(); glColor4f(0, 1, 0, 1*/ glColor4f(0, 1, 0, 1); // Draw the second triangle glBegin(GL_TRIANGLES); glNormal3f(n2.x, n2.y, n2.z); glVertex3f(xx + scale, heights[1][0] * yscale, zz); glVertex3f(xx + scale, heights[1][1] * yscale, zz + scale); glVertex3f(xx, heights[0][1] * yscale, zz + scale); glEnd(); // Draw the lines overtop of the shit /*glPushMatrix(); glTranslatef(0, 0.01, 0); glColor4f(0, 0, 0, 1); glBegin(GL_LINES); glColor4f(0, 0, 0, 1); glVertex3f(xx, heights[0][0] * yscale, zz); glVertex3f(xx+ scale, heights[1][0] * yscale, zz); glVertex3f(xx, heights[0][1] * yscale, zz + scale); glVertex3f(xx, heights[0][0] * yscale, zz); glVertex3f(xx + scale, heights[1][0] * yscale, zz); glVertex3f(xx + scale, heights[1][1] * yscale, zz + scale); glColor4f(1, 0, 0, 1); glVertex3f(xx, heights[0][1] * yscale, zz + scale); glVertex3f(xx + scale, heights[1][0] * yscale, zz); glEnd(); glPopMatrix();*/ } } glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); return Load_Success; }
Private
[
?
]
Run code
Submit