本文整理汇总了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);
}
}