Sign in to follow this  

Unity Exporting MAYA skinning mesh and boneoffset matrix problems

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've gone though almost all the tutors on web like RobTheBloke and florian.loitsch's gpExport. And I already sucessfully export a static mesh and render it in my engine. But I still failed to render an exported skinned mesh. I had the exp about render a .X file animation so I know the formula for skinning: vertex pos = vertexbindpos * boneoffset * jointworldtranform * bindweight I tried to extract the boneoffset like the following (a mix of RobTheBloke and gpExport and Chad Vernon's cvxport) but I got a distorted result and hope someone can tell me where the problem is.
BoneIT it = g_Bones.begin();
for( ; it != g_Bones.end(); ++it ){
	MFnTransform fnX(bone.path);

	//---------------------Get BindPoseMatrix using the function in gpExport---------------------
	MFnIkJoint joint(bone.path.node());
	MMatrix bindPoseMatrix = getBindPoseMatrix(joint);
	bindPoseMatrix = bindPoseMatrix.inverse();

	//---------------------Get Joint's Transform matrix---------------------
	MMatrix mat = fnX.transformation().asMatrix();
	while(true){
		MStatus s = bone.path.pop();
		if(s == MS::kSuccess){
			MFnTransform fnXP(bone.path.node());
			mat *= fnXP.transformationMatrix();
		}
		else break;
	}
	mat = mat.inverse();
	MMatrix boneoffset = bindPoseMatrix * mat;
}


But obviously this is not boneoffset, what I saw were all pure rotations, its weird that there's no translation, and the rotations are incorrect either. I just wonder that the joint's transform matrix, Using while(true) to accumulate the transform of all its ancestors. Actually I modified it(Chad's cvxporter in python) to C++, but I'm not sure if I've done it in a correct way. The bindpose matrix I used that from gpExport http://florian.loitsch.com/gpExport/index-4.html#Extraction It's like
MMatrix getBindPoseMatrix(MFnIkJoint joint)
{
    // get bindPose-plug on joint
    MPlug tempBindPosePlug = joint.findPlug("bindPose");

    MPlugArray mapConnections;
    tempBindPosePlug.connectedTo(mapConnections, false, true);

    if (mapConnections.length() != 1)
    {
        //cout << "returning currentMatrix" << endl;
        // certainly not the most correct way of dealing with the problem...
        return joint.transformation().asMatrix();
    }

    // find the other end. actually we shouldn't call it "bindPosePlug",
    // but worldTransformPlug (as that's where it enters).

    // theoretically someone could bind the bindPose to other nodes,
    // than the bindPose-node. in this case there's a problem.
    MPlug bindPosePlug = mapConnections[0];

    // this node should be a "dagPose"-node (in case you want to look it
    // up in the help)
    MFnDependencyNode bindPoseNode(bindPosePlug.node());

    // and as such, has the "xformMatrix"-attribute.
    MObject xformMatrixAttribute = bindPoseNode.attribute("xformMatrix");

    MPlug localTransformPlug(bindPosePlug.node(), xformMatrixAttribute);
    // xformMatrix is an array. to get our localmatrix we need to select
    // the same index, as our bindPosePlug (logicalIndex()).
    localTransformPlug.selectAncestorLogicalIndex(bindPosePlug.logicalIndex(), xformMatrixAttribute);

    MObject localMatrixObject;
    localTransformPlug.getValue(localMatrixObject);
    // extract the matrix out of the object.
    return MFnMatrixData(localMatrixObject).matrix();
}



BTW, I'm confused about the transforms in MAYA, http://www.gamedev.net/community/forums/topic.asp?topic_id=517946 And I've tried Rotation = RO * R * JO That's Rotation = Rotate Orient * Rotation * Joint Orient
BoneIT it = g_Bones.begin();
for( ; it != g_Bones.end(); ++it ){
	MMatrix test;
	MQuaternion JO(0,0,0,1);
	MQuaternion RO(0,0,0,1);
	MQuaternion Rcomb;
	MMatrix RcombMat;

	fnX.getScale(Scale);
	// Rotation
	fnX.getRotation(R);

	if( fnX.object().hasFn(MFn::kJoint) )
	{
		// Joint Orientation
		MFnIkJoint fnJ(fnX.object());
		fnJ.getOrientation(JO);
	}
	// Rotate Orientation
	RO = fnX.rotateOrientation(MSpace::kObject);

	// Test Rotate = [RO] * [R] * [JO]
	RcombMat = RO.asMatrix() * R.asMatrix();
	RcombMat = RcombMat * JO.asMatrix();
	Rcomb = RcombMat;

	MVector trans = fnX.translation(MSpace::kTransform);
	// Test Transform = [S] * [RO] * [R] * [JO] * [IS] * [T]
	MMatrix translationMat; translationMat.setToIdentity();
	translationMat(3,0) = trans.x;
	translationMat(3,1) = trans.y;
	translationMat(3,2) = trans.z;

	test = RcombMat * translationMat;
}







I think this should be the jointworldtranform that transform the origin to joint position, but it's not, I was wrong. Really hope someone can help me. I've spent a lot time on it but still can't work out. Any idea is appreciated. [Edited by - Quaid Tseng on March 4, 2010 7:44:22 PM]

Share this post


Link to post
Share on other sites

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Forum Statistics

    • Total Topics
      628719
    • Total Posts
      2984388
  • Similar Content

    • By Apollo Cabrera
      Energy particles being harnessed by collection multi-hedron energy matrix. Whuuuttt?
      Love it :)
    • By AndySv
        Total Music Collection (http://u3d.as/Pxo)   THE COLLECTION CONTAINS:   Mega Game Music Collection   Universal Music Collection   Huge library of high quality music for any project! All at an incredibly low price!   - 2,5GB of high quality audio - 100+ different music tracks - Loop and short versions   Action, fantasy, casual, horror, puzzle, epic, dramatic, romantic, positive, inspiring, motivational and more!
    • By Dafu
      FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
      FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
      So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
      Some FES features:
      Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
      FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
      Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
      I hope I've tickled your retro feels!



      More images at: https://imgur.com/a/LFMAc
      Live demo feature reel: https://simmer.io/@Dafu/fes
      Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
      Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064

      View full story
    • By Dafu
      FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
      FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
      So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
      Some FES features:
      Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
      FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
      Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
      I hope I've tickled your retro feels!



      More images at: https://imgur.com/a/LFMAc
      Live demo feature reel: https://simmer.io/@Dafu/fes
      Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
      Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064
    • By Dafu
      Hello all,
      I've been hard at work on a new retro pixel-perfect framework called FES Retro Game Framework. It is now available on the Unity Asset Store for your kind consideration!
      FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
      So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
      Some FES features:
      Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
      FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
      Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
      I hope I've tickled your retro feels!



      More images at: https://imgur.com/a/LFMAc
      Live demo feature reel: https://simmer.io/@Dafu/fes
      Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
      My own game I started working on using FES, a roguelike, very early: https://simmer.io/@Dafu/merl
      Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064
       
       
  • Popular Now