bone animation

Posted By: boyax

bone animation - 05/21/09 09:08

Hi,

I got here some problem with bone animation in my model.
I have a model riding in a bicycle. So, turning left/right would also appear his shoulder bones and the bicyle turn left/right.
But I got stucked since it appears the shoulder bones just move/rotate a small angle or seems not moving when turning left/right..

Here's the code:
Code:
action movePlayer()
{
	player = my;  //I'm the player
	var dist_ahead;
	var anim_percent = 0;
	
   //vec_for_min(vFeet,my); // vFeet.z = distance from player origin to lowest vertex		
   	   	
   while (1)
   {		      
		dist_ahead = 5*(key_w-key_s)*time_step;      
      c_move(my,vector(dist_ahead,0,0),nullvector,IGNORE_PASSABLE | GLIDE); // move the player

		// animate the player according to its moved distance				
      if (dist_ahead != 0) // player is moving ahead
      {
         anim_percent += 1.3*dist_ahead; // 1.3 = walk cycle percentage per quant                  
         ent_animate(my,"SlowPedal",anim_percent,ANM_CYCLE); // play the "slow pedal" animation
         
         if(key_a)
         {
         	// rotate the player using the [A] and [D] keys; play animation...
         	my.pan += 1*(key_a-key_d)*time_step;         	
         	ent_animate(my,"TurnLeft",anim_percent,ANM_ADD);
			}
         else if(key_d)
         {
         	my.pan += 1*(key_a-key_d)*time_step;         	
         	ent_animate(my,"TurnRight",anim_percent,ANM_ADD);
			}
      }      

		isometric_camera();
      wait(1);
   }
}


So, turning left/right I use the mode: ANM_ADD

Hope you can advise. Thanks
Posted By: boyax

Re: bone animation - 05/21/09 12:21

Any idea? or I should have change my code treating it via bone animation coding... confused
Posted By: Jaxas

Re: bone animation - 05/21/09 13:54

try rename animations: turnright to rightturn, turnleft to leftturn (in MED) wink
Posted By: boyax

Re: bone animation - 05/21/09 14:48

why? is there any difference with the name of frames? still have to try it. Thanks
Posted By: Jaxas

Re: bone animation - 05/21/09 15:24

AFAIK it's necessary to set different names of animation smile once i have similar problem, but change animation names and solve that problem wink
Posted By: boyax

Re: bone animation - 05/21/09 17:31

I've tried your suggestion but didn't fix it.

Actually, they are of different frame animation.
Here's my animation sequence:
SlowPedal: index 2-48 -> model is on pedal slowly the bike
TurnRight: index 154-177
TurnLeft: index 181-204

So, in MED playing the animation, this how it looks
TurnRight (front):


TurnRight (back):


What I want to do is that, when the model turns right, I'll be playing the SlowPedal+TurnRight animation.
But when I run my code I didn't get the desired output?

It seems it's not playing the TurnRight animation..
Sample output:


I just follow the lite-c workshop on bone animation but it didn't work for me well.

At first, moving forward I play the SlowPedal animation
Code:
ent_animate(my,"SlowPedal",anim_percent,ANM_CYCLE)


Then, when player turns right (key_d is pressed)
Code:
ent_animate(my,"TurnRight",anim_percent,ANM_ADD);


Is there something wrong with the code?

Hope you could advise. Thanks
Posted By: EvilSOB

Re: bone animation - 05/21/09 19:13

My best guess would be the anim_percent values.
Try separating them into separate counters, say, anim_pedal and anim_turn.

Just in case one has a longer "frame-set" than the other and so one keeps
resetting the other when they share the same percentage variable.
Posted By: Jaxas

Re: bone animation - 05/21/09 19:21

i just read in manual that ANM_ADD need to use with ANM_CYCLE:
ent_animate(my,"TurnRight",anim_percent,ANM_CYCLE+ANM_ADD);
try that wink
Posted By: boyax

Re: bone animation - 05/22/09 08:18

Hi,

I try the suggestions but didn't work well for me... frown

Anyway, other solution I have is to rotate the spine bone when turning left/right.

I'm able to locate the Spine bone.


some questions:
1. When selecting the bone mode, rotate, hope someone could clarify me which is the x,y and z vertex? or is it pan,tilt,roll angles?
2. In MED, clicking bone mode, there's a toolbar below that shows the position of the vertex (bone):
x,y,z, ?, name of the bone, mode, current selection
What's the 4th refers to?

I should be adjusting the blue arrow/vertex... but i'm not sure how I should do it adjusting the angle..?
I just have to use
ent_bonerotate( ENTITY*,STRING* name,VECTOR* angle)

Any advise? Thanks
Posted By: boyax

Re: bone animation - 05/22/09 09:44

I already solved this one. Thanks. smile
Posted By: Locoweed

Re: bone animation - 05/22/09 21:41

What was thes solution by the way? Just curious what was wrong.
Posted By: Nowherebrain

Re: bone animation - 05/23/09 20:12

me too.
Posted By: boyax

Re: bone animation - 05/26/09 09:10

The solution I've found is to rotate the spine bone of the model. So, I manipulate it through bone rather than playing it's vertex animation.

Code:
else if(key_d)
{
  my.pan += 1*(key_a-key_d)*time_step;         	         
				         
  bone_angle.pan = -20;				         
  ent_bonereset(my,"Spine1");
  ent_bonerotate(my,"Spine1", bone_angle); // rotate the bone
}

© 2024 lite-C Forums