Jump to content

[SOLVED] Animation functions related to ObjectMeshSkinned


photo

Recommended Posts

in setLayer() function, What exactly does the weight parameter do?
I want to know the meaning of animation layer weight.

and in setFrame,  Can the frame parameter have a value between 0 and 1?

If the "from" parameter is the first frame, the "to" parameter is the last frame, and the frame is 0.5, the animation starts at the middle frame. Is this meaning right?

 

Link to comment

Animations of a skinned mesh can be combined or interpolated.

As an illustration see the samples: animation_01 and animation_02 (Samples -> UnigineScript -> Animation in the SDK Browser). You can try to change values to see how these parameters work.

This "weight" parameter is actually a weight for each animation layer to be used for interpolation between the layers: the greater the weight(fraction) set for the layer, the more it affects the mesh.

As for the "frame" parameter in the setFrame() method, it is literally the number of frame. E.g. if your animation has 200 frames and you use:

setFrame(0,14); // 14th frame is to be set, as this is the same as setFrame(0,14,-1,-1) and the same as setFrame(0,14,0,200)
setFrame(0,0.7,0,20); // 1st frame is to be set (interpolated between nearest 0 and 1)

Thank you!

Link to comment

Oh, I understand.

 

animation_01 sameple is seems to be a smooth way to switch animations with  using setLayer().

 

but I do not understand the other samples that combine animations.  I am not sure why the animation result is output like the sample Run.

Can you tell me more detail about the effects of inverseLayer () and mulLayer ()? and lerpLayer() too.

 

Edited by dongju.jeong
Link to comment

lerpLayer(dest, l0, l1, w) - puts bone transforms (position, rotation and scale) linearly interpolated between l0 and l1 with weight = w [0.0, 1.0] (from 0 to 0.5 -  closer to l0, from 0.5 to 1 - closer to l1) to dest
simply put: when we use

mesh_combined.lerpLayer(0,0,1,0.5f);

we get (anim_lerp.gif)

mulLayer(dest, l0, l1, w) - puts bone multiplied transforms  with weight = w [0.0, 1.0] (from 0 to 0.5 -  closer to l0, from 0.5 to 1 - closer to l1) to dest

In this case rotation and scale are linearly interpolated the same way, but the position will be calculated as pos = pos0 * w + pos1

inverseLayer(dest, src) - copies inverse transformations of bones from src to dest this can be used to make the transforms relative to the reference frame when the mulLayer() method is used (see the link to the pdf document below)

when we use (see the difference in bone positions)

mesh_combined.inverseLayer(2,1);
//...
mesh_combined.mulLayer(1,2,1);
mesh_combined.mulLayer(0,0,1,0.5f);

we get (anim_mul.gif)

This document might be useful.

Thank you!

anim_lerp.gif

anim_mul.gif

Link to comment

고맙습니다. 나는 조금 이해했다.

그러나 애니메이션 믹싱 예제에서 update () 전에
SetFrame ()은 무엇을 의미합니까 ?? 이것이 없으면 문제가 있다는 것을 확인했습니다.

 

init()

    mesh_combined = create_agent (Mat4 (rotateZ (90.0f)));
    mesh_combined.setNumLayers (3);
    
    // 펀치 애니메이션
    mesh_combined.setAnimation (0, fullPath ( "samples / animation / animations / agent_punch.anim"));
    
    // 역 참조 프레임을 2 계층에 추가합니다.
    mesh_combined.setAnimation (1, fullPath ( "samples / animation / animations / agent_run.anim")));
    mesh_combined.setFrame (1,5.0f);
    mesh_combined.inverseLayer (2,1);

Edited by dongju.jeong
Link to comment

Hi Dongju,

This setFrame() that we call in the init() sets the reference frame to be used to copy inverse transforms to layer 2 via inverseLayer() (see the next line). So, we can make bone transforms relative to this reference frame by using mulLayer() in the update():

// multiple 1 layer by inverse reference frame
mesh_combined.mulLayer(1,2,1);
	
// combine two animations
mesh_combined.mulLayer(0,0,1,0.5f);

Thank you!

Link to comment
  • silent changed the title to [SOLVED] Animation functions related to ObjectMeshSkinned
×
×
  • Create New...