|
本帖最后由 tujie2652324 于 2011-11-21 16:42 编辑
就是现在导航器做出来了,我想在导航地图上用文字标记一些地方,这个能实现吗?求教各位了。。。
这个导航是根据FreeSouth的视频教程里面那样创建一个主相机和一个烘焙相机实现的。
另外一个就是碰撞检测和上楼梯算法的结合问题。。。
osg::Vec3 newpos = m_vPosition + delta;
osg::Vec3d start = osg::Vec3d(newpos.x(),newpos.y(),newpos.z()+8);
osg::Vec3d end = osg::Vec3d(newpos.x(),newpos.y(),newpos.z()-1000);
osg::Vec3d start2 = osg::Vec3d(m_vPosition.x(),m_vPosition.y(),m_vPosition.z());
osg::Vec3d end2 = osg::Vec3d(newpos.x(),newpos.y(),newpos.z());
osgUtil:ineSegmentIntersector::Intersections intersections;
osg::ref_ptr<osgUtil::LineSegmentIntersector> ls = new osgUtil::LineSegmentIntersector(start,end);
osg::ref_ptr<osgUtil::LineSegmentIntersector> ls2 = new osgUtil::LineSegmentIntersector(start2,end2);
osg::ref_ptr<osgUtil::IntersectionVisitor> iv = new osgUtil::IntersectionVisitor;
osg::ref_ptr<osgUtil::IntersectorGroup> lg = new osgUtil::IntersectorGroup;
//osg::LineSegment::Intersections intersections;
long height = 0;
lg->addIntersector(ls.get());
lg->addIntersector(ls2.get());
iv->setIntersector(lg.get());
m_node->accept(*(iv.get()));
if (!ls2->containsIntersections())
{
//取出交点
intersections = ls->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator iter = intersections.begin();
height = iter->getWorldIntersectPoint().z();
for (; iter != intersections.end();iter++)
{
if (height < iter->getWorldIntersectPoint().z())
{
height = iter->getWorldIntersectPoint().z();
}
}
}
else
{
return;
}
m_vPosition += delta;
m_vPosition.set(osg::Vec3d(m_vPosition.x(),m_vPosition.y(),height+1));
这样写可以实现么?有没有更好的实现方法???
|
|