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


C++ IntersectAction::setLine方法代码示例

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


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

示例1: affect

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);
                }
			}
		}
	}
}
开发者ID:achvas88,项目名称:OpenSGToolbox,代码行数:32,代码来源:OSGGeometryCollisionParticleSystemAffector.cpp

示例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; 
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:29,代码来源:OSGJoint.cpp

示例3: 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;
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:14,代码来源:OSGIntersectAction.cpp

示例4: 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; 
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:15,代码来源:testIntersectActionRender.cpp

示例5: 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;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:16,代码来源:OSGInverseTransform.cpp

示例6: 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;
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:17,代码来源:OSGJoint.cpp

示例7: 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);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:18,代码来源:OSGSkeletonBlendedGeometry.cpp

示例8: 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;
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:18,代码来源:OSGScreenGroup.cpp

示例9: main


//.........这里部分代码省略.........
        {
            IntersectResult result;

            result._hit  = true;
            result._pObj = pIActorP->getHitObject       ();
            result._tri  = pIActorP->getHitTriangleIndex();
            result._dist = pIActorP->getHitDistance     ();
            result._time = (tStop - tStart);

            resultsP.push_back(result);
        }
        else
        {
            IntersectResult result;

            result._hit  = false;
            result._pObj = NullFC;
            result._tri  = -1;
            result._dist = 0.0;
            result._time = (tStop - tStart);

            resultsP.push_back(result);
        }

        std::string strStatP;
        statP.putToString(strStatP);

        //SINFO << "stat P:   " << strStatP << endLog;

        // Old

        tStart = getSystemTime();

        pIntAction->setLine(*itRays, 100000);
        pIntAction->apply  (pScene         );

        tStop     =  getSystemTime();
        tOTotal += (tStop - tStart);

        if(pIntAction->didHit() == true)
        {
            IntersectResult result;

            result._hit  = true;
            result._pObj = pIntAction->getHitObject  ();
            result._tri  = pIntAction->getHitTriangle();
            result._dist = pIntAction->getHitT       ();
            result._time = (tStop - tStart);

            resultsO.push_back(result);
        }
        else
        {
            IntersectResult result;

            result._hit  = false;
            result._pObj = NullFC;
            result._tri  = -1;
            result._dist = 0.0;
            result._time = (tStop - tStart);

            resultsO.push_back(result);
        }
    }

    UInt32 DFwins      = 0;
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:67,代码来源:testIntersectActor.cpp

示例10: mouseButtonPress

void SpaceNavigatorSSM::mouseButtonPress(UInt16 button, Int16 x, Int16 y)
{
	switch (button)
	{
		case MouseLeft:
			// test if an object is picked
			if(_objectPicking)
			{
				Line ray = calcViewRay(x, y);
				IntersectAction *iAct = IntersectAction::create();
				iAct->setLine(ray);
				iAct->apply(this->getRoot());

				// we have a hit
				if(iAct->didHit())
				{
					_pickedObjectNode = iAct->getHitObject();
					#ifdef SPACENAVIGATOR_DEBUG_OUTPUT
					std::cout << "SpaceNavigatorSSM: Object transformation mode active ( " << getName(_pickedObjectNode) << " )" << std::endl;
					#endif // SPACENAVIGATOR_DEBUG_OUTPUT

					// go up in the graph to the next transformation
					while(!_pickedObjectNode->getCore()->getType().isDerivedFrom(Transform::getClassType()))
					{
						if(_pickedObjectNode->getParent() != this->getRoot())
							_pickedObjectNode = _pickedObjectNode->getParent();
						else
						{
							// insert a new transformation node
							NodePtr pickedObject = iAct->getHitObject();
							TransformPtr newTransform = Transform::create();
							Matrix m;
							m.setIdentity();
							beginEditCP(newTransform, Transform::MatrixFieldMask);
								newTransform->setMatrix(m);
							endEditCP(newTransform, Transform::MatrixFieldMask);

							NodePtr newTransformNode = Node::create();

							beginEditCP(newTransformNode, Node::CoreFieldMask);
								newTransformNode->setCore(newTransform);
							endEditCP(newTransformNode, Node::CoreFieldMask);
							
							NodePtr pickedObjectParent = pickedObject->getParent();

							// add reference because reCount would be 0 and then it will
							// be deleted
							addRefCP(pickedObject);

							beginEditCP(pickedObjectParent);
								pickedObjectParent->replaceChildBy(pickedObject, newTransformNode);
							endEditCP(pickedObjectParent);

							beginEditCP(newTransformNode);
								newTransformNode->addChild(pickedObject);
							endEditCP(newTransformNode);
							
							// sub the reference which was added before
							subRefCP(pickedObject);

							_pickedObjectNode = newTransformNode;
						}
					}

					// a transformation was found and the objects bounding box is showed
					this->setHighlight(_pickedObjectNode);
				}
			}
			_navigator.buttonPress(Navigator::LEFT_MOUSE,x,y);
			break;

		case MouseMiddle: 
			_navigator.buttonPress(Navigator::MIDDLE_MOUSE,x,y);
			break;

		case MouseRight:
			// release picked object and switch off bounding box rendering
			if(_objectPicking)
			{
				_pickedObjectNode = NullFC;
				this->setHighlight(NullFC);
				#ifdef SPACENAVIGATOR_DEBUG_OUTPUT
					std::cout << "SpaceNavigatorSSM: Camera transformation mode active" << std::endl;
				#endif // SPACENAVIGATOR_DEBUG_OUTPUT
			}
			_navigator.buttonPress(Navigator::RIGHT_MOUSE,x,y);
			break;

		case MouseUp:     
			_navigator.buttonPress(Navigator::UP_MOUSE,x,y);
			break;

		case MouseDown:    
			_navigator.buttonPress(Navigator::DOWN_MOUSE,x,y);
			break;
		}

		_mousebuttons |= 1 << button;
		_lastx = x;
		_lasty = y;
//.........这里部分代码省略.........
开发者ID:ufz-vislab,项目名称:vislab,代码行数:101,代码来源:SpaceNavigatorSSM.cpp

示例11: key

void key( unsigned char key, int , int )
{
    switch ( key )
    {
    case 27:    exit(0);
    }
    
    // Intersect
    
    IntersectAction * act = IntersectAction::create();
    
    static Pnt3f pnts[] = { Pnt3f( 0,0,1 ), Pnt3f( 1,0,1),  Pnt3f( 2,0,1), 
                Pnt3f( 3,0,1), Pnt3f( 0,0,1 ), Pnt3f( 0,0,1 ), 
                Pnt3f( 0,0,1 ),Pnt3f( 0,0,1 ), Pnt3f( 0.9,0.9,1 ), 
                Pnt3f(-Inf,-Inf,-Inf) };
    static Vec3f dirs[] = { Vec3f( 0,0,-1), Vec3f( 0,0,-1), Vec3f( 0,0,-1),  
                Vec3f( 0,0,-1), Vec3f( 0,-.2,-1), Vec3f( 0,.2,-1),  
                Vec3f( -.2,-.2,-1), Vec3f( .2,.2,-1), Vec3f( 0,0,-1 ),
                Vec3f(-Inf,-Inf,-Inf) };
    
    static int i = 0;

    act->setLine( Line( pnts[i], dirs[i]) );

    act->apply( iroot );

    std::cerr << "Line " << act->getLine().getPosition() << " dir " 
         << act->getLine().getDirection() << " hit: " << act->didHit() << " ";

    beginEditCP(points);
    points->setValue( pnts[i],                           0 );
    points->setValue( pnts[i] + (dirs[i] * Real32(3.0)), 1 );

    if ( act->didHit() )
    {
        std::cerr << " object " << act->getHitObject() 
             << " tri " << act->getHitTriangle() 
             << " at " << act->getHitPoint();

        TriangleIterator it( act->getHitObject() );
        it.seek( act->getHitTriangle() );
        
        Matrix m;
        act->getHitObject()->getToWorld(m);

        Pnt3f p = it.getPosition(0);
        m.mult(p, p);
        points->setValue( p, 2 );
        p = it.getPosition(1);
        m.mult(p, p);
        points->setValue( p, 3 );
        p = it.getPosition(2);
        m.mult(p, p);
        points->setValue( p, 4 );
    }
    else
    {
        points->setValue( Pnt3f(0,0,0), 2 );
        points->setValue( Pnt3f(0,0,0), 3 );
        points->setValue( Pnt3f(0,0,0), 4 );
    }
    endEditCP(points);

    std::cerr << std::endl;

    glutPostRedisplay();
    
    if ( pnts[++i][0] == -Inf )
        i = 0;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:70,代码来源:testIntersectActionRender.cpp

示例12: keyboard

// react to keys
void keyboard(unsigned char k, int x, int y)
{
    switch(k)
    {
        case 27:    
        {
            OSG::osgExit();
            exit(0);
        }
        break;

        case ' ':   // send a ray through the clicked pixel
                /*
                    Intersection testing for rays is done using an
                    IntersectAction. The ray itself is calculated by the
                    SimpleSceneManager, given the clicked pixel.
                    
                    It needs to be set up with the line that is to be
                    intersected. A line is a semi-infinite ray which has a
                    starting point and a direction, and extends in the
                    direction to infinity.
                    
                    To do the actual test the Action's apply() method is used.
                    
                    The results can be received from the Action. The main
                    difference is if something was hit or not, which is
                    returned in didHit().
                    
                    If an intersection did occur, the other data elements are
                    valid, otherwise they are undefined.
                    
                    The information that is stored in the action is the object
                    which was hit, the triangle of the object that was hit (in
                    the form of its index) and the actual hit position.             
                */
                {
                Line l;
                
                l = mgr->calcViewRay(x, y);

                std::cerr << "From "  << l.getPosition () 
                          << ", dir " << l.getDirection() << std::endl;
    
                IntersectAction *act = IntersectAction::create();
                
                act->setLine(l);
                act->apply(fileroot);
            
                beginEditCP(isectPoints);
                isectPoints->setValue(l.getPosition(), 0);
                isectPoints->setValue(l.getPosition() + l.getDirection(), 1);
            
                // did we hit something?
                if (act->didHit())
                {
                    // yes!! print and highlight it
                    std::cerr << " object " << act->getHitObject  () 
                              << " tri "    << act->getHitTriangle() 
                              << " at "     << act->getHitPoint   ();
                    
                    mgr->setHighlight(act->getHitObject());
                    
                    // stop the ray on the hit surface
                    Pnt3f is = l.getPosition() + 
                                l.getDirection() * act->getHitT();
                                
                    isectPoints->setValue(is, 1);
                    
                    // find the triangle that was hit
                    TriangleIterator it(act->getHitObject());
                    it.seek(act->getHitTriangle());

                    // Draw its normal at the intersection point
                    isectPoints->setValue(is, 2);
                    isectPoints->setValue(is + act->getHitNormal() * 5, 3);

                    
                    // calculate its vertex positions in world space
                    Matrix m;
                    act->getHitObject()->getToWorld(m);
            
                    // and turn them into a triangle
                    Pnt3f p = it.getPosition(0);
                    m.mult(p, p);
                    isectPoints->setValue(p, 4);
                    p = it.getPosition(1);
                    m.mult(p, p);
                    isectPoints->setValue(p, 5);
                    p = it.getPosition(2);
                    m.mult(p, p);
                    isectPoints->setValue(p, 6);
                }
                else
                {
                    // no, get rid of the triangle and highlight.
                    isectPoints->setValue(Pnt3f(0,0,0), 2);
                    isectPoints->setValue(Pnt3f(0,0,0), 3);
                    isectPoints->setValue(Pnt3f(0,0,0), 4);
                    
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:11picking.cpp


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