日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

osg动态加载模型不显示_OSG仿真案例(8)——读取FBX格式文件并显示(无动画)...

發布時間:2023/12/2 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 osg动态加载模型不显示_OSG仿真案例(8)——读取FBX格式文件并显示(无动画)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

包含的頭

#include

#include

#include

#include

#include

#include

#include

#include

#include

using namespace std;

所需要的類(結構體)

struct AnimationManagerFinder : public osg::NodeVisitor

{

osg::ref_ptr<:basicanimationmanager> _am;

AnimationManagerFinder()

{

osg::NodeVisitor sss=osg::NodeVisitor::TRAVERSE_ALL_CHILDREN;

}

void apply(osg::Node& node) {

if (_am.valid())

return;

if (node.getUpdateCallback()) {

osgAnimation::AnimationManagerBase* b = dynamic_cast<:animationmanagerbase>(node.getUpdateCallback());

if (b) {

_am = new osgAnimation::BasicAnimationManager(*b);

return;

}

}

traverse(node);

}

};

加載吧顯示模型

void xx()

{

osg::ref_ptr<:viewer> viewer1 = new osgViewer::Viewer;

osg::ref_ptr<:group> group1 = new osg::Group;

osg::ref_ptr<:matrixtransform> matrixTransform1 = new osg::MatrixTransform;

osg::ref_ptr<:node> node1 = osgDB::readNodeFile("E:\\......\\0000.fbx");

AnimationManagerFinder animationManagerFinder1;

group1->accept(animationManagerFinder1);

if (animationManagerFinder1._am.valid())

{

std::string playModeOpt;

osgAnimation::Animation::PlayMode playMode = osgAnimation::Animation::LOOP;

//此處加if的內容

for (osgAnimation::AnimationList::const_iterator animIter = animationManagerFinder1._am->getAnimationList().begin();

animIter != animationManagerFinder1._am->getAnimationList().end();

++animIter)

{

(*animIter)->setPlayMode(playMode);

}

}

matrixTransform1->setMatrix(osg::Matrix::translate(0.0, 0.0, 0.0));

matrixTransform1->addChild(node1);

group1->addChild(matrixTransform1);

viewer1->setSceneData(group1);

viewer1->setUpViewInWindow(200, 200, 800, 600, 0);

viewer1->run();

}

文件夾中數據

模型數據文件中的內容

灰度效果的模型展示

模型顯示

參考技術

https://www.jianshu.com/p/c29f7c2fa865

https://blog.csdn.net/weixin_30622181/article/details/95825855

總結

以上是生活随笔為你收集整理的osg动态加载模型不显示_OSG仿真案例(8)——读取FBX格式文件并显示(无动画)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。