在3D中, 将世界坐标映射为屏幕上的坐标点
2010-12-07 11:04
337 查看
首先介绍Ogre中的方法:
再谈谈直接使用OpenGL的方法:
参数解释一下,
cam_model_mat: camera model matrix
cam_proj_mat: camera projection matrix
cam_viewport: camera viewport
xfpcoord[0]: 屏幕X
xfpcoord[1]: 屏幕Y
Vector3 tartgetpos; Ogre::Matrix4 viewMat = mCamera->getViewMatrix(); Ogre::Matrix4 projMat = mCamera->getProjectionMatrix(); Ogre::Vector3 screenPos = projMat * viewMat * tartgetpos; float x = (screenPos.x + 1.0f)/ 2.0f; float y = -1*(screenPos.y - 1.0f) / 2.0f;
再谈谈直接使用OpenGL的方法:
Vector3 pos(...); //物体的位置 double xfpcoord[3]; gluProject(pos.x,pos.y,pos.z,cam_model_mat,cam_proj_mat,cam_viewport,&xfpcoord[0],&xfpcoord[1],&xfpcoord[2]);
参数解释一下,
cam_model_mat: camera model matrix
cam_proj_mat: camera projection matrix
cam_viewport: camera viewport
xfpcoord[0]: 屏幕X
xfpcoord[1]: 屏幕Y
相关文章推荐
- D3D坐标系统下3D世界坐标映射到2D屏幕坐标的平移矩阵
- 在3D中, 将世界坐标映射为屏幕上的坐标点
- 自制3D显示引擎十:三维坐标在屏幕上的映射
- Android OpenGL ES 2.0 屏幕坐标和3D世界坐标转换
- 屏幕坐标到世界坐标
- OpenGL通过读取Z Buffer深度值将屏幕2D坐标转化为场景3D坐标(含完整源码)
- 世界坐标物体在屏幕上的方位显示
- OGRE的2D坐标、CEGUI坐标、鼠标坐标、 世界坐标转屏幕坐标
- VTK屏幕坐标与世界坐标转换(Qt)
- UGUI世界坐标转屏幕坐标
- Vuforia在Unity中屏幕坐标转世界坐标,并使用lineRender画线,手指画线,选中物体并拖拽
- 屏幕坐标到世界坐标
- 读取Z Buffer深度值将屏幕2D坐标转化为场景3D坐标源码
- Unity UGUI坐标转为3D世界坐标 世界左边转为UGUI坐标
- Quake3平面Surface的光照贴图(light map)UV坐标与Surface顶点世界3D坐标之间的转换原理
- OSG中屏幕坐标和世界坐标的转化
- 通过读取Z Buffer深度值将屏幕2D坐标转化为场景3D坐标(含程序和源码)
- 三维世界坐标转化为二维屏幕坐标
- 3D物体在UGUI下的坐标映射
- [unity3d]屏幕坐标跟世界坐标的转换