#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. Kubernetes 1.14发布:对Windows节点的生产级支持、Kubectl更新与持久本地卷通用版本已全面到来

    今天,我们高兴地宣布Kubernetes 1.14版本的正式亮相,这亦是我们在2019年当中进行的首次发布!Kubernetes 1.14版本由31项增强功能组成,具体包括:10项稳定版功能,12项b ...

  2. JS多线程之Web Worker

    什么是Web Worker web worker 是运行在后台的 JavaScript,不会影响页面的性能. 当在 HTML 页面中执行脚本时,页面的状态是不可响应的,直到脚本已完成. web wor ...

  3. 与C++类的初始化有关---深拷贝,浅拷贝及相关问题

    深浅拷贝 如果之前没有仔细了解深浅拷贝的定义,那么从字面意思上理解,深拷贝大概是地址拷贝,因为它足够”深”嘛,那浅拷贝就是仅仅拷贝值喽,谁叫它那么“浅”,然而生活跟我们开了个巨大的玩笑,这俩意思正好满 ...

  4. RocketMQ的技术亮点

    高性能 存储原理 零拷贝 数据结构与存储逻辑 刷盘策略 长轮询PULL RocketMQ的Consumer都是从Broker拉消息来消费,但是为了能做到实时收消息,RocketMQ使用长轮询方式,可以 ...

  5. 14 Vue列表渲染

    列表渲染 用 v-for 把一个数组对应为一组元素(for循环) 我们可以用 v-for 指令基于一个数组来渲染一个列表. v-for 指令需要使用 item in items 形式的特殊语法, 其中 ...

  6. TDOA 之 基站逻辑代码实现

    在前一篇博文里描述了基站的逻辑部分,这里贴出来具体代码实现.https://www.cnblogs.com/tuzhuke/p/11689881.html 1 Sync 信息部分 case 'S': ...

  7. 物联网之窄带物联网(NB-IOT)

    NB-IoT即窄带物联网(Narrow Band Internet of Things),NB-IOT构建在蜂窝网络之上,只消耗大约180KHZ的带宽,可直接部署于GSM(2G).UMTS(3G).L ...

  8. 去除IDEA中xml黄色背景

    idea版本:IntelliJ IDEA 2019.2.1 在编写mybatis的xml中会出现大面积黄色背景提示,看起来比较不舒服. 去掉黄色背景颜色 1.打开File->Settings-& ...

  9. Linux 硬件软件时间同步

    同步BIOS时钟,强制把系统时间写入CMOS clock --show   查看硬件时间clock -w       强制把系统时间写入CMOSclock --show   查看硬件时间reboot ...

  10. 004_Python3 注释

    确保对模块, 函数, 方法和行内注释使用正确的风格 Python中的注释有单行注释和多行注释:Python中单行注释以 # 开头,例如::# 这是一个注释print("Hello, Worl ...