modeling & simulation

19
Modeling & Simulation

Upload: aliza

Post on 02-Feb-2016

60 views

Category:

Documents


0 download

DESCRIPTION

Modeling & Simulation. Stereographics. Active stereoscopic projection. ※ Needs Glasses with active components(Electronics, batteries..) Single Projector or monitor, fast phosphor required for a good result. 120Hz to minimize flicker. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Modeling & Simulation

Modeling & Simulation

Page 2: Modeling & Simulation
Page 3: Modeling & Simulation

• Stereographics

Page 4: Modeling & Simulation

• Active stereoscopic projection

※ Needs- Glasses with active components(Electronics, batteries..)- Single Projector or monitor, fast phosphor required for a good result.- 120Hz to minimize flicker. - Wired or infrared synchronization between the glasses & video card.

Page 5: Modeling & Simulation

• Passive stereoscopic projection (..we have)

※ Needs- Cheap polaroid glasses, Two projectors & Special projection surface

Page 6: Modeling & Simulation

• Parallax and perceived depth

Page 7: Modeling & Simulation

• Parallax - The distance between screen and virtual object

- Positive : objects behind the screen

- Zero : objects appear at the screen

- Negative : objects appear in front of the screen

• Divergent parallax- Projection screen 에 생성되는 두점 사이의 거리 P 가 두 눈사이의 거리보다 큰 경우 불편함을 느낌- | P | > | left_eye – right_eye | 를 고려하여 Stereo

Implementation

Page 8: Modeling & Simulation

• To understand the stereo display implementation

• Perspective projection

Page 9: Modeling & Simulation

• Use a view of side & top

Page 10: Modeling & Simulation
Page 11: Modeling & Simulation

• Use a view of mono – side & Stereo - top

Page 12: Modeling & Simulation
Page 13: Modeling & Simulation

• Core of Stereo viewing code at left & right

Page 14: Modeling & Simulation

void setStereoPerspective(GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far, GLdouble focalLenght, GLdouble eyeSep, EyeMode eyeMode)

{GLdouble left;GLdouble right;

GLdouble top = near*tan(DTOR*fovy/2); // y clipping plane 의 0 부터의 거리를 계산GLdouble bottom = -top;

GLdouble halfNearWidth = aspect*top; // aspect 에 기초한 x clipping 의 0 부터의 거리를 계산 // aspect : viewport 의 종횡비GLdouble stereoAdjustment = eyeSep/2*near/focalLenght; // equation 연립에 의한 계산식

if(RIGHT == eyeMode){

left = -halfNearWidth - stereoAdjustment; // 오른쪽눈의 left, right 정의right = halfNearWidth - stereoAdjustment;

}else{

left = -halfNearWidth + stereoAdjustment; // 왼쪽눈의 left, right 정의right = halfNearWidth + stereoAdjustment;

}glFrustum(left, right, bottom, top, near, far);/*glFrustum 절두체 즉 , 전체공간상에서 랜더링해야하는 공간만을 잘라낸 것 , 6 개의 인자를 가지며 ,첫번째와 두번째는 절두체를 구성하는 왼쪽과 오른쪽의 수직 평면이며 세번째와 네번째는 위와 아래의 수평평면 ,다섯번째와 여섯번째는 절두체를 구성하는 시선과 수직인 평면으로써 가장 가까운것과 먼것 ( 반드시 양수 )*/

}

• setStereoPerspective

Page 15: Modeling & Simulation

• setStereoLookAt

Page 16: Modeling & Simulation

void setStereoLootAt(GLdouble eyeX,GLdouble eyeY, GLdouble eyeZ, GLdouble centreX, GLdouble centreY, GLdouble centreZ, GLdouble upX, GLdouble upY, GLdouble upZ, GLdouble eyeSep, GLdouble eyeMode)

/* 단순히 카메라는 약간씩 왼쪽 그리고 오른쪽으로 이동한다 . 불행히도 어느방향이 왼쪽 오른쪽인지 3D 모델 공간에서는 사실상 알 수 없다 .그러나 우리는 이런 약간의 방향들을 데이터를 Input 하여 계산해 LookAt 함수에 기존의 좌표에 더해줄 수 있다 .그렇게 해서 stereoLookAt 함수값이 셋팅된다 .*/{

GLdouble inX = centreX - eyeX;GLdouble inY = centreY - eyeY;GLdouble inZ = centreZ - eyeZ;

GLdouble factor = (eyeMode == RIGHT)?1:-1;

GLdouble realEyeCorX = factor*(inY*upZ - upY*inZ); GLdouble realEyeCorY = factor*(inZ*upX - upZ*inX);GLdouble realEyeCorZ = factor*(inX*upY - upX*inY); //vector cross product of "in" with "up"

GLdouble length = sqrt(realEyeCorX*realEyeCorX + realEyeCorY*realEyeCorY + realEyeCorZ*realEyeCorZ);//realEyeCor 벡터의 길이 ( 스칼라 ) 값 계산GLdouble corLengthFactor = eyeSep/(2*length); // 축소비 지정realEyeCorX *=corLengthFactor; realEyeCorY *=corLengthFactor;realEyeCorZ *=corLengthFactor; // 각 realEyeCor 좌표에 축소비를 곱해서 누적연산

gluLookAt(eyeX + realEyeCorX, eyeY + realEyeCorY, eyeZ + realEyeCorZ, centreX, centreY, centreZ, upX, upY, upZ);/* EyeMode 가 right 이면 realEyeCor 은 양수 , left 이면 음수 *//* 모델과 Eye 와의 거리값에 따른 카메라 시선의 위치가 약간씩 변함 *//* 첫번째 xyz 좌표는 바라보는 시선의 위치 , 두번째 xyz 죄표는 모델의 위치 , 세번째는 모델의 top 좌표 ( 모델의 꼭대기부분이 바라보는 좌표위치 )*/

}

Page 17: Modeling & Simulation

• Considering the Parallax

Page 18: Modeling & Simulation

Void stereoproj(float xmin, float xmax, float ymin, float ymax,, float znear, float zfar, float zzps, float dist, float eye)/*stereoproj(-6.0, 6.0, -3, 4.8, 12.0, -12.0, 0.0, 14.5, -0.1) left stereoproj(-6.0, 6.0, -3, 4.8, 12.0, -12.0, 0.0, 14.5, 0.1); right*/{ float xmid, ymid, clip_near, clip_far, top, bottom, left, right, dx, dy, n_over_d; dx = xmax – xmin; dy = ymax – ymin; xmid = (xmax + xmin) / 2.0; ymid = (ymax + ymin) / 2.0;

clip_near = dist + zzps - znear; clip_far = dist + zzps - zfar; // stereo 에 맞는 near & far 재정의

n_over_d = clip_near / dist; // near 와 dist 와의 비

top = n_over_d * dy / 2.0; bottom = -top; right = n_over_d * (dx / 2.0 - eye); left = -n_over_d * (-dx / 2.0 + eye); // n_over_d 와 right or left 와의 삼각비에 의해 계산

glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(left, right, bottom, top, clip_near, clip_far); // 전체공간상에서 랜더링해야 하는 공간만을 잘라내는 절차 */ glTranslatef(-xmid - eye, -ymid, -zzps - dist); // 좌표의 이동}

• setStereoPerspective (with considering of parallax)

Page 19: Modeling & Simulation

• Stereo Display Implementation by OpenGL