This example is based on a previous interactive scene tutorial sample. We will use base code for 'interactive scene' sample and modify only the body of 'setupNavigation” function.
Cast3D version 0.97 or later is required for this sample.
There are few step are necessary to combine motions:
import cast3d.tracks.MotionBlender;
// Lets make an instance of motion blender
var mixer:MotionBlender = new MotionBlender( "motion_blend");
We are going to blend two motion groups. First we need to find track by id in node's track list. motion group to blend with is “lowerBack_motion”
track_id = "lowerBack_motion";
we need to find “lowerBack_motion” track first, which is a 'walking' animation track
for each ( track in node.tracks)
{
if (track.id == track_id) break;
track = null; i++;
}
then remove it from node's track list to prevent it from being animated
if (track) { node.tracks.splice(i,1); track.enabled = true;}
Next, we add it to blender, with weight = 0.5, which means 50% influence from this motion will be applied to node
mixer.addTrack(track,.5);
Same thing with another motion group “lowerBack_motion539”, which is 'waving' motion
track_id = "lowerBack_motion539";
i=0;
for each ( track in node.tracks)
{ if (track.id == track_id) break; track = null; i++;}
if (track) { node.tracks.splice(i,1); track.enabled = true; }
mixer.addTrack(track,.5);
we need to enable mixed, by default all tracks are disabled
mixer.enabled = true;
and add to tracks
node.tracks.push(mixer);
Full source for this function could be found here.
So, if done it right you should see something like these: