// v2DScreen : 2D 화면 좌표
// plane : 화면 좌표 위치에 해당하는 점을 체크할 3D 공간상의 평면
// vPickPos : 2D 화면 좌표에 대응하는 3D 평면 상의 좌표
Ogre::Vector2 v2DScreen(100, 120);
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::Vector3 vPickPos(0, 0, 0);

unsigned int iWidth, iHeight, iColor;
int iLeft, iTop;
mWindow->getMetrics(iWidth, iHeight, iColor, iLeft, iTop);

Ogre::Ray mouseRay = mCamera->getCameraToViewportRay(v2DScreen.x/float(iWidth), v2DScreen.y/float(iHeight));
std::pair <bool, Ogre::Real> ret = mouseRay.intersects(plane);
if(ret.first)
{
    vPickPos = mouseRay.getPoint(ret.second);
}


블로그 이미지

영스파파

3D 세상을 만들기 위한 프로그래밍 정보들을 정리하는 공간

,