190 likes | 347 Views
3D Game Programming Lab8- 3D Display. Ming-Te Chi Department of Computer Science National Chengchi University. Outline. 3D Viewer Categories 3D Display Device Overview 3D Display Device Setting Simple 3D Project RedBlue GLdirect Quad Buffer. 3D Viewer Categories.
E N D
3D Game ProgrammingLab8- 3D Display Ming-Te Chi Department of Computer Science National Chengchi University
Outline • 3D Viewer Categories • 3DDisplay Device Overview • 3DDisplay Device Setting • Simple 3D Project • RedBlue • GLdirect • Quad Buffer
Complementary Color Anaglyphs • Color filtering • Viewed with glasses and two lenses are different (chromatically opposite) colors, i.e: red & cyan. • left eye-pure red • right eye-pure blue
3DDisplay Device Overview • 3D Monitor Device • 3D Monitor from iZ3D • SAMSUNG SyncMaster 2233RZ • Acer GD245HQ • 3D Glasses • NVIDIA3D Vision glasses • Polarizing glasses • 3D Camera • Fujifilm FinePix REAL 3D
3D Camera • FUJIFILM FinePix REAL 3D W1 • High-precision Lens Alignment Technology for High-quality 3D Image Capture 2 Lenses & CCDs 3D LCD Monitor System
iZ3D Monitor with Polarizing glasses • Device Setting(2 lines ): • 1 front (DVI) ; 1 back (DVI) • Monitor with the addition of a patterned polarizer /retarder layer. • -1 Layer display - 2 Layer display 2D 3D
NVIDIA3D Vision Glasses • Driver: • nVidia Graphics Card • GEFORCE 3D vision glasses • 3D Glasses with Receiver
Shutter Glasses Technology Monitor:120Hz refresh rate Glasses:120Hz synchronized with monitor
System Overview System Requirement • 120Hz Refresh Rate • nVidia Graphics Card • OS:Windows Vista / 7 Input • 3D video camera • OpenGL Programming Output • 3D Vision Photo Viewer • NVIDIAStereoPlayer or OpenGL Programming
Simple 3D Project- RedBlue 嘗試利用CodeBlock編譯此專案 if(i==0) /* left eye - RED */ { Eye = ps.eye; glColorMask(GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE); } else /* if(i==1) right eye - BLUE */ { Eye = -ps.eye; glColorMask(GL_FALSE,GL_FALSE,GL_TRUE,GL_TRUE); }
void glColorMask (GLbooleanred, GLbooleangreen, GLbooleanblue, GLbooleanalpha); • Enable and disable writing of frame buffer color components red, green, blue, alpha • Specify whether red, green, blue, and alpha can or cannot be written into the frame buffer. • GL_TRUE, indicating that the color components can be written.
Key Function switch(key) { case 's': ps.eye = 0.80; /* stereo */ case 'm': ps.eye = 0.0; /* mono */ } switch(ps.solidmode) { case 1: …// Dodecahedron case 2: …// Icosahedron case 3: …// Teapot case 4: …// Sun & Earth }
RedBlue Programming KeyPoint void DisplayFunc(void) { if(i==0) /* left eye - RED */ { Eye = ps.eye; glColorMask(GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE); } else /* if(i==1) right eye - BLUE */ { Eye = -ps.eye; glColorMask(GL_FALSE,GL_FALSE,GL_TRUE,GL_TRUE); } glMatrixMode(GL_PROJECTION); … glMatrixMode(GL_MODELVIEW); … glTranslatef(Eye,0.0,0.0); glTranslated(0,0,-ps.zscreen); … } In the MODELVIEW need to adjust the position of Camera(eye) with object
Simple 3D Project-GLdirect OpenGL & DirectX • 目前3DVision必須使用DirectX並以全螢幕啟動,故範例必須以FullScreen 呈現為基礎 Approach • 將d3dx9_35.dll 及 opengl32.dllcopy至程式所在資料夾 • 目的:將OpenGL(base)->DirectX 以呈現3Deffect • 再按下快捷鍵 啟動/取消 3D Vision OpenGL ->DirectX ( GLDirect ) 2D 3D
OpenGL Quad buffer • OpenGL使用立體顯示時,需要硬體支援quad buffer,也就是在傳統double buffer上(前、後)再加上(左、右)
利用glDrawBuffer(GLenum mode);來指定 glDrawBuffer(GLenum mode); • specify which color buffers are to be drawn into mode Specifies up to four color buffers to be drawn into GL_BACK, GL_LEFT,…etc.
Simple 3D Project-QuadBuffer • In main() glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE | GLUT_STEREO); • 另可透過以下函式查詢是否具備quad buffer GLbooleanbStereo; glGetBooleanv(GL_STEREO, &bStereo);
Simple 3D Project-QuadBuffer Assign particular frame buffer parameter glDrawBuffer(GL_BACK); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDrawBuffer(GL_BACK_LEFT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(- IOD/2,0.0,0.0,0.0,0.0, screenZ,0.0,1.0,0.0); glPushMatrix(); { glTranslated(0.0,0.0,depthZ); draw(); } glPopMatrix(); glDrawBuffer(GL_BACK_RIGHT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(IOD/2, 0.0, 0.0, 0.0, 0.0, screenZ,0.0, 1.0, 0.0); glPushMatrix(); { glTranslated(0.0,0.0,depthZ); draw(); } glPopMatrix(); rtri+=0.2f; rquad-=0.15f; glutSwapBuffers(); } Adjust the left/right eye position