#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32 #include <osg/Group>
#include <osg/Camera>
#include <osg/Node>
#include <osg/Geometry> #include <osg/Image>
#include <osg/ShapeDrawable>
#include <osg/Texture2D>
#include <osg/MatrixTransform> #include <osg/AnimationPath>
#include <osg/ArgumentParser>
#include <osg/NodeVisitor> #include <osgDB/FileNameUtils>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers> #include <osgGA/DriveManipulator>
#include <osgGA/GUIEventHandler>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIActionAdapter> #include <osgGA/AnimationPathManipulator>
#include <osgGA/KeySwitchMatrixManipulator> #include <osgUtil/LineSegmentIntersector>
#include <osgAnimation/BasicAnimationManager> #include <iostream>
using namespace std; struct AnimationManagerFinder : public osg::NodeVisitor
{
osg::ref_ptr<osgAnimation::BasicAnimationManager> _am;
AnimationManagerFinder() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Node& node) {
if (_am.valid())
return;
if (node.getUpdateCallback()) {
osgAnimation::AnimationManagerBase* b = dynamic_cast<osgAnimation::AnimationManagerBase*>(node.getUpdateCallback());
if (b) {
_am = new osgAnimation::BasicAnimationManager(*b);
return;
}
}
traverse(node);
}
}; int main(int argc, char** argv)
{
//osg::ArgumentParser arguments(&argc, argv);
osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> group1 = new osg::Group;
osg::ref_ptr<osg::MatrixTransform> matrixTransform1 = new osg::MatrixTransform; osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("I:\\BIM\\fbx\\Worker201907.fbx");
//osg::ref_ptr<osgAnimation::BasicAnimationManager> basicAnimationManager1 = dynamic_cast<osgAnimation::BasicAnimationManager*>(node1->getUpdateCallback());
/*
osgAnimation::BasicAnimationManager* basicAnimationManager1 = dynamic_cast<osgAnimation::BasicAnimationManager*>(node1->getUpdateCallback());
osgAnimation::AnimationList animationList1 = basicAnimationManager1->getAnimationList();
osgAnimation::AnimationList::iterator animationList_iter;
for (animationList_iter = animationList1.begin();animationList_iter != animationList1.end();++animationList_iter)
{
std::string name = (*animationList_iter)->getName();
std::cout << name << std::endl;
basicAnimationManager1->playAnimation(*animationList_iter);
}
*/
/*
for (unsigned int i = 0; i<animationList1.size(); ++i)
{
const std::string& name = animationList1[i]->getName();
basicAnimationManager1->playAnimation(animationList1[i].get());
if (true)
{
std::cout << name << std::endl;
}
}
*/
AnimationManagerFinder animationManagerFinder1;
group1->accept(animationManagerFinder1); if (animationManagerFinder1._am.valid())
{
std::string playModeOpt;
osgAnimation::Animation::PlayMode playMode = osgAnimation::Animation::LOOP; if (osgDB::equalCaseInsensitive(playModeOpt, "ONCE"))
{
playMode = osgAnimation::Animation::ONCE;
}
else if (osgDB::equalCaseInsensitive(playModeOpt, "STAY"))
{
playMode = osgAnimation::Animation::STAY;
}
else if (osgDB::equalCaseInsensitive(playModeOpt, "LOOP"))
{
playMode = osgAnimation::Animation::LOOP;
}
else if (osgDB::equalCaseInsensitive(playModeOpt, "PPONG"))
{
playMode = osgAnimation::Animation::PPONG;
} 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(, , , , );
return viewer1->run();
}

export root node
Node : RootNode
Node : RootNode
Node : construction_worker
Node : Bip001
Node : Bip001 Pelvis
Node : Bip001 Spine
Node : Bip001 Spine1
Node : Bip001 Neck
Node : Bip001 L Clavicle
Node : Bip001 L UpperArm
Node : Bip001 L Forearm
Node : Bip001 L Hand
Node : Bip001 L Finger0
Node : Bip001 L Finger01
Node : Bip001 L Finger02
Node : Bip001 L Finger1
Node : Bip001 L Finger11
Node : Bip001 L Finger12
Node : Bip001 L Finger2
Node : Bip001 L Finger21
Node : Bip001 L Finger22
Node : Bip001 L Finger3
Node : Bip001 L Finger31
Node : Bip001 L Finger32
Node : Bip001 L Finger4
Node : Bip001 L Finger41
Node : Bip001 L Finger42
Node : Bip001 R Clavicle
Node : Bip001 R UpperArm
Node : Bip001 R Forearm
Node : Bip001 R Hand
Node : Bip001 R Finger0
Node : Bip001 R Finger01
Node : Bip001 R Finger02
Node : Bip001 R Finger1
Node : Bip001 R Finger11
Node : Bip001 R Finger12
Node : Bip001 R Finger2
Node : Bip001 R Finger21
Node : Bip001 R Finger22
Node : Bip001 R Finger3
Node : Bip001 R Finger31
Node : Bip001 R Finger32
Node : Bip001 R Finger4
Node : Bip001 R Finger41
Node : Bip001 R Finger42
Node : Bip001 Head
Node : helmet_bone
Node : Bip001 L Thigh
Node : Bip001 L Calf
Node : Bip001 L Foot
Node : Bip001 L Toe0
Node : hip_adjustment_bone_left
Node : Bip001 R Thigh
Node : Bip001 R Calf
Node : Bip001 R Foot
Node : Bip001 R Toe0
Node : hip_adjustment_bone_right
export root node done
done

osg 加载 fbx文件的更多相关文章

  1. [CG从零开始] 3. 安装 pyassimp 库加载模型文件

    assimp 是一个开源的模型加载库,支持非常多的格式,还有许多语言的 binding,这里我们选用 assimp 的 python 的 binding 来加载模型文件.不过社区主要是在维护 assi ...

  2. webpack模块加载css文件及图片地址

    webpack支持css文件加载并打包,只需安装相应加载器并在配置文件中配置 . 加载的css文件内容会与该模块里的js内容混合封装,这样做的好处是一个js文件包含了所有的css与js内容,有效减少了 ...

  3. 速战速决 (5) - PHP: 动态地创建属性和方法, 对象的复制, 对象的比较, 加载指定的文件, 自动加载类文件, 命名空间

    [源码下载] 速战速决 (5) - PHP: 动态地创建属性和方法, 对象的复制, 对象的比较, 加载指定的文件, 自动加载类文件, 命名空间 作者:webabcd 介绍速战速决 之 PHP 动态地创 ...

  4. Java提高篇——JVM加载class文件的原理机制

    在面试java工程师的时候,这道题经常被问到,故需特别注意. 1.JVM 简介 JVM 是我们Javaer 的最基本功底了,刚开始学Java 的时候,一般都是从“Hello World ”开始的,然后 ...

  5. assets 加载资源文件

    引用:http://abc20899.iteye.com/blog/1096620 1.获取资源的输入流 资源文件 sample.txt 位于 $PROJECT_HOME/assets/ 目录下,可以 ...

  6. 如何在SCENEKIT使用SWIFT RUNTIME动态加载COLLADA文件

    问题:今天接到一个项目,负责弄需求的美眉跟我讲能不能做一个原型能够加载Collada文件,流程如下: 用户用app下载Collada 压缩包(如内购项目) 压缩包解压 展示Collada文件里的内容 ...

  7. 动态加载js文件

    由于最近在弄echarts,关于地图类的效果,但是全国地图整体的js文件太大了,加载很耗费资源,所以要根据不同省份加载不同地区的js地图, 于是就想的比较简单, var script = docume ...

  8. spring入门(二)【加载properties文件】

    在开发过程当中需要用到配置信息,这些信息不能进行硬编码,这时配置文件是一个比较好的方式,java提供了properties格式的文件,以键值对的方式保存信息,在读取的时候通过键获得键对应的值,spri ...

  9. ios – 使用UINib加载xib文件实现UITableViewCell

    xib文件的实质是xml,描述界面对象,每个对象都有一个很重要的属性,identity inspector面板中class属性,加载xib文件的时候实际上是实例化界面对象相对应的这些class. xi ...

随机推荐

  1. k8s的网络

    K8S的网络中主要存在4种类型的通信:   ①同一Pod内的容器间通信 ②各个Pod彼此间的通信 ③Pod和Service间的通信 ④集群外部流量和Service之间的通信   K8S为Pod和Ser ...

  2. Session&Cookie&localStorage浅谈

    Session&Cookie&localStorage 领导让我开发一个有两张信息表单需要提交页面的网站,我作为一名开发人员,这个需求太简单了,和领导说直接存session sessi ...

  3. VUE this.$http.post 与后端flask 数据交互

    背景: 小鱼第一次前端用的VUE,然后前后端的交互调了几次,记录下来留给自己下次使用 前端 通过  form.XXX 获取数据,代码: <template> <el-form ref ...

  4. 改变某个对象的CSS样式时,不要使用JS直接添加样式,

    重绘: 使用js改变网页的背景颜色 浏览器会把整个网页的颜色重新在画一遍,导致性能降低 回流: 只要改变某个DOM对象的宽或者高,浏览器就会重新再计算网页结构,重新生成一次,导致性能严重降低. CSS ...

  5. PHP 判断给定两个时间是否在同一周,月,年

    判断是否在同一周 date_default_timezone_set('PRC'); //判断是否在同一周,原理:求出其中一个时间戳所在周的周一凌晨时间戳和周日24.00时间戳,如果另一个时间戳在这个 ...

  6. PHP流程控制之if语句多种嵌套

    王思总同学我们在最开始的故事中讲到了他有两个秘书:一个生活秘书.一个工作秘书. 王思总同学在出行和项目中也是极度有计划性.他给自己的生活秘书和工作秘书分别指派了出差的行程:大理石平台支架 生活上: 先 ...

  7. php数据类型之 NULL类型

    空在英文里面表示是null,它是代表没有.空(null)不是false,不是0,也不是空格. [重点]知道null产生的三种情况,学习empty 和 isset两个函数的区别.大理石平台怎么样 主要有 ...

  8. Laravel 项目架构 弹性、可维护性

    公司项目可能需要对架构进行重建,老大给了我一个视频让我学习里面的思想,看完后觉得收获很大,主讲人对laravel项目各个层次有很清晰的理解,力求做到职责单一分明,提高可维护性.下面是我看完视频对其内容 ...

  9. elment-ui的validate

    https://blog.csdn.net/qq469234155/article/details/84034816 validate()时elment-ui封装好的用于对整个表单进行验证valida ...

  10. 主席树K-th Number

    /*K-th NumberTime Limit: 20000MS Memory Limit: 65536KTotal Submissions: 44535 Accepted: 14779Case Ti ...