本文整理汇总了C++中IntersectAction类的典型用法代码示例。如果您正苦于以下问题:C++ IntersectAction类的具体用法?C++ IntersectAction怎么用?C++ IntersectAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IntersectAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NumParticles
void GeometryCollisionParticleSystemAffector::affect(ParticleSystemRefPtr System, const Time& elps)
{
UInt32 NumParticles(System->getNumParticles());
Line ray;
IntersectAction *iAct = IntersectAction::create();
Pnt3f ParticlePos, ParticleSecPos;
Real32 HitT(0.0f);
for(UInt32 i(0) ; i<NumParticles ; ++i)
{
ParticlePos = System->getPosition(i);
ParticleSecPos = System->getSecPosition(i);
ray.setValue(ParticleSecPos, ParticlePos);
iAct->setLine(ray);
iAct->apply(getCollisionNode());
if (iAct->didHit())
{
HitT = iAct->getHitT();
if(HitT > 0.0f && HitT*HitT<ParticlePos.dist2(ParticleSecPos))
{
produceParticleCollision(System, i, iAct);
for(UInt32 j(0) ; j<getMFCollisionAffectors()->size(); ++j)
{
getCollisionAffectors(i)->affect(System,i,elps);
}
}
}
}
}
示例2: intersectEnter
ActionBase::ResultE Joint::intersectEnter(Action *action)
{
// Use parent class for trivial reject
if(Inherited::intersect(action) == Action::Skip)
return Action::Skip;
// Need to check children
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
Matrix m = this->getMatrix();
m.mult(this->getJointTransformation());
m.invert();
Pnt3f pos;
Vec3f dir;
m.multFull(ia->getLine().getPosition (), pos);
m.mult (ia->getLine().getDirection(), dir);
Real32 length = dir.length();
if(length < TypeTraits<Real32>::getDefaultEps())
SWARNING << "Joint::intersectEnter: Near-zero scale!" << std::endl;
ia->setLine(Line(pos, dir), ia->getMaxDist());
ia->scale (length );
return ActionBase::Continue;
}
示例3: intersectEnter
Action::ResultE IconLabel::intersectEnter(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
const BoxVolume &bv = ia->getActNode()->getVolume();
if(bv.isValid() && ! bv.intersect(ia->getLine()))
{
return Action::Skip; //bv missed -> can not hit children
}
return Action::Continue;
}
示例4: intersect
Action::ResultE DistanceLOD::intersect(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
#ifndef OSG_2_PREP
const DynamicVolume &vol = ia->getActNode()->getVolume();
#else
const BoxVolume &vol = ia->getActNode()->getVolume();
#endif
UInt32 numLevels = action->getNNodes();
// early out: no children or lod set missed, cannot hit anything
if (numLevels == 0 ||
vol.isValid() && !vol.intersect(ia->getLine()))
{
return Action::Skip;
}
const MFReal32 &range = (*getMFRange());
UInt32 numRanges = range.size();
UInt32 index = 0;
if (numRanges > 0)
{
if (numRanges >= numLevels)
numRanges = numLevels - 1;
if (numRanges == 0)
{
index = 0;
}
else if (_lastDist >= range[numRanges - 1])
{
index = numRanges;
}
else
{
for (index = 0; index < numRanges; ++index)
{
if (_lastDist < range[index])
break;
}
}
}
const NodePtr nodePtr = action->getNode(index);
ia->addNode(nodePtr);
return Action::Continue;
}
示例5: IntersectAction
IntersectAction *IntersectAction::create(const Line &line,
const Real32 maxdist)
{
IntersectAction *act;
if(_prototype)
act = new IntersectAction(*_prototype);
else
act = new IntersectAction();
act->setLine(line, maxdist);
return act;
}
示例6: transformLeave
Action::ResultE transformLeave(CNodePtr& node, Action * action)
{
IntersectAction * ia = dynamic_cast<IntersectAction*>(action);
NodePtr n( node );
Transform* core = dynamic_cast<Transform*>(get_pointer(n->getCore()));
Matrix &m = core->editMatrix();
Pnt3f pos;
Vec3f dir;
m.multFull(ia->getLine().getPosition (), pos);
m.mult (ia->getLine().getDirection(), dir);
ia->setLine( Line( pos, dir ), ia->getMaxDist() );
return Action::Continue;
}
示例7: intersect
Action::ResultE Group::intersect(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
#ifndef OSG_2_PREP
const DynamicVolume &vol = ia->getActNode()->getVolume();
#else
const BoxVolume &vol = ia->getActNode()->getVolume();
#endif
if(vol.isValid() && ! vol.intersect(ia->getLine()))
{
return Action::Skip; //bv missed -> can not hit children
}
return Action::Continue;
}
示例8: intersectLeave
Action::ResultE InverseTransform::intersectLeave(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
Matrix m(_invWorld);
Pnt3f pos;
Vec3f dir;
m.multFull(ia->getLine().getPosition (), pos);
m.mult (ia->getLine().getDirection(), dir);
ia->setLine(Line(pos, dir), ia->getMaxDist());
ia->scale(dir.length());
return Action::Continue;
}
示例9: intersectLeave
ActionBase::ResultE Joint::intersectLeave(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
Matrix m = this->getMatrix();
m.mult(this->getJointTransformation());
Pnt3f pos;
Vec3f dir;
m.multFull(ia->getLine().getPosition (), pos);
m.mult (ia->getLine().getDirection(), dir);
ia->setLine(Line(pos, dir), ia->getMaxDist());
ia->scale(dir.length());
return ActionBase::Continue;
}
示例10: FDEBUG
//! intersection test
Action::ResultE DVRVolume::intersect(Action * action)
{
FDEBUG(("DVRVolume::intersect\n"));
IntersectAction *ia = dynamic_cast<IntersectAction*>(action);
#ifndef OSG_2_PREP
const DynamicVolume &vol = ia->getActNode()->getVolume();
#else
const BoxVolume &vol = ia->getActNode()->getVolume();
#endif
if(vol.isValid() && !vol.intersect(ia->getLine()))
{
return Action::Skip; //bv missed -> can not hit children
}
//!! FIXME: simulate hit when bounding volume is hit
Real32 t, v;
Vec3f norm;
if(vol.intersect(ia->getLine(), t, v))
ia->setHit(t, ia->getActNode(), 0, norm);
return Action::Continue;
}
示例11: intersectEnter
Action::ResultE ScreenGroup::intersectEnter(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
Matrix m(_camTransform);
m.invert();
Pnt3f pos;
Vec3f dir;
m.multFull(ia->getLine().getPosition (), pos);
m.mult (ia->getLine().getDirection(), dir);
ia->setLine(Line(pos, dir), ia->getMaxDist());
ia->scale(dir.length());
return Action::Continue;
}
示例12: intersectEnter
Action::ResultE SkeletonBlendedGeometry::intersectEnter(Action *action)
{
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
Matrix m(_invWorld);
m.invert();
Pnt3f pos;
Vec3f dir;
m.multFull(ia->getLine().getPosition (), pos);
m.mult (ia->getLine().getDirection(), dir);
ia->setLine(Line(pos, dir), ia->getMaxDist());
ia->scale(dir.length());
return Inherited::intersectEnter(action);
}
示例13: intersectEnter
Action::ResultE DynamicTerrain::intersectEnter(Action* action )
{
IntersectAction *ia = dynamic_cast< IntersectAction* >( action );
#ifndef OSG_2_PREP
const DynamicVolume &vol = ia->getActNode()->editVolume(true);
#else
const BoxVolume &vol = ia->getActNode()->editVolume(true);
#endif
Real32 enter = 0, exit = 0;
if(vol.isValid() && !vol.intersect(ia->getLine(), enter, exit))
{
return Action::Skip; //bv missed -> can not hit children
}
Real32 t = enter;
Vec3f normal(0,0,0);
Int32 index = -1;
//if( geoClipmaps_.findFirstIntersection( ia->getLine(), t, normal ) )
{
ia->setHit( t, ia->getActNode(), index, normal );
}
return Action::Continue;
}
示例14: intersect
ActionBase::ResultE Switch::intersect(Action *action)
{
ActionBase::ResultE returnValue = ActionBase::Continue;
IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
if((getChoice() >= 0 ) &&
(UInt32(getChoice()) < ia->getNNodes()) )
{
ia->useNodeList( );
ia->addNode (ia->getNode(getChoice()));
}
else if(getChoice() == ALL)
{
returnValue = ActionBase::Continue;
}
else
{
returnValue = ActionBase::Skip;
}
return returnValue;
}
示例15: geometryEnter
Action::ResultE geometryEnter(CNodePtr& node, Action * action)
{
IntersectAction * ia = dynamic_cast<IntersectAction*>(action);
NodePtr n( node );
Geometry* core = dynamic_cast<Geometry*>(get_pointer(n->getCore()));
TriangleIterator it;
Real32 t;
Vec3f norm;
for ( it = core->beginTriangles(); it != core->endTriangles(); ++it )
{
if ( ia->getLine().intersect( it.getPosition(0),
it.getPosition(1),
it.getPosition(2), t, &norm ) )
{
ia->setHit( t, NodePtr(node), it.getIndex(), norm );
}
}
return Action::Continue;
}