Animate a Character

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

I used ms3d models to make them Child animated and it seems to be working but im still stuck on Joints because there is no any method on IAnimatedMeshNode to get the Joints names/ids/count.

It is quite simple:
1. Make the child nodes and the parent (this) Ragdolls (disable animation)
2. Load Child nodes models and the Skeleton only for parent node (this)

OnAnimate just animate the parent bone joints and copy their positions/rotations to each child node ... and voila.

The only unsolved problem is to get all the Joints IDs or Names array.
This method is useless if i need to copy all joints staticly by name.
It must be dynamic (otherwise you will be able to use ONE skeleton) :)



About loading BVH:
I think its impossible without creating own quite complicated Node or modyfing engine source code to access the Joints / Animations directly.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Try to get the IAnimatedMesh from the scene node, cast it to ISkinnedMesh and use that interface to query the joint details.
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

It's not enough to just cast IAnimatedMesh to ISkinnedMesh.
It throws an Access Violation when try to use getAllJoints or useAnimationFrom.

Any ideas ?
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No idea, it should work as described. Please show the code and the error message, and try to debug the reason of the crash.
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

Code: Select all

	scene::ISkinnedMesh * source      = (scene::ISkinnedMesh*) playerSkeletonNode -> getMesh();
	scene::ISkinnedMesh * destination = (scene::ISkinnedMesh*) playerTorsoNode    -> getMesh();
	
	destination -> useAnimationFrom ( source );


	ERROR : Unhandled exception at 0x00000034 in Test.exe: 0xC0000005: Access violation.
Made just as described.
Both nodes have loaded meshes with valid joints.
Both source and destination seems to be valid ... no any NULL pointers.

It looks like the CSkinnedMesh::AllJoints array is NULL but im not quite sure.

Code: Select all

//CSkinnedMesh.cpp
bool CSkinnedMesh::useAnimationFrom(const ISkinnedMesh *mesh)
{
	bool unmatched=false;

	for(u32 i=0;i<AllJoints.size();++i)
	{
		SJoint *joint=AllJoints[i];
		joint->UseAnimationFrom=0;

		if (joint->Name=="")
			unmatched=true;
		else
		{
			for(u32 j=0;j<mesh->getAllJoints().size();++j)
			{
				SJoint *otherJoint=mesh->getAllJoints()[j];
				if (joint->Name==otherJoint->Name)
				{
					joint->UseAnimationFrom=otherJoint;
				}
			}
			if (!joint->UseAnimationFrom) unmatched=true;
		}
	}

	checkForAnimation();

	return !unmatched;
}
Is the ISkinnedMesh designed for some specific mesh types or should work for all common types ?
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

Any example code how to use the ISkinnedMesh on IAnimatedMesh ?
I didnt found any.

It still crashes with the Access Violation error.
Post Reply