本文整理汇总了C++中Ray::getIntersectedObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Ray::getIntersectedObject方法的具体用法?C++ Ray::getIntersectedObject怎么用?C++ Ray::getIntersectedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ray
的用法示例。
在下文中一共展示了Ray::getIntersectedObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hard
bool Shadow::hard(const Vec3Df & pos, const Vec3Df& light) const {
Ray riShadow;
Vec3Df dir = light - pos;
float dist = dir.normalize();
bool inter = rt->intersect(dir, pos, riShadow);
if(inter && dynamic_cast<const Glass *>(&riShadow.getIntersectedObject()->getMaterial()))
return true;
return !inter || (inter && riShadow.getIntersectionDistance() > dist);
}
示例2: mousePressEvent
void GLViewer::mousePressEvent(QMouseEvent * event) {
const WindowModel *windowModel = controller->getWindowModel();
if (windowModel->isDragEnabled()) {
float fov, ar;
float screenWidth;
float screenHeight;
Vec3Df camPos;
Vec3Df viewDirection;
Vec3Df upVector;
Vec3Df rightVector;
getCameraInformation(fov, ar, screenWidth, screenHeight, camPos, viewDirection, upVector, rightVector);
float tanX = tan(fov)*ar;
float tanY = tan(fov);
Vec3Df stepX = (float (event->x()) - screenWidth/2.f)/screenWidth * tanX * rightVector;
Vec3Df stepY = (float (screenHeight-event->y()) - screenHeight/2.f)/screenHeight * tanY * upVector;
Vec3Df step = stepX + stepY;
Vec3Df dir = viewDirection + step;
float distanceCameraScreen = dir.getLength();
dir.normalize();
Ray ray;
if (controller->getRayTracer()->intersect(dir, camPos, ray)) {
Object *o=ray.getIntersectedObject();
QPoint p = event->globalPos();
Vec3Df oPos = o->getTrans();
float ratio = distanceCameraScreen/sqrt(ray.getIntersectionDistance());
controller->viewerStartsDragging(o, oPos, p, ratio);
}
}
if (!controller->getWindowModel()->isRealTime()) {
controller->viewerSetDisplayMode(WindowModel::OpenGLDisplayMode);
}
else {
controller->forceThreadUpdate();
}
QGLViewer::mousePressEvent(event);
}