Jump to content

Attach skinned mesh


hen
 Share

Recommended Posts

4 minutes ago, Deltakosh said:

what kind of error? I'm pretty sure (But as always I can be wrong) that body skeleton cannot be applied to the pants directly

Exportation cancelled: Object reference not set to an instance of an object

Link to comment
Share on other sites

I'm not a 3dsMax expert but let summarize it:

  • two meshes can have the same skeleton. I tested it multiple time (check this demo for instance:http://www.babylonjs.com/Demos/Bones/ where rabbits share the same skeleton)
  • In you case, I'm afraid meshes are not compatible with the same skeleton (And once again I don't know how to do have one skeleton with multiple meshes in 3dsmax).
Link to comment
Share on other sites

1 minute ago, Deltakosh said:

I'm not a 3dsMax expert but let summarize it:

  • two meshes can have the same skeleton. I tested it multiple time (check this demo for instance:http://www.babylonjs.com/Demos/Bones/ where rabbits share the same skeleton)
  • In you case, I'm afraid meshes are not compatible with the same skeleton (And once again I don't know how to do have one skeleton with multiple meshes in 3dsmax).

Just sent it by pm.
Checking your demo now :)
 

Link to comment
Share on other sites

We need your max scene in order to help you more.

It's somewhat relative, but I often get this error :  "Object reference not set to an instance of an object" when something in my scene is not compatible with Babylon exporter (example with VRay materials, which are not supported). Maybe it is something else in your scene (a material maybe?) that is not compatible.

Link to comment
Share on other sites

8 minutes ago, Temechon said:

We need your max scene in order to help you more.

It's somewhat relative, but I often get this error :  "Object reference not set to an instance of an object" when something in my scene is not compatible with Babylon exporter (example with VRay materials, which are not supported). Maybe it is something else in your scene (a material maybe?) that is not compatible.

I did just sent a copy to Deltakosh.

There is just empty 3ds max standard material applied, since i generate new materials in babylon.
Everything else is just mesh and the skeleton. 

Link to comment
Share on other sites

I worked the whole night on this issue...

After comparing the babylon files created using the fbx converter and 3ds max exporter i came to the conclusion that the exported skeletons are different for each mesh.

@Deltakosh  You are right, i can see that babylon supports what i am trying to do. But only if the skeletons are all similar exported ;) 

Please correct me if i am wrong but i think that the mesh holds the skin inverse bind matrix and bones are only the animation transforms.
So in theory it must work... my assets has been all skinned from the same bindpose on the same skeleton, like in that playground example.

Now when i have a scene in 3ds max wich has 1 skeleton and 5 meshes bound to it, i will get 5 skeletons.
Weird is that each of this 5 skeletons is unique. From same source it exports 5 different ones.

I did copy over the skeletons from file to file by hand to discover that.
That explains as well why your bunny demo works and mine not. Its a single mesh rig and only 1 skeleton exported.

In another thread we discussed problems i had to load that meshes from the playground in gltf format. 
That problem is absolutely related, because single mesh characters do load well with gltf in babylon, multiple mesh characters do "never" load right.
GLTF exports a single skeleton for all meshes, wich seems not to be compatible somehow. 

Please Deltakosh.. please explain to me why the babylon exporters do 1 skeleton to each mesh? and why a unique one for each?
That`s so weird actually. Is it a problem with the internal format or on the exporter side?

Me and my small team worked 2 months fulltime to port from three.js to babylon. That was a amazing experience, really its awesome what you guys have got done here and especially the measured performance with our app is so much better than with three.js. But i cant push a new beta release to our users group and tell them they have to play with naked avatars that cannot be customized anymore because we switched to babylon :)

I really need to understand if this is a solvable problem or something that doesnt meet the design of babylon or the babylon internal file format.

Sorry for the bad english in this post.. its 5am.. i need sleep :)


 

Link to comment
Share on other sites

Be assure that we will find a fix :) We never leave people behind!

 

Regarding your problem, I gave your 3dsmax file to @Supermitch. He will soon be able to get back to you

I think you could try this: Move your 5 meshes to origin. Have everything exported from the origin to remove the need for a specific transformation. If this does not work I would like you to create a simple repro case for me: a .max file with 2 meshes (REALLY SIMPLE like 2 planes), one skeleton and the code you use to test it. With this I will dig into the 3ds max exporter (I hate it :)) in order to make it work :) (But this is as a last resort as I prefer spending my week end with my family)

 

 

Link to comment
Share on other sites

@Deltakosh  I am back working on it right now and maybe a bit closer to find the problem.

When you look at the pant example mesh, the total amount of exported bones is far lower compared to the body mesh.
As well the ids of bones are different. But the bone matrices itself are similar.

Now when you check the 3ds max file i sent to you yesterday, you will see that the skin modifier has the whole set of bones applied.
Thats required to have meshes compatible with the same skeleton wich was similar requirement with three.

I would think that all bones from the skin modifier would be exported.
But the babylon exporters do work different. Seems like they check the verts weight settings for related bones and export only those bones.
When i added the missing bones manually to the babylon file, i got exactly the same result like when i replaced the whole skeleton with the body one.

Forcing all bones to export, even the ones wich have no weight connection to the exported mesh would might fix it.
There must be some difference either on engine side or exporter side how it works with the weights set on the vertices.
I actually believe its on the engine side and the replaced skeleton wich has much more bones is applying transforms to the wrong verts.

Maybe its easier to fix gltf loading than to fix the exporters?
With the latest version of assimp, gltf converts from almost any asset format. Its the new webgl standard runtime asset format.
I was testing the gltf loader again. To make sure that my gltf asset is right i compared with cesium and three. Its all right, but in babylon it doesnt render.
Would be good to have the gltf loader in the playground to provide such examples.

Regarding the origin.. all the content in that test max file has this already.
All pivots are zero, rotations are zero and the scale for each mesh is 1 (100 in max).

I will do some more tests and provide a more simple 3ds max file to you asap.

 

I attached 2 images, one is the the model loaded as gltf in babylon, the other one is loaded from same source in cesium (with no lights).

2016-01-22 18_23_06.png

2016-01-22 18_26_03.png

Link to comment
Share on other sites

Really interesting. So based on your assumption you confirm that skeletons are different in babylonjs file whereas the is only one skin in 3dsmax, correct?

I see no test in my bones exportation code here: https://github.com/BabylonJS/Babylon.js/blob/master/Exporters/3ds%20Max/Max2Babylon/Exporter/BabylonExporter.Skeleton.cs

I like your idea but I don't know how to change the exporter as it seems to me that the optimization you mention is done by 3dsmax

 

But my guts say that maybe this could be fixed in 3dsmax because so far I can confirm that in your example there is a skin per mesh where I would love to see one skin for all :)

Link to comment
Share on other sites

I really dont know the answer, since i dont know how the skin/weight binding relates to the skeleton in babylon.
The skeleton seems to be ok, but somehow the exporters are creating some weight matrices on meshes wich are only compatible to skeletons reduced to the bones bound to that exported mesh. Like a mesh bound only to the head bone would only export the head bone and only work with head bone.

Thats where i believe the problem is. 
From my experience as content developer with several other engines is that the whole skeleton must be exported to guarantee that the props attach right at runtime.
What actually worries me with babylon is that the skeleton doesnt really exists physically and represents only the animation frames.

There should be at least some kind of bind pose for every character as reference for any kind of attachments, because animations are usually changing as well.
As example in threejs we had to define a bind pose (tpose) where every asset had to be skinned to and this bind pose was always called at time when we attached a prop.
Afterwards we went able to apply any kind of animation to that character wich worked well together with the character and any attached props.

Your 3ds max exporter is far more than just an asset exporter wich is amazing for quickly creating interactive scenes.
But maybe its easier to fully support the gltf file format to get this working right.
For my personal use there is so much benefits in using gltf.. If i had the choice i would only use that in the world of webgl ;)
But actually i would be happy just to to get this to work, whatever file format it requires :)

 

Link to comment
Share on other sites

I'll check the exporter but as you can see in the link I shared I'm consuming data produced by 3dsmax.

Regarding the bind pose, we also have this (bone can return to pose for instance) but this is not the problem here.

 

The problem is the one you mentioned: export from max produced specific skeleton per mesh which are incompatible with other meshes

Link to comment
Share on other sites

So goood news, I added a new feature to babylon.js: Bones are no more linked to a specific mesh. So now a single skeleton can be applied to various compatible meshes!

 

From an user standpoint, nothing changed. The engine will do all the work for you. If you want to use the new system just reexport your data from 3dsmax.

Here is an example of two different meshes sharing the same skeleton:

http://www.babylonjs-playground.com/#SQ8ZI#46

 

@JCPalmer: For exporter there are two changes to support this new mode:

Do you mind adding this to your backlog for Blender? Thank you so much :)

 

@Luaacro: Do you mind doing the same for glTF? You can see the changes I did on 3dsmax exporter here

Removing the mesh inverse world matrix:

Setting needInitialSkinMatrix to true:

 

 

Link to comment
Share on other sites

Hard coding a switch is minor.  I'll have to look at program, but don't you mean the skeleton's world matrix, or is that the same thing?

In order to use a skeleton in a mesh you have to assign weights & bone indices.  No problem there, but don't you also need either a way to not export the skeleton in 1 of the files, or have both meshes in the same export file to avoid  2 skeletons?

Also, since bones have a state, how can each mesh be in a different pose at the same time?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...