MS3D Joint Nodes.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
HondaDarrell
Posts: 20
Joined: Sun Aug 27, 2006 9:10 pm
Location: U.S.A.
Contact:

MS3D Joint Nodes.

Post by HondaDarrell »

I was trying to attach Child Scenenodes to Joint Nodes from MS3D models.
When I test this code the Node attaches it self as a Child but not in the right position.

Code: Select all

ISceneNode* ShipLight = 
PlayerNode->getMS3DJointNode( "Light1" );
ShipLight->addChild( Scene->addSphereSceneNode( 0.1, 8 ));
So then I tried setting the position of the TestNode to the position of the models Joint Node Matrix. But Irrlicht can't load my model as an IAnimatedMeshMS3D and returns an error about converting from 'IAnimatedMesh' to 'IAnimatedMeshMS3D'. So could my model be incorrect?

Here's how my model looks. Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

If you know for sure that an IAnimatedMesh points to a MS3D mesh, you can cast it thusly (error checking elided for brevity):

Code: Select all

	IAnimatedMesh * shipMesh = smgr->getMesh("z1.ms3d");
	if(!shipMesh || shipMesh->getMeshType() != EAMT_MS3D)
		return(-1);
	IAnimatedMeshMS3D * actualMesh = static_cast<IAnimatedMeshMS3D*>(shipMesh);

	IAnimatedMeshSceneNode * shipNode = smgr->addAnimatedMeshSceneNode(shipMesh);

	IAnimatedMesh * gunMesh = smgr->getMesh("KM-gun-1x5.0.ms3d");

	for(int joint = 0; joint < actualMesh->getJointCount(); ++joint)
	{
		matrix4 * matrix = actualMesh->getMatrixOfJoint(joint, 0);

		vector3df location(matrix ? matrix->M[12] : 0.f,
							matrix ? matrix->M[13] : 0.f,
							matrix ? matrix->M[14] : 0.f);

		IAnimatedMeshSceneNode* gunNode = smgr->addAnimatedMeshSceneNode(gunMesh, shipNode, -1, location);
	}
Amt0571
Posts: 128
Joined: Mon Mar 06, 2006 6:29 pm

Post by Amt0571 »

I had a lot of problems when using ms3d format. I ended up using b3d instead which milkshape exports without problems.
Post Reply