Exemplo n.º 1
0
osg::ref_ptr<osg::AnimationPath> CVehicle::outputScene(const osg::ref_ptr<osg::Vec3Array>& junctionArray , double width, unsigned int num)
{
	osg::ref_ptr<osg::Vec3Array> driveway = new osg::Vec3Array;
	for (int i = 0; i != m_index.size(); i++ )
	{
		driveway->push_back((*junctionArray)[m_index[i]]);
	}

	m_loc = rand() % num ;
	double w = width / 2.0 + width * m_loc;
	generatePath(driveway,w);


	
	typedef osg::AnimationPath::ControlPoint ControlPoint;
	osg::Vec3 yoz(1.0, 0.0, 0.0), xoz(0.0, 1.0, 0.0), xoy(0.0, 0.0, 1.0);
	osg::ref_ptr<osg::AnimationPath> path = new osg::AnimationPath;




	double m = 0;

	for (int i = 0; i != m_index.size(); i++ )
	{
		if( i == 0)
		{
			path->insert( 0,
				ControlPoint((*driveway)[i],osg::Quat( 0.0,yoz,0.0,xoz, 0.0,xoy)) );
			
		}

		else
		{
			m += m_angleList[i-1];
				
			path->insert( (i-1) * m_speed + 0.1,
				ControlPoint((*driveway)[i-1],osg::Quat( 0.0,yoz,0.0,xoz,m,xoy)) );
			path->insert( i * m_speed , 
				ControlPoint((*driveway)[i],osg::Quat( 0.0,yoz,0.0,xoz,m,xoy)) );
		
		}

	}

	return path.release();

}
Exemplo n.º 2
0
osg::AnimationPath* createPath()
{
    typedef osg::AnimationPath::ControlPoint ControlPoint;
    osg::Vec3 yoz(1.0, 0.0, 0.0), xoz(0.0, 1.0, 0.0), xoy(0.0, 0.0, 1.0);
    osg::ref_ptr<osg::AnimationPath> path = new osg::AnimationPath;
    
    path->insert( 0.0,
        ControlPoint(osg::Vec3(0.0,0.0,0.0), osg::Quat(    0.0,yoz,0.0,xoz,    0.0,xoy)) );
    path->insert( 2.0,
        ControlPoint(osg::Vec3(5.0,0.0,0.0), osg::Quat(osg::PI,yoz,0.0,xoz,    0.0,xoy)) );
    path->insert( 4.0,
        ControlPoint(osg::Vec3(5.0,0.0,5.0), osg::Quat(osg::PI,yoz,0.0,xoz,osg::PI,xoy)) );
    path->insert( 6.0,
        ControlPoint(osg::Vec3(0.0,0.0,5.0), osg::Quat(    0.0,yoz,0.0,xoz,osg::PI,xoy)) );
    path->insert( 8.0,
        ControlPoint(osg::Vec3(0.0,0.0,0.0), osg::Quat(    0.0,yoz,0.0,xoz,    0.0,xoy)) );
    return path.release();
}