Jump to content

Importing a Rigged Mesh from Maya to Blender


Alex Carpenter
 Share

You are about to reply to a thread that has been inactive for 2220 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

I'm trying to solve an issue I'm having trying to import a collada file originally exported from Maya into Blender 2.73a.  I have managed to get a successful import of the rig, and all looks well, until I try to export it again for testing in SL/OpenSim. I managed to solve some of the problems it has by rotating the entire armature 90 degrees on the Z axis, but the bone scales are still very badly broken. I have also tried manually adding the data I found in the collada xml to custom 'restpose_*' props, but this doesn't quite produce the results I'm expecting, which I suspect has something to do with the props being global in scope rather than inheriting from the parent bone, but I'm not sure.

Questions I have are:

  • Is there detailed documentation anywhere about the latest collada importer and exporter for Blender? I'd like to be able to find out what the importer reads, what it expects, what happens if it doesn't get what it expects, what it converts and how, and what, if anything, it ignores, and compare this to the raw XML of the file I'm trying to import.
  • It's strange to me that the armature looks and behaves perfectly fine in Blender but breaks on Opensim/SL. Is there anything about the collada exporter that could explain this behavior, even when the appropriate preset is used?
  • Are the custom 'restpose_*' props calculated as if they are global or do they follow the parent/child inheritance structure of the armature? Specifically I'd like to know how restpose scale is handled. As I said above, I suspect they're global (while the values from the file are local) but I want to be sure.
  • When a file is imported that uses Y_UP, what is Blender doing to the data to convert it to its native Z_UP space? If there's something that I would need to convert manually I'd like to know roughly what steps to take. Related, what steps would need to be taken on fixed data if the whole armature were rotated as it was in the case above?
  • From what I know of the math behind it, the formula to convert local restpose values to global ones, if indeed that be needed, would be something like 'global = local * parent_global'. Is this correct or is there something I am overlooking?


Thanks in advance,

--Alex


Link to comment
Share on other sites

You'd think that using industry standard formats like FBX and DAE that these kinds of scale issues wouldn't happen between apps, but I've had similar issues going from Max to Blender. Hope someone can provide you some insights because it might help me unravel problems I've been having recently with skin modifiers and bone scale.

Link to comment
Share on other sites

So in first place Blender should import Second Life Rigs without trouble. Especially in Blender 2.73 we added a feature to find the "maximum connected bone chains" of the rig, which works nice for the SL bones (not so nice for the Collision Volumes)

The Rig comes in with a 90 degrees rotation because SL wants the character to look at positive X . While Blender's "natural" character looks towards negative y (using the X axis as mirror axis).

Futhermore Blender does not have a bind Pose. So the Rest Pose is the only neutral pose that can be used. In the Rest Pose all normal bones have a scale of 1, and a rotation of 0. However, Collsion bones have very weird scale values (in restpose) and there Blender chockes a bit. But see below in the q/a section:

Here are some answers to your questions:

Is there detailed documentation anywhere about the latest collada importer and exporter for Blender?

Blender uses the OpenCollada libraries and the Collada-1.41 specification. If Blender does not conform to the specifications then please report this to Blender.

Why would a rig work well iun blender and not so well in OpenSim?

Can it be that you use fitted mesh (weighting to collision volumes? If that is the case, then you need to do a very special extra step, as described in the last chapter of the fitted mesh survival kit

When a file is imported that uses Y_UP, what is Blender doing to the data to convert it to its native Z_UP space?

The UP Axis is normally specified in the Collada file. Blender reads this and rotates the object in world space. If this does not work as expected, then its a bug (please report to blender in that case)

For the other questions i am not sure what you mean by "props" and "restpose values".

  • Like 1
Link to comment
Share on other sites

Thanks for the reply.

The avatar dummy mesh I'm trying to work with is likely liquid mesh, as some parts of the mesh do change when appearance is edited, but not all of them, and it was created before the introduction of fitted mesh. I understand it works on basically the same principle though. Additionally while in Blender everything looks perfect thanks to the import options you mentioned. But upon upload, the mesh becomes a stick figure (after being rotated to face positive X anyway).

What I meant about 'restpose_*' props was basically a very inelegant attempt to describe the same thing your fitted mesh survival kit does in the last section. By taking values found in <scale> tags nested within <node> tags of type 'joint' in the <library_visual_scenes> section of the collada file, using a formula to convert the scale values to global space, and inputting them into the appropriate properties, I was able to get the blender-exported mesh really close to what the original one looks like when worn, which I'm hoping also means if I develop clothing with it, it will work. However it looks really weird in the preview, and is not exactly like the original. I suspect a loss of decimal precision when I converted local bone scale to global might explain some of it, but also admit I'm really new to all this.

After all of this, I have to ask, is there a more elegant way to do what I'm trying to do? The mesh I'm working with does not seem to have any collision bones to work with. Is it possible to rerig a mesh in Avastar without losing its original weights?

Thanks,

--Alex

Link to comment
Share on other sites

Well, Avastar would certainly help to get things done. And sure you can use it to get your mesh rigged with its original weights and later imported to SL without need to calculate matrix parameters for bone scaling or so...

Admitedly using blender for fitted Mesh without a tool like Avastar is imho a bit of a complex thing. The Mesh survival kit IS a blend file that only uses pure Blender and it is capable to export fitted mesh, but it is also not as flexible as Avastar.

Avastar works well for classic rigging (to the mBones) and for fitted mesh (collision volume bones). However, it isn't a cakewalk when it comes to fitted mesh. There are still some gray spots where our documentation is not yet as good as it could be and our tools still can need some improvements. But all in all it seems like the tools do pretty much what users expect them to do. I do not hear many complains.

And just to have mentioned it, Avastar's real benefit is that it provides ways to animate your creations with IK- and FK- animation, use of control bones, export to .bvh and .anim (and our animation files conform to what the SL importer needs) , eye animations, and it even includes a retargeting tool.

oops, i get carried away. i better stop :matte-motes-sunglasses-3:

Link to comment
Share on other sites


Alex Carpenter wrote:

The avatar dummy mesh I'm trying to work with is likely liquid mesh, as some parts of the mesh do change when appearance is edited, but not all of them, and it was created before the introduction of fitted mesh. I understand it works on basically the same principle though. Additionally while in Blender everything looks perfect thanks to the import options you mentioned. But upon upload, the mesh becomes a stick figure (after being rotated to face positive X anyway).

When you see a stick figure when you export your mesh to SL, then your problem is exactly what i mentioned in the document about Fitted Mesh. Then the bind pose matrix is missing! The following custom parameters define the bind pose (and it is not at all easy to get the exact parameter values for all bones) . Here are the custom parameter names (and each parameter needs to be set differently for each collision Volume Bone):

 

restpose_loc_x (default=0.0)restpose_loc_y (default=0.0)restpose_loc_z (default=0.0)
restpose_rot_x (default=0.0)restpose_rot_y (default=0.0)restpose_rot_z (default=0.0)restpose_scale_x (default=1.0)restpose_scale_y (default=1.0)restpose_scale_z (default=1.0)

However the fitted mesh kit should be good for your purposes as well. Because it actually DOES define the bind pose matrix for the collision volume bones of the female default character.

  • Like 1
Link to comment
Share on other sites

Again, thanks for the reply. Were it not for the information you've provided here and elsewhere I'd likely never have gotten this far.

I had actually already purchased Avastar back when I started trying to work on this, and before I had started to get any sort of mental foothold with regards to the problems I've been trying to work around. At that point I had tried to use its exporter and ran into errors, more than likely because it wasn't designed to do what I was trying to make it do, and I need to read the manual. :matte-motes-big-grin-squint:

Since the steps I took to get the results I have now are almost exactly what you described in the mesh survival kit, I feel relatively confident that my issue is resolved to the best extent I can hope for in pure Blender, at least for the moment. I plan on continuing to tinker though, starting with reading Avastar's manual, in hopes of coming up with something a bit nicer to work with.

Thanks again,

--Alex

Link to comment
Share on other sites

And sure you can use it (Avastar) to get your mesh rigged with its original weights and later imported to SL without need to calculate matrix parameters for bone scaling or so...

Could I ask how? Is this written down anywhere? I've tried migrating the avatar to the avastar skeleton and rebinding the mesh while keeping the weights. In the case of migrating, I end up with an enormous mesh perpendicular to the skeleton. In the case of reskinning, the mesh ends up smaller than the armature and proportioned incorrectly. Is there a way to make the mesh 'wrap' around the new skeleton and preserve the scale of the original?

Thanks,

--Alex

Link to comment
Share on other sites

It is possible not only from maya but from any other software you want to use to rig to bring your mesh in blender then use just the SL provided files for fitted mesh with the custom properties added to export it in second life working good.

Maya doesn't need that kind of hack cause its exporter is so far better than blender.

What you need to do is set up your other program maya in this case and blender to use the same scale both for the other software and blender. I set blender in metric scale from scene tab.

The whole strategy that will allow you to do this is ismple: you use the vertex groups and the weight added from other softwares in blender, binding with just armature deform your mesh to the blender bones.

Anyways to make it short. Your problem is to keep the same weights that you aded in maya ( say maya or another software of choice that has a not compatible dae for sl like maya has) .Once you've imported it in blender then select the clothes in object mode ( if you have a wrong rotation rotate it on z axes it may happen) then apply rotation, appply scale apply position (ctrl A or object menu/apply), this is very essential for next step to not get your mesh too big .

When you've done this just select your cloth mesh then the armature that you have in blender (not the one that has been imported)and ctrl p  and choice among the options provided by the pop up menu bind witharmature deform, this allows you to bind the clothes to the armature that you have in blender but keeping the weights that you assigned to the vertices of the clothes in your other program of choice. When I say the armature that you have in blender , I mean that first in blender you open one of those avatar that you download from second life wiki then you import your mesh from other softwares, having already that blender scene and sl avatar in the scene. This is also essential because those files have already the custom properties added to a proper export import in SL, which is not needed for the most advanced experter that you find in maya.

Now delete the other files that you've imported any null object and the armature from maya. We don't care if skeleton it's imported good or bad or if there is any distortion, we just need to bind the mesh from the other software keeping its weights to the bones that you have in blender.

Now you can export  using blender just like a translator like the software between, to import in second life your mesh rigged in softewares whose dae is exporter is not fully compatible with sl. Somewhere else In the forum I already made a thread where I showed how to bring in maya rigged fbx from other softwares (read here), by then I was not playing with blender settings, just with files that people sent me to rig or rigged.

fbximport.png

These are settings that quite often worked with fbx, you can also play around with them. With blender 2.72 there was a problem of orientation going from blender to other software s that was somehow fixable as I saw later with better bone orientation.in the 2.73 this was fixed plus they aded new dae exporrter that converts bones to joints, read here http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.73/Addons.

In blender 2.72 I had some errors as showed here https://developer.blender.org/T42295, but Those were fixing playing with the bone roll before esporting, now with the new version of 2.73 blender I am not having that iussue descrivbed in that thread.

What is really a great new in blender 2.73 already working in its beta is the new dae that doing proper settings allows you to transform the goddam bones into joints when you go to other software.

Just patience a few tweaks and tests and you will get in SL or elsewhere your rigged mesh. If you have maya just get mayastar and avoid all this madness. Other option, if you're stubbon like me and want it to be riggable everywhere without chains and leashes to plugins, just find a way to get the list of the sizes of all the bones in all the states of the sliders that control the collision bones and then it would be really free for all. We'd just need the sizes for the smallest(0%) states of those bones, as I showed in this thread.

Link to comment
Share on other sites

Could you give a short information ion which way the maya Dae exporter is by far better than the Blender exporter? Where does the Blender Collada Exporter need improvement?

[Edit]: ah, its because of the bind pose matrix, i see now. Well, there is no support for bind pose matrix in Blender (yet). So the Blender exporter can not do much here. Using the custom properties is indeed a workaround.

However Avastar actually DOES support a bind pose. So no hack needed there, just the plugin... But well...

Link to comment
Share on other sites

  • 6 months later...

Unfortunately I don't currently have access to Maya, so I can't 'work both sides of the equation'. The workaround has done well for fixing the scale issues. However I'm still having trouble with joint orientation. When the collada file imports, if there were bind pose rotations specified the armature skews from the preview I'm able to look at using FBX Viewer, then gets bound to the skin that way. So far none of the math I have tried is able to get the joint orientation data from the library_visual_scenes section of the file into a form that solves this, and further, attempts to animate or pose the character in Blender goes wonky for the affected bones.

So as an experiment I deleted the joint orient data in question from the collada file by hand. I can then import the file and get exactly the same result as if it had been there. After looking at the source code for collada in Blender I'm wondering if any of the translate/rotate/scale values in that section of the file are used; it seems to try and derive all of that from the inverse bind pose matrix in the skin data instead.

I'm just a novice here, but shouldn't Blender try and do something with the translate/rotate/scale stuff in the joint node tree (in library_visual_scenes)? It looks to be part of the collada specification and not a vendor-specific extra. There are <extra> tags in that section, below the data, referencing 'fcollada', but they only seem to be defining some sort of visibility.

Link to comment
Share on other sites

Please create a simple example blend file which demonstrates the problem and create a report at

https://developer.blender.org/maniphest/task/create/?project=2&type=Bug

If this is possible for you  then you can add the project "Collada" to the report and if you like you also can assign me to the report. It ends up on my desk anyways :matte-motes-sunglasses-1:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2220 days.

Please take a moment to consider if this thread is worth bumping.

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
 Share

×
×
  • Create New...