Page 1 of 1

MS3D Joint Nodes.

Posted: Mon Dec 11, 2006 5:55 am
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

Posted: Mon Dec 11, 2006 11:00 am
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);
	}

Posted: Wed Dec 13, 2006 9:24 am
by Amt0571
I had a lot of problems when using ms3d format. I ended up using b3d instead which milkshape exports without problems.