delay of attached node. is this a irrlicht bug?

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

delay of attached node. is this a irrlicht bug?

Post by moriwo »

I attached the sword to hand bone of the character.

but, the sword is delayed compared with the movement of hand bone.

Is this a my mistake?

Code: Select all

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{
	Device = createDevice(video::EDT_DIRECT3D9, dimension2d<s32>(1024, 768), 32, false, false,true);
    IVideoDriver *Driver = Device->getVideoDriver();
	ISceneManager *Scene = Device->getSceneManager();

	//create camera
	ICameraSceneNode *camera;
	camera = Scene->addCameraSceneNode(0, vector3df(-2,2,-2), vector3df(0,1,0));

	//set up vector
	camera->setUpVector(vector3df(0.0f,1.0f,0.0f));
	matrix4 projMat;
	projMat.buildProjectionMatrixPerspectiveFovLH(45.0f,1.3333f,1.0f,10000.0f);
	camera->setProjectionMatrix(projMat);

	//create character mesh
	IAnimatedMesh* meshPC = Scene->getMesh("mypc.x");
	IAnimatedMeshSceneNode* nodePC = Scene->addAnimatedMeshSceneNode(meshPC);
	nodePC->setMaterialFlag(EMF_LIGHTING,false);
	nodePC->setAnimationSpeed(5000);

	IBoneSceneNode* bone = nodePC->getJointNode("game_HumanRPalm");

   //create sword mesh
	IAnimatedMesh* meshWP = Scene->getMesh("sword.x");
	IAnimatedMeshSceneNode* nodeWP = Scene->addAnimatedMeshSceneNode(meshWP);
	nodeWP->setMaterialFlag(EMF_LIGHTING,false);

	nodeWP->setParent(bone);

	float add=0;
	while(Device->run())
    {   
		if(nodePC->getPosition().Z > 5)
			add = -0.1;
		if(nodePC->getPosition().Z <= 0)
			add = 0.1;

		nodePC->setPosition(nodePC->getPosition()+vector3df(0,0,add));


		//render
		Driver->beginScene(true, true, SColor(0,100,100,160));
		Scene->drawAll();
		Driver->endScene();
	}

    Device->drop();

    return 0;
}
Last edited by moriwo on Mon Jul 21, 2008 7:23 am, edited 1 time in total.
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

someone
can you try the code above?

Does the same problem occur?

I entreat you to help me.
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

Image
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

in image,
The sword turns oppositely.
The purpose of it is to see the problem well.


this is test model to use.

http://3dcg-yotuba.com/uploader/src/up0053.zip[/url]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, thanks to the good input the problem is at least reproducible. This can be a problem with the wrong transofrmation of attached nodes, which was reported some time ago. Or it could be a problem with a 1 frame offset due to wrong updates of the models.
I'll move it to the bug forum since I don't know what it is, yet.
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

thanks hybrid.

I will try the another way until fix of this problem.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

try to use this code:

Code: Select all

void UpdateAbsoluteTransformationAndChildren(ISceneNode *Node)
{
   Node->updateAbsolutePosition();
   core::list<ISceneNode*>::ConstIterator it = Node->getChildren().begin();
   for (; it != Node->getChildren().end(); ++it)
   {
      UpdateAbsoluteTransformationAndChildren((*it));
   }
} 
call it every time before smgr->drawAll();

it works for me :D
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

oh!! it works!!

thanks B@z!!
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

if i remember correctly it's rogerborg's xD
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I can't take credit for that; I try to stay as far away from animation as possible, in case I get hit with a sharp fragmented triangle.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hbraun
Posts: 28
Joined: Tue Dec 16, 2008 7:33 pm
Location: Porto Alegre, Brazil
Contact:

Post by hbraun »

I have the same problem,
I used the B@z`s code and it helped, but depending from camera angle the problem still persists!

Can anyone help or had another solution?

Thank You,

Braun
Post Reply