Jump to content

Blender 'Shape Keys' > Babylon 'morphTargetManager'


babbleon
 Share

Recommended Posts

Hello, 

I'm posting this partly to help anyone else who has struggled with this, but also to ask if I am doing something wrong / if this is a bug in the exporter.

When I export a mesh from Blender with 'Shape Keys', I have to create two Keys in addition to the Basis for it to work in Babylon.

One Key + basis: https://www.babylonjs-playground.com/#0XATER#1

A.gif.216f3a9f838f1dd25c759a1a985cc662.gif

Two keys + basis: https://www.babylonjs-playground.com/#0XATER

B.gif.e36fa5bfdc7bb6428e967527e4aef0b4.gif

 

Link to comment
Share on other sites

Here's the positions for the vertices of mesh & targets for Key 1 (this is the one with only one shape key).

one shape key

Mesh vertex positions:

[0.5,0,0.25,-0.5,0.38,0.25,0.5,0.38,0.25,0.5,0,-0.25,-0.5,0,0,0.5,0,0,0.5,0.76,0,-0.5,0.76,-0.25,0.5,0.76,-0.25,0.5,0.38,-0.25,0.5,0.38,0,-0.5,0.38,-0.25,-0.5,0,-0.25,-0.5,0.38,0,-0.5,0,0.25,0.5,0.76,0.25,-0.5,0.76,0
,-0.5,0.76,0.25]

Target vertex positions for 'Key 1':

[0.5,0,0.25,-0.5,0.38,0.25,0.5,0.38,0.25,0.5,0,-0.25,-0.5,0,0,0.5,0,0,0.5,0.76,0,-0.5,0.76,-0.25,0.5,0.76,-0.25,0.5,0.38,-0.25,0.5,0.38,0,-0.5,0.38,-0.25,-0.5,0,-0.25,-0.5,0.38,0,-0.5,0,0.25,0.5,0.76,0.25,-0.5,0.76,0
,-0.5,0.76,0.25]

...the same.

This may be something for @V!nc3r to add to the docs until it's sorted.

Link to comment
Share on other sites

I just looked at the code & cannot see where this is wrong, so I made my own cube, added a basis & key.  Went into edit mode (while the key was selected) & colapsed a face in.  When I export, I get different values for the positions & target positions:

"meshes":[{"name":"Cube","id":"Cube","materialId":"shapekey.Material","billboardMode":0,"position":[0,0,0],"rotation":[0,0,0],"scaling":[1,1,1],"isVisible":true,"freezeWorldMatrix":false,"isEnabled":true,"checkCollisions":false,"receiveShadows":false,"pickable":true,"tags":""
,"positions":[1,-1,-1,-1,-1,1,1,-1,1,-1,1,1,1,1,-1,1,1,1,-1,-1,-1,-1,1,-1]
,"normals":[0.577,-0.577,-0.577,-0.577,-0.577,0.577,0.577,-0.577,0.577,-0.577,0.577,0.577,0.577,0.577,-0.577,0.577,0.577,0.577,-0.577,-0.577,-0.577,-0.577,0.577,-0.577]
,"indices":[0,1,2,3,4,5,5,0,2,4,6,0,6,3,1,2,3,5,0,6,1,3,7,4,5,4,0,4,7,6,6,7,3,2,1,3]
,"subMeshes":[{"materialIndex":0,"verticesStart":0,"verticesCount":8,"indexStart":0,"indexCount":36}]
,"instances":[],"morphTargetManagerId":535126}
],
"morphTargetManagers":[{"id":535126
,"targets":[{"name":"Key 1"
,"positions":[-0.7202,-1,-1,-1,-1,1,-0.7202,-1,1,-1,1,1,-0.7202,1,-1,-0.7202,1,1,-1,-1,-1,-1,1,-1],"influence":0}]}],

Cannot reproduce.

Link to comment
Share on other sites

I think it is more accurate to say that each morph target is always exported with the same values.  The positions themselves are not directly exported in the first place.  A temp copy with all modifiers including current shapekey settings is made, & that is what gets exported.  This is very powerful.  You might have Mirror modifier for making a perfectly symmetrical mesh with only doing half the work.  You do not to HAVE TO apply your modifiers to do an export, since it would wreck more development.  Probably best to store all your shapekeys @ 0 in the .blend file to get your mesh exported without any influences per-applied.

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...