Jump to content

Blender Shape Keys


adam
 Share

Recommended Posts

Here is a simple QI class I wrote (not the official one).

Include this in your code before your tower of babel export file.

Then in your code:

            var myShapeKeyGroup = mesh.shapeKeyGroups["ENTIRE_MESH"];
            myShapeKeyGroup.shapeKeys["Key 1"].value = .5;

to morph your mesh using a shape key you created in Blender.

 

simple example:

http://www.babylonjs-playground.com/#1RH0J8#4

animation examples:

http://www.babylonjs-playground.com/#1RH0J8#5

http://www.babylonjs-playground.com/#1RH0J8#7

 

QI.js

QI.ts

Link to comment
Share on other sites

Does anyone know of a cleaner way to set up that animation?

This didn't work:
var animationBox = new BABYLON.Animation("tutoAnimation", "mesh.shapeKeyGroups['ENTIRE_MESH'].shapeKeys['KEY 1'].value", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT,
                                                                    BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);

That's why I resorted to this:

mesh.shapeKey = mesh.shapeKeyGroups['ENTIRE_MESH'].shapeKeys['KEY 1'];

var animationBox = new BABYLON.Animation("tutoAnimation", "shapeKey.value", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT,
                                                                    BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
 

 


    

Link to comment
Share on other sites

The actual ShapeKeyGroups are implemented as an beforerender on the mesh.  Each group has a queue of new targets to morph to.  There is also a pose queue for skeleton interpolations.  I am starting to think about bringing out QueuedInterpolation without anything specific to MakeHuman to start.  It be supported by Tower of Babel 5.0, which is been completely re-factored into 17 files & distributed as a .zip file.

There will be no documentation changes for TOB, or any documentation for QI.  There could be breaking changes without apology.  It still would better than what you are doing.  There is plenty of code comments, & Javadoc like code arg descriptions.

Link to comment
Share on other sites

11 minutes ago, JCPalmer said:

There could be breaking changes without apology.  It still would better than what you are doing.

That is so very nice of you, Jeff.  :angry:

I'm glad I got you to move, though.

Link to comment
Share on other sites

@adam -

Sorry to chime in so late, but I was out of town the past few days. Obviously, you have been provided examples on how to export/import blend shape keys. However, in many years of working on rigging game characters, if you don't require extreme close-ups by the camera of the character's face and specifically their eyes, then the rotation of half or smaller parts of simple colored and/or textured spheres are by far the best method with the least computation in a scene. And this method specifically limits various conflicts and concerns when translating and transforming your character in the game.

By maintaining the mesh's center in the center of the partial sphere and rotating simple sphere geometry from the local center won't contribute to the additive effects of using other bend shapes on the face.  Just make certain that you maintain or re-position your sphere's center position to rotate the lids correctly - as many surface operations to reduce the polygons to a half or 1/3rd sphere often repositions the mesh's center to the average position of its remaining polys. And on any console game ever released where I have any rigged characters, no one has ever noticed that I wasn't using blend shapes to open and close the upper and lower eyelids.

And FYI - it's allot less work with virtually the same results - unless as I say again, you require facial closeups for expressive emotions directly to camera - which even then doesn't often require blend shapes for eyelids, unless we're talking extreme closeups and emotions.

DB

Link to comment
Share on other sites

Hi @dbawel.  That's what I was planning on doing.  Deltakosh fixed an attachToBone bug a few days ago for me that allows me to use separate eyelids for blinking.  I'm going to use this morphing code to make my character squint and close his eyes.  The separate eyelid meshes looked terrible for that.

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