Bonjour,

Pour un projet particulier j'ai construit un personnage que je souhaite faire croître et grossir/maigrir. Avec Tween, je réussis facilement à redimensionner toutes les parties du corps de mon personnage, cependant je n'ai toujours pas réussi à faire suivre son squelette.

Selon ce que j'ai pu trouver un peu partout sur internet, il est simple de déplacer une jointure au bout d'un os pour créer un mouvement mais qu'en est-il d'allonger un segment?

Quelqu'un pourrait m'aider?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
import fl.transitions.*;
import fl.transitions.easing.*;
import fl.ik.*;
 
var squelette:IKArmature = IKManager.getArmatureByName("Bonhomme");
var os_bras_gauche:IKBone = squelette.getBoneByName("os_bras_gauche");
 
trace(os_bras_gauche.hasOwnProperty("length")); //false
 
var el1:Tween = new Tween(bras_gauche, "scaleX", Regular.easeIn, 1, 2, 2, true);
var el2:Tween = new Tween(bras_gauche, "scaleY", Regular.easeIn, 1, 2, 2, true);
 
el2.addEventListener(TweenEvent.MOTION_FINISH, scaling_finished);
 
function scaling_finished(evt:TweenEvent):void {
    resize_bone(os_bras_gauche, 2);
}
 
function resize_bone(bone, ratio) {
    var hj:IKJoint = bone.headJoint;
    var tj:IKJoint = bone.tailJoint;
    var pos_head : Point = hj.position;
    var pos_tail : Point = tj.position;
 
    var tail_mover:IKMover = new IKMover(tj, pos_tail);
    pos_tail.x = pos_head.x + ((pos_tail.x - pos_head.x) * ratio); 
    pos_tail.y = pos_head.y + ((pos_tail.y - pos_head.y) * ratio); 
    tail_mover.moveTo(pos_tail); //Crée un déplacement
 
    var bone_length = Math.sqrt(Math.pow(pos_head.x = pos_tail.x, 2) + Math.pow(pos_head.y = pos_tail.y, 2));
    trace(bone_length);
}
je souhaiterais que ma jointure "tail" s'éloigne de ma jointure "head" mais cela ne correspond pas au principe de Cinématique Inverse qui cherche à tout prix à tout faire suivre.