|
想用osg做出一个人体骨骼来,现在暂时想用box来当作骨骼,遇到几个问题。
1.bone1->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(osg::Vec3(1.0,1.0,0.0)))),这句话的意思是不是将bone1相对于骨骼原点平移vec3(1.0,1.0,0.0)的位置作为空间变换的原点位置?;
2.对box的makeRotate设置具体是怎么用的,参数向量代表着什么?
3.如果我现在再添加一块bone2,想要显示出来的是bone0->bone1->bone2,可是现在bone2是从骨骼的原点也就是bone0连过去的一个box,而不是从bone1连接过去的,这个连接点怎么设置? skelroot->addChild(bone0); bone0->addChild(bone1);bone1->addChild(bone2);我以为这句写上去就是起到这个作用的,但好像不是。
- osg::ref_ptr<osgAnimation::Bone> bone0 = new osgAnimation::Bone;
- bone0->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(osg::Vec3(0.0,0.0,0.0))));
- bone0->setName("bone0");
- osgAnimation::UpdateBone* pRight1Update = new osgAnimation::UpdateBone("bone0");
- bone0->setUpdateCallback(pRight1Update);
- osg::ref_ptr<osg::Box> box0 =
- new osg::Box(osg::Vec3(0.0,0.0,0.0)*0.5,1,0.2,0.2);
- osg::Quat quat;
- quat.makeRotate(osg::Vec3(1.0,0.0,0.0),osg::Vec3(0.0,0.0,0.0));
- box0->setRotation(quat);
- osg::ref_ptr<osgAnimation::Bone> bone1 = new osgAnimation::Bone;
- bone1->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(osg::Vec3(1.0,0.0,0.0))));
- bone1->setName("bone1");
- osgAnimation::UpdateBone* pRight1Update0 = new osgAnimation::UpdateBone("bone1");
- bone1->setUpdateCallback(pRight1Update0);
- osg::ref_ptr<osg::Box> box1 =
- new osg::Box(osg::Vec3(1.0,0.0,0.0)*0.5,1,0.2,0.2);
- quat.makeRotate(osg::Vec3(1.0,0.0,0.0),osg::Vec3(1.0,0.0,0.0));
- box1->setRotation(quat);
-
- osg::ref_ptr<osg::Geode> geode = new osg::Geode;
- geode->addDrawable(new osg::ShapeDrawable(box0.get()));
- geode->addDrawable(new osg::ShapeDrawable(box1.get()));
- bone0->addChild(geode.get());
- bone1->addChild(geode.get());
- //bone2->addChild(geode.get());
- osg::ref_ptr<osgAnimation::Skeleton> skelroot =
- new osgAnimation::Skeleton;
- skelroot->setDefaultUpdateCallback();
- skelroot->addChild(bone0);
- bone0->addChild(bone1);
复制代码 |
|