Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Angle of Terrain?

Author
Message
Yoyokid
16
Years of Service
User Offline
Joined: 26th Nov 2007
Location:
Posted: 28th Nov 2007 23:46
Ok, so i have a guy walking around a "world" and i want to know if there is a way to find the angle of the Land, so basically i dont have my guy walking up walls, is there a way to do that?

being a yoyoer has its ups and downs...
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 29th Nov 2007 00:32
Get the height of the terrain at the player's position (h1), and the height one unit infront(h2). The position you would check 1 unit ifront would be:

float x = player_x + dbSin( player_angle_y );
float z = player_z + dbCos( player_angle_y );

The angle you are walking on would then be:

float angle = atanfull( h2 - h1, 1 );

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Yoyokid
16
Years of Service
User Offline
Joined: 26th Nov 2007
Location:
Posted: 29th Nov 2007 01:04
i understand the concept, and thank you very much!
but how do i get x and z to equal h2? do i add them?

sorry if i sound dumb, i am new to this.

being a yoyoer has its ups and downs...
Para _Charlie
18
Years of Service
User Offline
Joined: 31st May 2006
Location: Wisconsin
Posted: 29th Nov 2007 02:32
Very nice explanation. That helps alot of others also

DBP 6.3 DX 9.0c
3.2Gig Proc, 2Gigs Ram, SATA HD, Gigabyte MB, 6800GT Vid
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 29th Nov 2007 17:28
Got your email Yoyokid, I'll explain a bit better heh.

Well, basically, the dbAtanFull() function gets the angle of a 2D vector. That might sound strange considering you're working in 3D, but basically, if you want to get an X angle, the 2D vector would be a Y distance and a Z distance. For a Y angle, you put in an X distance and a Z distance, and for a Z angle, the X and Y distance (basically, the distance's axes are not the axis of the angle you're trying to get).

So you want to get an X angle, because it's the angle that you are walking up, so you need a Y and a Z distance.

The Y distance in that case should be the difference in height between where you are standing and a point infront of you. The Z distance is the distance between you and the point infront of you that you are checking, so, to keep it simple, check a point infront of you 1 unit, and leave the Z distance as 1.

To get a point infront of you 1 unit, you use these:

float x = player_x + dbSin( player_angle_y ) * Distance;
float z = player_z + dbCos( player_angle_y ) * Distance;

But since Distance is just 1, you can forget that bit, and leave it as:

float x = player_x + dbSin( player_angle_y );
float z = player_z + dbCos( player_angle_y );

Now you just have to get the terrain height at that point infront of you. I havent used terrain in a while, but I'm sure the function you use it something like Height = dbTerrainHeight( Num, x, z ).

Now you have the height 1 unit infront (h1), and the height where you are (h2), so the Y distance is simple the difference between them, h1 - h2.

Now that you have your Y and Z distances, h1 - h2 and 1, you just plug them into the dbAtanFull() function, and it will return the X angle of them. That angle will be the angle of the surface you're walking on.

Hope that helps

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Yoyokid
16
Years of Service
User Offline
Joined: 26th Nov 2007
Location:
Posted: 29th Nov 2007 22:16
thank you! i understand now and its working great! thanks!!!

being a yoyoer has its ups and downs...
jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 13th Jan 2008 17:10
@Zotoaster:

Hi! I am not using DGDK, but ad Yoyokid says: How do i get x and z to equal h2?
Thanks!!!

Jeff


You're the 'th to view this signature!
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 13th Jan 2008 17:38
If you are using a matrix, Get Ground Height() (DBPro)

If you are using advanced terrain, I dunno then, don't use it much Prolly something like Get Terrain Ground Height()

Your signature has been erased by a mod
jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 14th Jan 2008 21:05
I am going to use sparky's now, any tips on that? (Getting angle of polygon beneath your feet?)

-Jeff


You're the 'th to view this signature!
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Jan 2008 21:15
IIRC, You can get the angles like this:

float X = dbAtanFull( SC_GetCollisionNormalY(), SC_GetCollisionNormalZ() );
float X = dbAtanFull( SC_GetCollisionNormalY(), SC_GetCollisionNormalZ() );
float X = dbAtanFull( SC_GetCollisionNormalY(), SC_GetCollisionNormalZ() );

But dont forget to cast the ray.

Your signature has been erased by a mod
jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 21st Jan 2008 09:41
Well, does not fully work for me, this is my code:



A bit long, but can you help me out, please?
Thank you VERY much!!

-Jeff


You're the 'th to view this signature!

Login to post a reply

Server time is: 2024-11-19 23:22:00
Your offset time is: 2024-11-19 23:22:00