osg 加载 fbx文件
#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文件的更多相关文章
- [CG从零开始] 3. 安装 pyassimp 库加载模型文件
assimp 是一个开源的模型加载库,支持非常多的格式,还有许多语言的 binding,这里我们选用 assimp 的 python 的 binding 来加载模型文件.不过社区主要是在维护 assi ...
- webpack模块加载css文件及图片地址
webpack支持css文件加载并打包,只需安装相应加载器并在配置文件中配置 . 加载的css文件内容会与该模块里的js内容混合封装,这样做的好处是一个js文件包含了所有的css与js内容,有效减少了 ...
- 速战速决 (5) - PHP: 动态地创建属性和方法, 对象的复制, 对象的比较, 加载指定的文件, 自动加载类文件, 命名空间
[源码下载] 速战速决 (5) - PHP: 动态地创建属性和方法, 对象的复制, 对象的比较, 加载指定的文件, 自动加载类文件, 命名空间 作者:webabcd 介绍速战速决 之 PHP 动态地创 ...
- Java提高篇——JVM加载class文件的原理机制
在面试java工程师的时候,这道题经常被问到,故需特别注意. 1.JVM 简介 JVM 是我们Javaer 的最基本功底了,刚开始学Java 的时候,一般都是从“Hello World ”开始的,然后 ...
- assets 加载资源文件
引用:http://abc20899.iteye.com/blog/1096620 1.获取资源的输入流 资源文件 sample.txt 位于 $PROJECT_HOME/assets/ 目录下,可以 ...
- 如何在SCENEKIT使用SWIFT RUNTIME动态加载COLLADA文件
问题:今天接到一个项目,负责弄需求的美眉跟我讲能不能做一个原型能够加载Collada文件,流程如下: 用户用app下载Collada 压缩包(如内购项目) 压缩包解压 展示Collada文件里的内容 ...
- 动态加载js文件
由于最近在弄echarts,关于地图类的效果,但是全国地图整体的js文件太大了,加载很耗费资源,所以要根据不同省份加载不同地区的js地图, 于是就想的比较简单, var script = docume ...
- spring入门(二)【加载properties文件】
在开发过程当中需要用到配置信息,这些信息不能进行硬编码,这时配置文件是一个比较好的方式,java提供了properties格式的文件,以键值对的方式保存信息,在读取的时候通过键获得键对应的值,spri ...
- ios – 使用UINib加载xib文件实现UITableViewCell
xib文件的实质是xml,描述界面对象,每个对象都有一个很重要的属性,identity inspector面板中class属性,加载xib文件的时候实际上是实例化界面对象相对应的这些class. xi ...
随机推荐
- CentOS7下Yum安装Redis并配置主从
原文 :https://blog.51cto.com/11134648/2158209 Redis简介: Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库.它通常被 ...
- SLAM、三维重建,语义相关数据集大全
作者朱尊杰,公众号:计算机视觉life,编辑成员 一 主要针对自动驾驶: 1.KITTI数据集: http://www.cvlibs.net/datasets/kitti/index.php(RGB+ ...
- vue 关于vuex
<!-- vuex 配置js store.js -->1.引入vue和vuex import Vue from 'vue'import Vuex from 'vuex'Vue.use(Vu ...
- G1垃圾收集器官方文档透彻解读【官方解读】
在前几次中已经对G1的理论进行了一个比较详细的了解了,对于G1垃圾收集器最权威的解读肯定得上官网,当咱们将官网的理解透了,那基本上网上对于G1的说明其实最终都是来自于官网,所以接下来会详细来解读Ora ...
- 【搜索/tarjan找环】zznu-简单环路
简单环路 题目描述 有一个N x M 大小的地图,地图中的每个单元包含一个大写字母. 若两个相邻的(这里的相邻指“上下左右”相邻)点上的字母相同,我们可以用线段连接这两个点. 若存在一个包含同一字母的 ...
- Mac系统上,Firefox和Selenium不兼容的情况
解决办法,检查环境: Python 2.7.10 Firefox 46版本 Selenium 2.53.6 注意:将Firefox自动更新关闭,否则可能会出现自动升级以后无法执行Selenium用例的 ...
- 神经网络(3)---如何表示hypothesis,如何表示我们的model
大脑中的神经元 我们的大脑都充满了上图所示的神经元,神经元有一个细胞体(cell body),还有一些input wires,专业词汇叫做树突(dendrite),它们从其它地方接收输入信息,神经元还 ...
- machine learning(15) --Regularization:Regularized logistic regression
Regularization:Regularized logistic regression without regularization 当features很多时会出现overfitting现象,图 ...
- unity里blit的load store action设置
做blit的 load store action时 用 setrendertarget做 之后blit 参数用 BuiltinRenderTextureType.CurrentActive https ...
- 定时器 延时调用setTimeout
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...