|
楼主 |
发表于 2010-4-18 22:15:44
|
显示全部楼层
10# array
对不起,最近没有上网,上次说的问题:
osg::ref_ptr<osg::Node>CCoreOSG::createEarth()
{
osg::ref_ptr<osg::ShapeDrawable>sd=new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),osg::WGS_84_RADIUS_POLAR));
osg::ref_ptr<osg::Geode>geode=new osg::Geode();
geode->addDrawable(sd.get());
std::string filename("Images/land_shallow_topo_2048.jpg");
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0,new osg::Texture2D(osgDB::readImageFile(filename)));
return geode.get();
}
void CCoreOSG::InitSceneGraph(void)
{
mRoot->addChild(missilePAT.get());
mRoot->addChild(createEarth());
}
void CCoreOSG::InitCameraConfig(void)
{
viewer->addView(view.get());
view->addSlave(camera.get());
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->addChild(mRoot.get());
}
void CCoreOSG:reFrameUpdate()
{
missilePAT->setPosition(position_missile);
missilePAT->setAttitude(rotation_missile);
missilePAT->setScale(osg::Vec3(100.0f,100.0f,100.0f));
camera->setViewMatrixAsLookAt(position_missile+osg::Vec3(50000.0,-50000.0,20000.0),position_missile,osg::Vec3(0.0,0.0,1.0));
position=position_missile;
}
通过外部程序更新PreFrameUpdate()的数据实现模型运动,在加入地球前程序为:
missilePAT->setScale(osg::Vec3(1.0f,1.0f,1.0f));
camera->setViewMatrixAsLookAt(position_missile+osg::Vec3(500.0,-500.0,200.0),position_missile,osg::Vec3(0.0,0.0,1.0));
在加入createEarth()后就必须调大上面的参数才能看见模型,为什么? |
|