3D Game Programming Lab8- 3D Display

Preview:

DESCRIPTION

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. - PowerPoint PPT Presentation

Citation preview

3D Game ProgrammingLab8- 3D Display

Ming-Te ChiDepartment of Computer Science 

National Chengchi University

Outline3D Viewer Categories3D Display Device Overview3D Display Device SettingSimple 3D Project – RedBlue– GLdirect– Quad Buffer

3D Viewer Categories

3D displaytechnology

with glasses

*Polarized glasses

*Shutter glasses

*Anaglyphglasses

HMD

withoutglasses

Wiggle stereoscopy

Parallax barrier

Lenticular lens

Complementary Color Anaglyphs

Color filteringViewed with glasses and two lenses

are different (chromatically opposite) colors, i.e: red & cyan.  

• left eye-pure red• right eye-pure blue

3D Display Device Overview3D Monitor Device– 3D Monitor from iZ3D– SAMSUNG SyncMaster 2233RZ– Acer GD245HQ3D Glasses– NVIDIA 3D Vision glasses– Polarizing glasses 3D Camera– Fujifilm FinePix REAL 3D

3D CameraFUJIFILM FinePix REAL 3D W1High-precision Lens Alignment Technology

for High-quality 3D Image Capture

Picture taken from 3D Camera

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

Real Picture taken from Camera

NVIDIA 3D Vision GlassesDriver:– nVidia Graphics Card – GEFORCE 3D vision glasses3D Glasses with Receiver

Shutter Glasses Technology Monitor:120Hz refresh rate

Glasses:120Hz synchronized with

monitor

Real Picture taken from Camera

System OverviewSystem Requirement – 120Hz Refresh Rate– nVidia Graphics Card– OS: Windows Vista / 7

Input– 3D video camera– OpenGL Programming

Output– 3D Vision Photo Viewer– NVIDIAStereoPlayer 

or

OpenGLProgramming

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(GLboolean  red, GLboolean  green, GLboolean  blue, GLboolean

 alpha);– 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 Functionswitch(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 KeyPointvoid 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-GLdirectOpenGL & DirectX– 目前 3D Vision 必須使用 DirectX 並以全螢幕啟動,故範例必須以 FullScreen 呈現為基礎

Approach– 將 d3dx9_35.dll 及 opengl32.dll copy 至程式所在資料夾– 目的 : 將 OpenGL(base)->DirectX 以呈現 3D effect– 再按下快捷鍵 啟動 / 取消 3D Vision

OpenGL ->DirectX ( GLDirect ) 3D 2D

OpenGL Quad buffer

OpenGL 使用立體顯示時,需要硬體支援quad buffer ,也就是在傳統 double buffer 上 ( 前、後 ) 再加上 ( 左、右 )

利用 glDrawBuffer(GLenum mode); 來指定 glDrawBuffer(GLenum mode);– specify which color buffers are to be drawn

intomodeSpecifies up to four color buffers to be drawn

intoGL_BACK, GL_LEFT,…etc.

Simple 3D Project-Quad Buffer

In main()glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH |

GLUT_DOUBLE | GLUT_STEREO);

另可透過以下函式查詢是否具備 quad bufferGLboolean bStereo;glGetBooleanv(GL_STEREO, &bStereo);

Simple 3D Project-Quad Buffer

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();}

Assign particular frame buffer parameter

Adjust the left/right eye position