Picking gl Get IntegervGLVIEWPORT viewport switch to projection

  • Slides: 10
Download presentation

Picking 영역 gl. Get. Integerv(GL_VIEWPORT, viewport); // 뷰포트의 윈도좌표 구하기 // switch to projection

Picking 영역 gl. Get. Integerv(GL_VIEWPORT, viewport); // 뷰포트의 윈도좌표 구하기 // switch to projection and save the matrix gl. Matrix. Mode(GL_PROJECTION); gl. Push. Matrix(); gl. Render. Mode(GL_SELECT); gl. Load. Identity(); glu. Pick. Matrix(x, y, 2, 2, viewport); (1) // Create picking volume glu. Perspective(45. 0 f, m_f. Aspect, 1. 0, 350. 0); (2) � // Apply perspective matrix (1) : picking 영역설정(x, y, width, height, viewport) - x, y: 마우스 클릭한 위치 좌표 - width, height: 윈도픽셀로 picking 한 영역의 높이와 넓이를 의미. 이 값이 크면 객 체 외부를 클릭해도 객체로 인식할 수가 있음. � (2) : perspective projection 적용(fovy, aspect, z. Near, z. Far) - fovy: y방향에서 뷰 앵글 - aspect: x/y의 종횡비로 x방향의 뷰 앵글을 결정하는데 사용. - z. Near, z. Far: 항상 양의 값을 가지며, 관측자와 클리핑 평면 사이의 거리를 나타 냄. 8

14. 4 3 D 오브젝트 선택하기 � 오브젝트 구별하기 - 객체가 선택되고 나면 selection

14. 4 3 D 오브젝트 선택하기 � 오브젝트 구별하기 - 객체가 선택되고 나면 selection buffer에 히트 레코드가 채워지 게 된다. 이 때 세번째 배열의 값이 객체의 이름이므로, 그 값을 참 조하면 어떤 객체가 선택되었는지 알 수 있다. hits = gl. Render. Mode(GL_RENDER); // collect the hits if(hits == 1) Process. Select(select. Buff[3]); void CBasement. View: : Process. Select(GLuint id) { switch(id) { case 1: Afx. Message. Box("Yellow sphere is clicked!"); break; case 2: Afx. Message. Box("Grey torus is clicked!"); break; . . . default: break; } } 9