Away3D FaceLink

Flash Add comments

AwayFaceLink1

A new comer to the Away trunk is the FaceLink class. This one is also made for the
animators among the Away users. This handy little class allows you to link
objects to a face of a Mesh.
Think here the sword that must follow the leg of the moving avatar, the optional weapon your hero just won during battle... of course you can do totally different things with it as well, like the demo above. In this case a light and a model are coupled to a FaceLink instance. I've even been able to make some very funcky Ik chains with it.

The demo beneath shows an animated AS3 output being linked to a moving md2 model.

AwayFaceLink2

The code is very easy to implement:
import away3d.animators.FaceLink;
[..code..]
facelink = new FaceLink( item, mesh, mesh.faces[index], offset, align, target);

Lets say you have a gun, and you have prepared an avatar with a hand dedicated for this purpose. The code required when you want the model starts "wearing" the gun would then be: facelink = new FaceLink( gun, hero, hero.faces[index], 0, true);

Now the warrior you have made, has a gun thats opens from the leg
you code triggered the opening and you want the gun go outside the opening.
You just need to increase the offset. facelink.offset += myTweenValue;
The offset is calculated from face center, from there positive or negative values
will position the object along the normal vector of this face. You can change at runtime the face or any other properties of the class.

The align property triggers a lookat: the gun following a leg while its walking.
The last optional is another lookat. The gun would point at a specific coordinate.
That's the gun pointing at the target.

Finally the engine needs to know if you want keep it alive, because you want be able to let the gun fall, or assign another weapon to the warrior.

Add just this line when the model position are updated, in case of static models.
facelink.update();

On moving item or geometry change like for animated md2, pass a boolean :true
facelink.update(true);

if you do not want the gun to be updated: don't update, or pass another object to the class.

AwayFaceLink1

This little demo is also using the class, but is an excuse to show you the new added property for the BitmapMaterial: showNormals, which comes very handy to debug model geometry.

5 Responses to “Away3D FaceLink”

  1. Ozgur Uksal Says:

    beautiful

  2. xea Says:

    Thanks very nice work! I linked it Merci!

  3. Anjue Says:

    very strong!
    But I’m a new personality study away3d,I can’t find some demo by away3D for import dae bones;
    can you give me a demo?
    英文非常烂哦!

  4. cellis Says:

    Hey fabrice, nice work. I want to ask, how do you know which face to link to for a collada model?

  5. Fabrice Says:

    Since exporters do not respect a specific order when the output files are generated. Its depending on how the developper makes his loops and how the data is stored into a specific app. It actually doesn’t matter what format it is. There is only one way to find out the easy way.
    Like shown in demo 2, just make a little scrollbar or stepper that is coupled to the mesh.vertices array. You will then be able to define the face index.
    This class can even be used as “bones” structure if well exploited. The key being to place faces at the right places into the model itselff, or if you work with containers, set new faces objects that will affect the containers and their content.

    Finally, keep in mind that collada is an overkill format for web if it contains only static data. Use the native as3exporter instead for a lightweight result.

Leave a Reply

Entries RSS Comments RSS Log in