本文整理汇总了C++中SbViewVolume::projectPointToLine方法的典型用法代码示例。如果您正苦于以下问题:C++ SbViewVolume::projectPointToLine方法的具体用法?C++ SbViewVolume::projectPointToLine怎么用?C++ SbViewVolume::projectPointToLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbViewVolume
的用法示例。
在下文中一共展示了SbViewVolume::projectPointToLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: projectTelePointer
//======================================================================
//
// Description:
// projection of telepointer
//
//
// Use: private
//======================================================================
void TPHandler::projectTelePointer(TelePointer *, const SbVec3f pos, float aspectRatio,
SbVec3f &intersection, InvExaminerViewer *viewer)
{
const int xOffset = 61;
const int yOffset = 33;
float xs, ys, zs; // normalized screen coordinates
SbVec3f screen;
SbVec2s size = viewer->getSize();
if (viewer->isDecoration())
{
// !! Attention: SoXtRenderArea with offset
size[0] = size[0] - xOffset;
size[1] = size[1] - yOffset;
}
float aspRat = size[0] / (float)size[1];
// set aspect ratio explicitely
tp_camera->aspectRatio.setValue(aspRat);
// default setting
tp_camera->height.setValue(2.0);
// scale height
tp_camera->scaleHeight(1 / aspRat);
/*
float h = tp_camera->height.getValue();
fprintf(stderr, "Height Camera: %.6f\n", h);
*/
// get the view volume -> rectangular box
SbViewVolume viewVolume = tp_camera->getViewVolume();
// determine mouse position
viewVolume.projectToScreen(pos, screen);
screen.getValue(xs, ys, zs);
/*
cerr << "xs: " << xs << endl;
cerr << "ys: " << ys << endl;
*/
// project the mouse point to a line
SbVec3f p0, p1;
viewVolume.projectPointToLine(SbVec2f(xs, ys), p0, p1);
// take the midpoint of the line as telepointer position
intersection = (p0 + p1) / 2.0f;
// adapt telepointer position to the aspect ratio
if (aspectRatio > 1.0)
{
intersection[0] = intersection[0] * aspectRatio / aspRat;
intersection[1] = intersection[1] * aspectRatio / aspRat;
}
if (aspectRatio < 1.0)
{
// in this case the aspect ratio submitted to the function
// and belonging to the delivered position leads to wrong projection point
// => local correction for x-, y-value
intersection[0] = intersection[0] / aspRat;
intersection[1] = intersection[1] / aspRat;
}
/*
float fx,fy,fz;
intersection.getValue(fx,fy,fz);
cerr << "TP: (" << fx << "," << fy << "," << fz << ")" << endl;
*/
}