在使用Camera::getCameraToViewportBoxVolume (Real screenLeft,Real screenTop, Real screenRight, Real screenBottom, boolincludeFarPlane=false)时,不清楚这几个值到底该怎么设置呢?跟我用的屏幕坐标mousePoint(x,y)有什么不一样呢?接 下来总结一下。
常见的Ogre中的屏幕坐标有以下三种方式:
1. 屏幕绝对坐标系。
度量为像素。如左上角为(0,0), 右下角为(800, 600). 这些值分别表示在屏幕宽度和高度上的像素位置。经常也表示为2D的数据,分别表示x方向和y方向。
2. 屏幕相对坐标系。
左下角为(-1,-1),右上角为(1,1),Rectangle2D::setCorners(Real left, Real top,Real right, Real bottom,bool updateAABB = true )用的就是就这个坐标系。 其中left :Left position in screen relative coordinates, -1 = left edge, 1.0 =right edge 。top :Top positionin screen relative coordinates, 1 = top edge, -1 = bottom edge 。right: Right position in screen relativecoordinates 。bottom :Bottomposition in screen relative coordinates 。
3. 屏幕单位化绝对坐标系。
左上角为(0,0),右下角为(1,1),Camera::getCameraToViewportBoxVolume (Real screenLeft, RealscreenTop, Real screenRight, Real screenBottom, bool includeFarPlane=false)就是用的这个坐标系。 screenLeft,screenTop,screenRight,screenBottom The bounds of theon-screen rectangle, expressed in normalised screen coordinates [0,1] 。
由此,1,3之间 是可以相互转化的。不过要首先获取到屏幕的宽度和高度,可以在绝对坐标系和单位话绝对坐标系之间游刃有余了。