1 registered members (AndrewAMD),
946
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Adapting angle of Feet
#438342
03/12/14 10:37
03/12/14 10:37
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Hey guys Well, Ive got a little math problem and idk what I could do to achieve my goal. Well first of all, heres my 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?
Last edited by Ch40zzC0d3r; 03/12/14 10:49.
|
|
|
Re: Adapting angle of Feet
[Re: Ch40zzC0d3r]
#438343
03/12/14 10:55
03/12/14 10:55
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
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
// ------------------------------------------------------------------------------
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
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: Adapting angle of Feet
[Re: Superku]
#438363
03/12/14 14:58
03/12/14 14:58
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Thanks Superku! Works fine, I tried to rotate it before, but I forgot the asin and acos Thanks again Looks awesome!
|
|
|
Re: Adapting angle of Feet
[Re: Ch40zzC0d3r]
#438413
03/13/14 19:50
03/13/14 19:50
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
OP
Serious User
|
OP
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
I tried adapting them on the groudn aswell and my solution worked fine:
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
|
|
|
Re: Adapting angle of Feet
[Re: Ch40zzC0d3r]
#438416
03/13/14 20:57
03/13/14 20:57
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
You are probably looking for the following: http://en.wikipedia.org/wiki/Inverse_kinematicsHowever, 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%).
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Adapting angle of Feet
[Re: Superku]
#438427
03/13/14 23:36
03/13/14 23:36
|
Joined: Feb 2012
Posts: 371
Dico
Senior Member
|
Senior Member
Joined: Feb 2012
Posts: 371
|
try to use physics ? you can get best result ! or two cube
Last edited by Dico; 03/13/14 23:41.
|
|
|
|