Adapting angle of Feet

Posted By: Ch40zzC0d3r

Adapting angle of Feet - 03/12/14 10:37

Hey guys tongue
Well, Ive got a little math problem and idk what I could do to achieve my goal. Well first of all, heres my code:

Code:
if(c_trace(my.x, vector(my.x, my.y, my.z - 100), IGNORE_ME | IGNORE_PASSABLE | SCAN_TEXTURE))
{
	vec_to_angle(footRotation, hit.nx);
	ent_bonerotate(me, "Bip01_L_Foot", vector(0, -footRotation.tilt + 90, 0));
	ent_bonerotate(me, "Bip01_R_Foot", vector(0, -footRotation.tilt + 90, 0));
}



Im trying to adapt the feet rotation to the ground. The code works fine if I go up my ramps (only on one side because of the negating), it doesnt work on the other side if I go down the ramp. How can I adapt the rotation better to the ground?
Posted By: rayp

Re: Adapting angle of Feet - 03/12/14 10:55

Did not sleep ... did not test ... just a wild guess / try ... and i hate vector - "math", its always tryNerror 4 me. maybe it works, maybe iam totally wrong ( the Wood-way ^^ ) with this one grin
Code:
// ------------------------------------------------------------------------------
   trace_mode = IGNORE_ME | IGNORE_PASSABLE | SCAN_TEXTURE; //| USE_POLYGON ?
// ------------------------------------------------------------------------------
   if (c_trace (my.x, vector (my.x, my.y, my.z - 100), trace_mode)) if (HIT_TARGET){
   vec_to_angle   (footRotation, hit.nx);

   VECTOR ttarget;
   vec_set        (ttarget,      vector (0, 90, 0));
   vec_rotate     (ttarget,      footRotation.pan);
   vec_add        (ttarget,      hit.x);
   vec_add        (footRotation, ttarget);
	
   ent_bonerotate (me, "Bip01_L_Foot", vector (0, -ttarget, 0));
   ent_bonerotate (me, "Bip01_R_Foot", vector (0, -ttarget, 0));
	
   vec_set        (pLastSlope, footRotation);
}
// -----------------------------------------------------------------------------

Really no idea if this works ( and if i understood your question right ). if not, just ignore this post ^^

Greets
Posted By: Ch40zzC0d3r

Re: Adapting angle of Feet - 03/12/14 11:03

Nope doesnt work xD
But thanks.
However, I dont want to place them on the ground, I just want to rotate them so if you walk up a mountain the feet tips are looking up the mountain too.
Posted By: Superku

Re: Adapting angle of Feet - 03/12/14 12:55

Code:
c_trace(...)
vec_rotate(normal,vector(-my.pan,0,0));
my.tilt = -asinv(normal.x); //adapt to slope
my.roll = -asinv(normal.y);


Does this method work when you transfer it to (your) bone code?
Posted By: Ch40zzC0d3r

Re: Adapting angle of Feet - 03/12/14 14:58

Thanks Superku!
Works fine, I tried to rotate it before, but I forgot the asin and acos tongue
Thanks again laugh Looks awesome!
Posted By: Ch40zzC0d3r

Re: Adapting angle of Feet - 03/13/14 19:50

I tried adapting them on the groudn aswell and my solution worked fine:
Code:
var test = c_trace(...) //height of feet to ground
ent_bonemove(pLocal, "Bip01_R_Foot", vector(0, 0, 25 - test)); //25 is the heigt when the feet are perfectly placed on ground!



But it looks ugly like hell xD (just imagine a 3 times longer foot..)
Then I tried to adapt the angle of the knee/leg to change height but I couldnt find a constant result like 1 dregree = 15 quants or whatever...

Could someone help me again please? Sorry Im not that far in math right now we just started vectors some weeks ago frown
Posted By: Superku

Re: Adapting angle of Feet - 03/13/14 20:57

You are probably looking for the following: http://en.wikipedia.org/wiki/Inverse_kinematics

However, it's not really that easy (Heel-X or some other guy may have done it in the past, I'm not sure).
If I were you I would try to approximate the result without some fancy mathematics - still you could for example draw a triangle where the longest side is the stretched leg and its opposing vertex the knee, then use some sinus/ cosinus theorems and probably the scalar product to calculate the necessary angle.
Simple approach: Create a 2 or more frame animation for each leg where you go from stretched to bent leg. You then memorize the distances from the body to the foot and use the ground distance to get the correct animation value (0..100%).
Posted By: Dico

Re: Adapting angle of Feet - 03/13/14 23:36

try to use physics ? you can get best result !
or two cube
© 2024 lite-C Forums