Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 946 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Adapting angle of Feet #438342
03/12/14 10:37
03/12/14 10:37
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
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?

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 Offline

X
rayp  Offline

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 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


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: rayp] #438344
03/12/14 11:03
03/12/14 11:03
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
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.

Re: Adapting angle of Feet [Re: Ch40zzC0d3r] #438355
03/12/14 12:55
03/12/14 12:55
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
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?


"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] #438363
03/12/14 14:58
03/12/14 14:58
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Thanks Superku!
Works fine, I tried to rotate it before, but I forgot the asin and acos tongue
Thanks again laugh 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
C
Ch40zzC0d3r Offline OP
Serious User
Ch40zzC0d3r  Offline OP
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
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

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 Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
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%).


"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 Offline
Senior Member
Dico  Offline
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.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1