当前位置: 首页>>代码示例>>C++>>正文


C++ Ray::getIntersectionDistance方法代码示例

本文整理汇总了C++中Ray::getIntersectionDistance方法的典型用法代码示例。如果您正苦于以下问题:C++ Ray::getIntersectionDistance方法的具体用法?C++ Ray::getIntersectionDistance怎么用?C++ Ray::getIntersectionDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ray的用法示例。


在下文中一共展示了Ray::getIntersectionDistance方法的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);
}
开发者ID:B-C,项目名称:raymini,代码行数:12,代码来源:Shadow.cpp

示例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);
}
开发者ID:Rekamux,项目名称:raymini,代码行数:36,代码来源:GLViewer.cpp


注:本文中的Ray::getIntersectionDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。