I'm trying to learn how to do animation with Irrlicht; currently, using data from an older post in the forums (http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=29365).
My question is a bit different from the original post: how do we specify the point of contact between two meshes? (is there a term for that?). I mean attaching sword to the right hand is a bit vague unless there is some implicit notion of attach points both on the sword and the hand. In other words, what part of the sword gets attached to what part of the hand?
This is a generalization of the original (unanswered) question, how to correctly orient the sword?
Attaching objects to a mesh
Also note that it is "origin" of object that serve as reference point. So when you attach two objects, you attach them relative to their origin. Origin is point [0,0,0] in local space of your object, be it model or bone. You define origin in your modelling program.
No, he mean bone or joint of hand. Your sword does not have bones probably (what for?).You mean a bone or joint on the sword?
>> No, he mean bone or joint of hand.
Thats exactly what I'm doing, similar to what the user in the original post tried to do.
>> So when you attach two objects, you attach them relative to their origin
Ok, if i'm understanding it properly that means the pivot point of the sword gets connected to the pivot point of the hand, right? What about the direction vector? I mean it attaches in the backward direction (sword on the back) and there does not seem to be a way to orient it in any other direction.
Thats exactly what I'm doing, similar to what the user in the original post tried to do.
Code: Select all
//create character mesh
IAnimatedMesh* meshPC = smgr->getMesh("../../media/testmodel/mypc.x");
IAnimatedMeshSceneNode* nodePC = smgr->addAnimatedMeshSceneNode(meshPC);
nodePC->setMaterialFlag(EMF_LIGHTING,false);
nodePC->setAnimationSpeed(3000);
IBoneSceneNode* bone = nodePC->getJointNode("game_HumanLPalm");
//create sword mesh
IAnimatedMesh* meshWP = smgr->getMesh("../../media/testmodel/sword.x");
IAnimatedMeshSceneNode* nodeWP = smgr->addAnimatedMeshSceneNode(meshWP);
nodeWP->setMaterialFlag(EMF_LIGHTING,false);
nodeWP->setParent(bone);
Ok, if i'm understanding it properly that means the pivot point of the sword gets connected to the pivot point of the hand, right? What about the direction vector? I mean it attaches in the backward direction (sword on the back) and there does not seem to be a way to orient it in any other direction.
I must be missing something very fundamental then, because no matter what I do it does not affect at all. I even tried various combinations of EJUOR_CONTROL . Here is my entire code. What am I missing?
The models are from this link http://3dcg-yotuba.com/uploader/src/up0053.zip
The models are from this link http://3dcg-yotuba.com/uploader/src/up0053.zip
Code: Select all
int main()
{
IrrlichtDevice *device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16, false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
matrix4 projMat;
projMat.buildProjectionMatrixPerspectiveFovLH(45.0f,1.3333f,1.0f,10000.0f);
ICameraSceneNode *camera = smgr->addCameraSceneNode(0, vector3df(2, 2, 2), vector3df(0,1,0));
camera->setUpVector(vector3df(0.0f,1.0f,0.0f));
camera->setProjectionMatrix(projMat);
//create sword mesh
IAnimatedMesh* meshWP = smgr->getMesh("../../media/testmodel/sword.x");
IAnimatedMeshSceneNode* nodeWP = smgr->addAnimatedMeshSceneNode(meshWP);
nodeWP->setMaterialFlag(EMF_LIGHTING,false);
nodeWP->setRotation(vector3df(45.0f,45.0f,45.0f)); // <------------ SET ROTATION
//nodeWP->setJointMode(EJUOR_CONTROL);
//create character mesh
IAnimatedMesh* meshPC = smgr->getMesh("../../media/testmodel/mypc.x");
IAnimatedMeshSceneNode* nodePC = smgr->addAnimatedMeshSceneNode(meshPC);
nodePC->setMaterialFlag(EMF_LIGHTING,false);
nodePC->setAnimationSpeed(3000);
//nodePC->setJointMode(EJUOR_CONTROL);
IBoneSceneNode* bone = nodePC->getJointNode("game_HumanRPalm");
nodeWP->setParent(bone);
nodeWP->setRotation(vector3df(45.0f,45.0f,45.0f)); // <------------ SET ROTATION (TRY AFTER CONNECTING)
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
nodeWP->setRotation(vector3df(45.0f,45.0f,45.0f)); // <------------ SET ROTATION (TRY HERE)
smgr->drawAll();
nodeWP->setRotation(vector3df(45.0f,45.0f,45.0f)); // <------------ SET ROTATION (OR HERE)
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}