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


C++ Hit::getWorldIntersectPoint方法代码示例

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


在下文中一共展示了Hit::getWorldIntersectPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: intersect

void coTouchIntersection::intersect(const osg::Matrix &handMat, bool mouseHit)
{

    cerr << "coTouchIntersection::intersect info: called" << endl;

    Vec3 q0, q1, q2, q3, q4, q5;

    // 3 line segments for interscetion test hand-object
    // of course this test can fail
    q0.set(0.0f, -0.5f * handSize, 0.0f);
    q1.set(0.0f, 0.5f * handSize, 0.0f);
    q2.set(-0.5f * handSize, 0.0f, 0.0f);
    q3.set(0.5f * handSize, 0.0f, 0.0f);
    q4.set(0.0f, 0.0f, -0.5f * handSize);
    q5.set(0.0f, 0.0f, 0.5f * handSize);

    // xform the intersection line segment
    q0 = handMat.preMult(q0);
    q1 = handMat.preMult(q1);
    q2 = handMat.preMult(q2);
    q3 = handMat.preMult(q3);
    q4 = handMat.preMult(q4);
    q5 = handMat.preMult(q5);

    ref_ptr<LineSegment> ray1 = new LineSegment();
    ref_ptr<LineSegment> ray2 = new LineSegment();
    ref_ptr<LineSegment> ray3 = new LineSegment();
    ray1->set(q0, q1);
    ray2->set(q2, q3);
    ray3->set(q4, q5);

    IntersectVisitor visitor;
    visitor.addLineSegment(ray1.get());
    visitor.addLineSegment(ray2.get());
    visitor.addLineSegment(ray3.get());

    cover->getScene()->traverse(visitor);

    ref_ptr<LineSegment> hitRay = 0;

    if (visitor.getNumHits(ray1.get()))
        hitRay = ray1;
    else if (visitor.getNumHits(ray2.get()))
        hitRay = ray2;
    else if (visitor.getNumHits(ray3.get()))
        hitRay = ray3;

    if (visitor.getNumHits(hitRay.get()))
    {
        Hit hitInformation = visitor.getHitList(hitRay.get()).front();
        cover->intersectionHitPointWorld = hitInformation.getWorldIntersectPoint();
        cover->intersectionHitPointLocal = hitInformation.getLocalIntersectPoint();
        cover->intersectionMatrix = hitInformation._matrix;
        cover->intersectedNode = hitInformation._geode;
        // walk up to the root and call all coActions
        OSGVruiHit hit(hitInformation, mouseHit);
        OSGVruiNode node(cover->intersectedNode.get());
        callActions(&node, &hit);
    }
}
开发者ID:nixz,项目名称:covise,代码行数:60,代码来源:coTouchIntersection.cpp


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