ent_blendframe (ENTITY* entity, ENTITY* anim, STRING* scene, var anim_percent, var blend_percent);
Interpolates a frame or skeleton between two animation scenes. The source scene is the current skeleton position or the current frame parameter, which is set by ent_animate. A7.84 LC
Parameters:
entity |
Entity to be interpolated. |
anim |
Entity that contains the animation scene. For bones animation only; the skeleton of both entities must be identical. |
scene |
Target animation scene name, without the trailing number; STRING* or char* |
anim_percent |
Percentage within the target scene, 0..100 |
blend_percent |
Blending percentage between previous and new scene, 0..100 |
Modifies:
entity.frame |
new source frame plus interpolation factor. |
entity.next_frame |
new target frame. |
Speed:
Medium (for vertex frames).
Slow (for bones frames).
Remarks:
- For vertex scenes, the instruction only sets the entity's frame and next_frame parameters. For bones scenes, the instruction
blends the entity's skeleton between the scenes.
- As
vertex
animation can only blend between two frames, not between three or more, ent_blend can not interpolate between two already-interpolated frames. The source and target frames are not interpolated, but 'snapped' to the next full frame number.
If your model is bones animated, use ent_blendpose for
smooth or
complex blending.
- Only bones affected by the given scene are moved. Several bones animations can be blended by executing this instruction several times for different animation scenes that can even affect the same sets of bones (see ent_animate example).
- The instruction assumes a cyclic animation scene, which results in reaching the end position earlier than at 100% in noncyclic scenes.
Algorithm:
//vertex scenes only
ent_blend (ENTITY* entity, ENTITY* anim, STRING* name, var anim_percent, var blend_percent)
{
var oldframe = entity.frame;
if (fraction(oldframe) > 0.5) {
if (entity.next_frame)
oldframe = entity.next_frame;
else
oldframe += 1;
}
ent_animatefrom(entity,source,name,anim_percent,0);
entity.next_frame = integer(entity.frame);
entity.frame = integer(oldframe) + blend_percent*0.01;
}
Example:
//Sets the entity to a vertex frame within 50% of the walk cycle,
//and then blends over to the first frame of the stand cycle.
ent_animatefrom(me,me,"walk",50,ANM_CYCLE);
ent_blendframe(me,me,"stand",0,25);
//The result of this code is a frame mixed from 75% of the middle
//of the "walk" cycle and 25% of first frame of the "stand" cycle.
See also:
ent_animate, frame, pose, ent_blendpose
► latest version online