|
楼主 |
发表于 2012-10-22 08:51:36
|
显示全部楼层
liuzhiyu123 发表于 2012-10-22 08:35
您说的程序停了是什么意思?给出截图,堆栈信息等等,或者您读取的代码
源码是这样的
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/Geode>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <osgViewer/Viewer>
osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime)
{
osg::AnimationPath* animationPath = new osg::AnimationPath;
animationPath->setLoopMode(osg::AnimationPath:OOP);
int numSamples = 40;
float yaw = 0.0f;
float yaw_delta = 2.0f*osg:I/((float)numSamples-1.0f);
float roll = osg::inDegrees(30.0f);
double time=0.0f;
double time_delta = looptime/(double)numSamples;
for(int i=0;i<numSamples;++i)
{
osg::Vec3 position(0,0,0);
osg:uat rotation(osg::Quat(roll,osg::Vec3(0.0,1.0,0.0))*osg::Quat(-(yaw+osg::inDegrees(90.0f)),osg::Vec3(0.0,0.0,1.0)));
animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation));
yaw += yaw_delta;
time += time_delta;
}
return animationPath;
}
osg::Node* createMovingModel(const osg::Vec3& center, float radius)
{
float animationLength = 10.0f;
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
osg::Group* model = new osg::Group;
osg::Node* fountain = osgDB::readNodeFile("fountain.osgt");
fountain ->asGroup() ->getChild(0) ->setNodeMask(0) ;
if (fountain)
{
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0,1.0));
xform->addChild(fountain);
model->addChild(xform);
}
return model;
}
osg::Node* createModel()
{
osg::Vec3 center(0.0f,0.0f,0.0f);
float radius = 1.0f;
osg::Group* root = new osg::Group;
osg::Node* movingModel = createMovingModel(center,radius*0.8f);
root->addChild(movingModel);
return root;
}
int main( int argc, char **argv )
{
osgViewer::Viewer viewer;
osg::Node* model = createModel();
viewer.setSceneData(model);
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
viewer.realize() ;
return viewer.run();
}
程序听了的意思是:
程序运行本来应该出现一个命令行窗口和显示图像的窗口,但是程序只出现命令行窗口,图像一直不显示。
如果调试的话效果也是一样的,没有报错。
如果设置断点可以发现是到osg::Node* fountain = osgDB::readNodeFile("fountain.osgt");这句停住了,后面的句子都没有运行到。
|
|