Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/08/26 22:41
Stooq now requires an API key
by VHX. 06/08/26 20:14
ZorroGPT
by TipmyPip. 06/06/26 12:36
Zorro 3.01 recoded MMI function issue
by TipmyPip. 06/04/26 05:44
SGT_FW
by Aku_Aku. 05/31/26 11:05
Issues resuming trades on Demo account
by Martin_HH. 05/22/26 13:31
XTB
by pr0logic. 05/18/26 12:27
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 3,487 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Seraphinang, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_trace problem? #275972
07/02/09 23:00
07/02/09 23:00
Joined: Jun 2009
Posts: 5
Plystire Offline OP
Newbie
Plystire  Offline OP
Newbie

Joined: Jun 2009
Posts: 5
Been looking at my code for a couple days now and it SHOULD work, if my math is correct, which after many sit downs, I think it is.

The goal:
Get my model to tilt properly to the terrain under it (without using the physics engine)

The technique:
I started off with just the tilt and would move on to the roll after the tilt was working.

I started with using c_trace to find the distance to the ground from the center of my model. Then use another c_trace to find the distance to the ground from the front of my model. Once I had those two distances, I could get the difference between them, and use atan to find the angle that the model should be angled to.

Here's a picture to show what I mean:


The formula based on the picture would be:
theta = atan((A-B)/L)

I think this is correct... but for some reason I'm not getting the angle I think I should be.
I know the slope my model is standing on is exactly 15 degrees, but it constantly returns 7.125 cry


Can anyone see anything wrong with my method here, or if there is an easier way to do this (without using the physics system).


Thanks in advance for any help.


The one and only,
~Plystire
Re: c_trace problem? [Re: Plystire] #275975
07/02/09 23:19
07/02/09 23:19
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
if you use the trace anoyhow, you can read out the normal vector of
the surface that was hit.

Do several traces to the front in different angles,
get the normal vector, and make an weighted average of them.

if you turn your model 90 degrees to the normal vector
you have the same effect.


Your current method assumes a very steady / flat terrain,
if some obstace comes, the angle can jump quite quickly.


---

if the math in your calculation for the angle is correct, you can
check on paper.
if the values differ from what you have in the engine,
you probably uses some math function with the
wrong parameters.

Re: c_trace problem? [Re: Damocles_] #275981
07/03/09 00:14
07/03/09 00:14
Joined: Jun 2009
Posts: 5
Plystire Offline OP
Newbie
Plystire  Offline OP
Newbie

Joined: Jun 2009
Posts: 5
Based upon the debug values I have for the c_trace distance returns, the paper math is giving me the same answer as the engine.

That is what led me to believe it was a problem with the c_trace function. I don't think it's giving me accurate distance values. frown

Here's the code I have for c_trace and setting up the vectors to use in it. Let me know if I've done something wrong here, please.

vec_set(t_vec.x,vector(0,0,-500));
vec_for_ent(t_vec.x,me);
floor_dist_center = c_trace(me.x,t_vec.x,IGNORE_ME | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MODELS | IGNORE_SPRITES);
vec_set(t_vec.x,vector(60,0,-500));
vec_for_ent(t_vec.x,me);
vec_set(t2_vec.x,vector(60,0,0));
vec_for_ent(t2_vec.x,me);
floor_dist_front = c_trace(t2_vec.x,t_vec.x,IGNORE_ME | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MODELS | IGNORE_SPRITES);

if (floor_dist_center != 0 && floor_dist_front != 0)
{
targtilt = atan((floor_dist_center-floor_dist_front)/60);
}

Last edited by Plystire; 07/03/09 00:29.

The one and only,
~Plystire

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

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