查看: 946|回复: 2

关于动画模块出现的问题

[复制链接]

该用户从未签到

发表于 2011-4-10 02:18:05 | 显示全部楼层 |阅读模式
在编写动画模块的过程中..能编译通过..但是运行总会出现以下问题..  

31.jpg    请问下高人..究竟是库丢失了..抑或是系统问题..或者有其他答案.?
   编写环境.OSG2.9.9  OS:win7 MFC库已更新到最新版

   //代码

   
#include <windows.h>

#include <osgGA/TrackballManipulator>

#include <osg/Node>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>

#include <osg/ShapeDrawable>
#include <osgAnimation/Bone>
#include <osgAnimation/Skeleton>
#include <osgAnimation/BasicAnimationManager>

#include <osgViewer/Viewer>
#include <osgUtil/Optimizer>
#include <iostream>

osgAnimation::Bone* createBone(const char* name,const osg::Vec3& trans)
{

osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone;


bone->setInvBindMatrixInSkeletonSpace(osg::Matrix::translate(trans));


bone->setName(name);


bone->setDefaultUpdateCallback();


osg::ref_ptr<osg::Box> box = new osg::Box(trans*0.5,trans.length(),0.2,0.2);


osg:uat quat;


quat.makeRotate(osg::Vec3(1.0,0.0,0.0),trans);


box->setRotation(quat);


osg::ref_ptr<osg::Geode> geode = new osg::Geode;


geode->addDrawable(new osg::ShapeDrawable(box.get()));


bone->addChild(geode.get());


return bone.release();
}

osgAnimation::Channel* createChannel(const char* name,float rad)
{

osg::ref_ptr<osgAnimation::QuatSphericalLinearChannel> channel = new osgAnimation::QuatSphericalLinearChannel;


channel->setName("quaternion");


channel->setTargetName(name);


osgAnimation::QuatKeyframeContainer* ks = channel->getOrCreateSampler()->getOrCreateKeyframeContainer();


ks->push_back(osgAnimation::QuatKeyframe(0.0,osg::Quat(0.0,osg::Y_AXIS)));


ks->push_back(osgAnimation::QuatKeyframe(8.0,osg::Quat(0.0,osg::Y_AXIS)));


return channel.release();
}

int main(int argc,char** argv)
{

osgAnimation::Bone* bone0 = createBone("bone0",osg::Vec3(0.0,0.0,0.0));


osgAnimation::Bone* bone1 = createBone("bone1",osg::Vec3(1.0,0.0,0.0));


osgAnimation::Bone* bone2 = createBone("bone2",osg::Vec3(1.0,0.0,0.0));


osg::ref_ptr<osgAnimation::Skeleton> skelroot = new osgAnimation::Skeleton;


skelroot->setDefaultUpdateCallback();


skelroot->addChild(bone0);


bone0->addChild(bone1);


bone1->addChild(bone2);


osg::ref_ptr<osgAnimation::Animation> anim = new osgAnimation::Animation;


anim->setPlayMode(osgAnimation::Animation:PONG);


anim->addChannel(createChannel("bone1",osg::PI_2));


anim->addChannel(createChannel("bone2",osg::PI_2));


osg::ref_ptr<osgAnimation::BasicAnimationManager> manager = new osgAnimation::BasicAnimationManager;


manager->registerAnimation(anim.get());


manager->playAnimation(anim.get());


osg::ref_ptr<osg::Group> root = new osg::Group;


root->addChild(skelroot.get());


root->setUpdateCallback(manager.get());


osgViewer::Viewer viewer;


viewer.setSceneData(root.get());


return viewer.run();

}

该用户从未签到

发表于 2011-4-11 08:57:27 | 显示全部楼层
您的工程配置是什么,是否混用了Debug和Release版本的依赖库?

该用户从未签到

 楼主| 发表于 2011-4-12 23:29:23 | 显示全部楼层
array你所言甚是..一针见血啊...已经搞掂了..谢谢..
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表