本文整理汇总了C++中ViewExp::MapScreenToView方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewExp::MapScreenToView方法的具体用法?C++ ViewExp::MapScreenToView怎么用?C++ ViewExp::MapScreenToView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewExp
的用法示例。
在下文中一共展示了ViewExp::MapScreenToView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filename
//.........这里部分代码省略.........
}
// Show quick preview
if(_options->getQuickView()){
float fNear = 1.0f;
float fFar = 1000.0f;
// Get the active viewport and the win32 window within it.
// The position and size will be retreive from this.
ViewExp* viewExp = _ip->GetActiveViewport();
float fov = viewExp->GetFOV();
HWND hWnd = viewExp->getGW()->getHWnd();
RECT sRect;
BOOL ok = GetWindowRect(hWnd, &sRect);
int width = 100;
int height = 100;
int x =100;
int y =100;
if(ok){
x = sRect.left;
y = sRect.top;
width = sRect.right - sRect.left;
height = sRect.bottom - sRect.top;
}
// Create previewer window and set size.
Previewer previewer;
previewer.setWindowSize(x, y, width, height);
// The affine TM transforms from world coords to view coords
// so we need the inverse of this matrix
Matrix3 aTM, camTM, coordSysTM;
Point3 viewDir, viewPos, lookAtPos, upVector;
INode* camera;
float dist = 100;
Point3 upperLeft = viewExp->MapScreenToView(IPoint2(0, 0), fFar);
Point3 lowerRight = viewExp->MapScreenToView(IPoint2(width, height), fFar);
viewExp->GetAffineTM(aTM);
coordSysTM = Inverse(aTM);
viewDir = coordSysTM.VectorTransform(Point3(0.0f, 0.0f, -1.0f));
viewPos = coordSysTM.GetRow(3);
lookAtPos = viewPos + viewDir;
upVector.Set(0.0f, 0.0f, 1.0f);
switch(viewExp->GetViewType()){
case VIEW_ISO_USER:
case VIEW_PERSP_USER:
previewer.setProjectionMatrixAsFrustum(lowerRight.x, upperLeft.x, upperLeft.y, lowerRight.y, fFar, -fFar);
break;
case VIEW_CAMERA:
previewer.setProjectionMatrixAsFrustum(upperLeft.x, lowerRight.x, lowerRight.y, upperLeft.y, fFar, -fFar);
camera = viewExp->GetViewCamera();
camTM = camera->GetObjTMBeforeWSM(_ip->GetTime());
viewDir = camTM.VectorTransform(Point3(0.0f, 0.0f, -1.0f));
viewPos = camTM.GetRow(3);
lookAtPos = viewPos + viewDir;
break;
case VIEW_LEFT:
case VIEW_RIGHT:
case VIEW_TOP:
case VIEW_BOTTOM:
case VIEW_FRONT:
case VIEW_BACK:
previewer.setProjectionMatrixAsOrtho(upperLeft.x, lowerRight.x, lowerRight.y, upperLeft.y, -fFar, fFar);
//cam->setOrtho(upperLeft.x, lowerRight.x, lowerRight.y, upperLeft.y, -fFar, fFar);
// Go far away from the viewing point in the negative viewing direction.
viewPos = coordSysTM.PointTransform(Point3(0.0f, 0.0f, fFar));
lookAtPos = viewPos + viewDir;
// In top view the up vector on the camera is the positive y-axis.
if(viewExp->GetViewType() == VIEW_TOP)
upVector.Set(0.0f, 1.0f, 0.0f);
// In bottom view the up vector on the camera is the negative y-axis.
if(viewExp->GetViewType() == VIEW_BOTTOM)
upVector.Set(0.0f, -1.0f, 0.0f);
break;
}
// When we are done with the viewport we should release it.
_ip->ReleaseViewport(viewExp);
// Set scene data.
previewer.setSceneData(rootTransform.get());
// set the view - OpenGL look at
previewer.setViewMatrixAsLookAt(osg::Vec3( viewPos.x, viewPos.y, viewPos.z),
osg::Vec3(lookAtPos.x, lookAtPos.y, lookAtPos.z),
osg::Vec3(upVector.x, upVector.y, upVector.z) );
previewer.run();
isExporting = FALSE;
return TRUE;
}
}
isExporting = FALSE;
return TRUE;
}