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.

DarkBASIC Discussion / Sparky's Angular Collision

Author
Message
Brick Break
User Banned
Posted: 28th Jul 2009 21:17
Well, rather than look at the tutorial, I decided to be a lazy bum and ask you guys how to detect angular collision with Sparky's DLL. I just haven't gotten getCollisionNormalX() to work right. Attached is a very primitive pre-alpha of Big Rigs *raises flame shield* Online. No, it's not online yet. Don't even bother clicking on "ONLINE RACE". It seems the only thing I have done right so far is the menu system.

Anyways, if you could tell me how to correct the problem I'm having with my currently non-rotational vehicle physics, that would be great.

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!

Attachments

Login to view attachments
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Jul 2009 21:27
First of all, nice menu set up!

But I see you left your coding un-commented. You should get into commenting your code, it is much more viewable.

I never really understood the normals, I used this for angle calculation:



cx#, cy# and cz# are the positions of the player.

TheComet


Make the path of your enemies easier with Waypoint Pro!
Brick Break
User Banned
Posted: 28th Jul 2009 21:39
I don't like that idea. There's an example that comes with the library that allows you to shoot these white things, and they stick at the perfect angle!

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
Brick Break
User Banned
Posted: 28th Jul 2009 21:51
Bump. I saw in the example a mention of getCollisionBounceX(), but I couldn't find that function anywhere!

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Jul 2009 22:06
Yeah, I remember those white things... Sorry I can't help. I am interested though how the normals work.

TheComet


Make the path of your enemies easier with Waypoint Pro!
Brick Break
User Banned
Posted: 28th Jul 2009 23:07
I'm tired of figuring things out myself. Someone please just write a function to get the angle of the face the ray is colliding with.

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 31st Jul 2009 22:25
Quote: "Someone please just write a function to get the angle of the face the ray is colliding with."


The normal is the vector - the direction of the face the ray is colliding with. Since it is 3d, there are actually three angles that could represent the vector's angular orientation in world space. And depending on the order of rotation, the angle combination (x,y and z) could be anything - so the easiest way to represent the normal, is by a vector.

If you have to represent it by angles, then you might take the approach TheComet was suggesting - but you could make it a little easier on yourself.

Based on the example that comes with Sparky's (where the planes are angled according to the ray collision), create a dummy object, place it at the center of the object that the ray is colliding with, get the normal coordinates of the ray collision, and use POINT OBJECT to point the dummy object at the x,y and z of the normal. Then use OBJECT ANGLE X() y and z of the dummy object to get the x,y and z angle of the normal.

Quote: "I am interested though how the normals work."

The normal is a perpendicular to a face - it's 90 degrees away projected away from a face. The normal determines how light is reflected from the face for color and lighting effects. A vertex normal is the average face normals of faces that share the same vertex. Just remember a normal is a vector 90 degrees from the face. It tells the direction a face is facing.

Quote: "Bump. I saw in the example a mention of getCollisionBounceX(), but I couldn't find that function anywhere!"


The functions:


And an example: move the mouse around to position a big sphere on the screen. From the big sphere a ray is cast towards the cube in the center. The ray will reflect when hitting the cube and the resulting vector will be where the little sphere ends up.



Enjoy your day.
Brick Break
User Banned
Posted: 31st Jul 2009 22:34
I don't want to have to use a dummy object. All I want are some functions using atanfull() to determine the angle. No matter how much you try to explain, I'm not going to understand how it works. I know what normals are, and I've seen visual representations of them, but it would do worlds of good to have a function to return the angle of the normal. By the way thanks for the functions!

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 31st Jul 2009 23:40 Edited at: 31st Jul 2009 23:42
Quote: "I don't want to have to use a dummy object."

I dont see any other way.

Nah, its the only way i know of.....If i can dig out my old PODS racing game, i'd give you my functions, but i'll have to search my old backup...

EDIT)
Where can i get Sparky's again...?

Your signature has been erased by a mod because it was too big.CHANGE IT OR DIE!!!!!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Aug 2009 00:15
Type in "collision DLL" into the search box or click this link:

http://forum.thegamecreators.com/?m=forum_view&t=31051&b=5




TheComet


Make the path of your enemies easier with Waypoint Pro!
Brick Break
User Banned
Posted: 1st Aug 2009 01:29
Quote: "I dont see any other way."

All we have to do is figure out some kind of system using arctangent math. The POINT OBJECT function doesn't just pop up out of thin air, you know- someone had to program it. Maybe Latch could shed a little more light on it...

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Aug 2009 14:16
Quote: "All we have to do is figure out some kind of system using arctangent math. The POINT OBJECT function doesn't just pop up out of thin air, you know- someone had to program it. Maybe Latch could shed a little more light on it..."

I don't think it's as simple as it may seem. It's a direction and not an orientation so that can be represented by 2 angles. You decide on which angles that the rotation will represent - probably x and y. Y is easy, you can find the arctangent of that using x/z of the normal. The x angle is a little more difficult because you have to figure out it's tilt or rotation after the point has been rotated around y. It's gonna come down to matrix rotation math. Ultimately multiplying two matrices together of the separate rotations.

I'm sure you can find the details on the internet. Look up something like convert 3d vector to euler angles.

Enjoy your day.

Login to post a reply

Server time is: 2024-05-20 05:16:35
Your offset time is: 2024-05-20 05:16:35