Mercurial > hg > Game > Cerium
changeset 1031:92185a81e94b draft
OpenGL mode fix
author | Yutaka_Kinjyo |
---|---|
date | Tue, 16 Nov 2010 14:57:20 +0900 |
parents | ffe6ad89840e |
children | 373576eb10ba |
files | Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/DrawSpan.cc Renderer/Engine/viewerGL.cc |
diffstat | 3 files changed, 26 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Mon Nov 15 22:39:25 2010 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Tue Nov 16 14:57:20 2010 +0900 @@ -186,9 +186,13 @@ //normal3[3] = 1.0f; normal3[3] = 0.0f; - ApplyNormalMatrix(normal1,sg->real_matrix); - ApplyNormalMatrix(normal2,sg->real_matrix); - ApplyNormalMatrix(normal3,sg->real_matrix); + //ApplyNormalMatrix(normal1,sg->real_matrix); + //ApplyNormalMatrix(normal2,sg->real_matrix); + //ApplyNormalMatrix(normal3,sg->real_matrix); + + ApplyMatrix(normal1,sg->real_matrix); + ApplyMatrix(normal2,sg->real_matrix); + ApplyMatrix(normal3,sg->real_matrix); normal1[0] /= normal1[2]; normal1[1] /= normal1[2];
--- a/Renderer/Engine/task/DrawSpan.cc Mon Nov 15 22:39:25 2010 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Tue Nov 16 14:57:20 2010 +0900 @@ -199,7 +199,8 @@ /*完全に透けているか判断, 法線ベクトルが奥を向いてるかどうか*/ - int flag = (alpha != 0 && normal_z < 0); + //int flag = (alpha != 0 && normal_z < 0); + int flag = (alpha != 0); //printf("light_sysswitch %d\n",light_sysswitch);
--- a/Renderer/Engine/viewerGL.cc Mon Nov 15 22:39:25 2010 +0900 +++ b/Renderer/Engine/viewerGL.cc Tue Nov 16 14:57:20 2010 +0900 @@ -127,7 +127,8 @@ glLoadIdentity( ); //正射影 - glOrtho( 0.0, width, height, 0.0, OPENGL_PARAM::near, OPENGL_PARAM::far ); + //glOrtho( 0.0, width, height, 0.0, OPENGL_PARAM::near, OPENGL_PARAM::far ); + glOrtho( 0.0, width, height, 0.0, OPENGL_PARAM::far, OPENGL_PARAM::near ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); @@ -145,7 +146,7 @@ glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0); glDepthFunc(GL_LESS); - glShadeModel(GL_SMOOTH); + //glShadeModel(GL_SMOOTH); } void @@ -210,16 +211,19 @@ xyz1[0] = sg->coord_xyz[(i+0)*3]; xyz1[1] = sg->coord_xyz[(i+0)*3+1]; xyz1[2] = sg->coord_xyz[(i+0)*3+2]*-1.0f; + //xyz1[2] = sg->coord_xyz[(i+0)*3+2]; xyz1[3] = 1.0f; xyz2[0] = sg->coord_xyz[(i+1)*3]; xyz2[1] = sg->coord_xyz[(i+1)*3+1]; xyz2[2] = sg->coord_xyz[(i+1)*3+2]*-1.0f; + //xyz2[2] = sg->coord_xyz[(i+1)*3+2]; xyz2[3] = 1.0f; xyz3[0] = sg->coord_xyz[(i+2)*3]; xyz3[1] = sg->coord_xyz[(i+2)*3+1]; xyz3[2] = sg->coord_xyz[(i+2)*3+2]*-1.0f; + //xyz3[2] = sg->coord_xyz[(i+2)*3+2]; xyz3[3] = 1.0f; // sg->matrix = 回転行列*透視変換行列 @@ -227,47 +231,42 @@ ApplyMatrix(xyz2, sg->matrix); ApplyMatrix(xyz3, sg->matrix); + xyz1[0] /= xyz1[2]; xyz1[1] /= xyz1[2]; xyz2[0] /= xyz2[2]; xyz2[1] /= xyz2[2]; xyz3[0] /= xyz3[2]; xyz3[1] /= xyz3[2]; - + tex_xy1[0] = sg->coord_tex[(i+0)*3]; tex_xy1[1] = sg->coord_tex[(i+0)*3+1]; tex_xy2[0] = sg->coord_tex[(i+1)*3]; tex_xy2[1] = sg->coord_tex[(i+1)*3+1]; tex_xy3[0] = sg->coord_tex[(i+2)*3]; tex_xy3[1] = sg->coord_tex[(i+2)*3+1]; - + normal1[0] = sg->normal[(i+0)*3]; normal1[1] = sg->normal[(i+0)*3+1]; normal1[2] = sg->normal[(i+0)*3+2]*-1.0f; + //normal1[2] = sg->normal[(i+0)*3+2]; normal1[3] = 0.0f; normal2[0] = sg->normal[(i+1)*3]; normal2[1] = sg->normal[(i+1)*3+1]; normal2[2] = sg->normal[(i+1)*3+2]*-1.0f; + //normal2[2] = sg->normal[(i+1)*3+2]; normal2[3] = 0.0f; normal3[0] = sg->normal[(i+2)*3]; normal3[1] = sg->normal[(i+2)*3+1]; normal3[2] = sg->normal[(i+2)*3+2]*-1.0f; + //normal3[2] = sg->normal[(i+2)*3+2]; normal3[3] = 0.0f; - ApplyNormalMatrix(normal1,sg->real_matrix); - ApplyNormalMatrix(normal2,sg->real_matrix); - ApplyNormalMatrix(normal3,sg->real_matrix); - - normal1[0] /= normal1[2]; - normal1[1] /= normal1[2]; - - normal2[0] /= normal2[2]; - normal2[1] /= normal2[2]; - - normal3[0] /= normal3[2]; - normal3[1] /= normal3[2]; + ApplyMatrix(normal1,sg->real_matrix); + ApplyMatrix(normal2,sg->real_matrix); + ApplyMatrix(normal3,sg->real_matrix); obj_draw(xyz1, tex_xy1, normal1); obj_draw(xyz2, tex_xy2, normal2); @@ -302,6 +301,8 @@ void ViewerGL::obj_draw(float *xyz, float *tex_xyz, float *normal_xyz) { + + glTexCoord2f(tex_xyz[0], tex_xyz[1]); glVertex3f(xyz[0], xyz[1], xyz[2]); glNormal3f(normal_xyz[0], normal_xyz[1], normal_xyz[2]);