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 / DarkGDK/Spary Collision Object Bound Size?

Author
Message
iSilver
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 25th Feb 2011 00:43
I'm trying to code my own elastic collision code, since I can't get SC_ObjectCollision() to give me SC_GetCollisionBounceX() and Y() properly.

I've used SC_SetupObject() and am drawing the spherical bounding sphere (lol) so I get see it. How do I get the exact radius size of the bounding sphere so I can perform the collision calculations?

Thanks,

Flamesilver
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 26th Feb 2011 13:59
Have you tried allowing for scaling?

Warning! May contain Nuts!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 26th Feb 2011 19:34
I'm not convinced that coding your own collision functions is a good idea. Sparky's DLL is optimized for speed and it's already written, you only need to figure out how to use it to get a good result.

Did SC_GetCollisionBounceX/Y work when you tried with sphere casting? If yes, why do you want to use object collision instead of sphere cast?

There are Dark GDK commands which give you the object size in all three dimensions: dbObjectSizeX, Y and Z. Use the largest size (or an average if you wish) and set that as the size of the sphere in sphere casting. I think these size commands return always the original size of the object, so if it is scaled, then you need to scale the collision sphere size as well.
iSilver
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 27th Feb 2011 20:07
You're right. Sparky's collision handling code is probably much more efficient. It was just nice to learn how to do it myself (got it semi-working). I'll rework my code to use SC spherecast instead. Thanks for the tip on dbObjectSize.

So... regarding SC's GetCollisionBounceX/Y(), is it a unit vector pointing in the collision direction? Should I still have to account for velocity based on masses of the two collision objects?

Thanks,

Flamesilver
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 28th Feb 2011 22:01 Edited at: 28th Feb 2011 22:04
According to my experiments, the bounce vector points into the direction towards which the object should continue moving after it collided, and the vector does contain velocity information, so you can assign its values directly to the X/Y/Z components of the object's speed vector. The size of the object will influence the direction since the point of contact will be different, but I'm sure there is no mass in the calculation because that would already require a physics engine.

I actually created a test project to make sure that I give you a correct answer. I tried with different object sizes, velocities and directions. Here is the code, if you are interested. I haven't checked a situation when both objects are moving, so you should continue experimenting from here to find out what to do with the other object if it's not stationary.

iSilver
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 1st Mar 2011 02:01
Thank you for your reply.

I produced code very similar to yours. I found that I did not have the math skills to find out the resulting vector for the object being hit. I mean, I couldn't get a real figure on where things were supposed to go after the hit. Even when using Spherecast it didn't look "right" to me, especially because I couldn't figure out the movement vector result for object 2.

You mentioned that everything would probably be in a physics engine. Does that mean if I had DarkPhysics it would take care of the circular collision response (accounting for mass as well) issues for me? Would it also be able to easily do Planetary Gravity?

At $49.99 for both DarkAI and DarkPhysics, etc in a bundle, it's like a steal if it does what I need.

Thanks,

Flamesilver
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 1st Mar 2011 06:39
P.S. In the meantime I realized that using the bounce vector directly works only if your speed vector is in "distance per loop". If you use timer-based movement, then only the direction of the vector can be used, and you will need to normalize it and calculate the components of the object's speed vector yourself.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 2nd Mar 2011 20:36
I didn't see your post when I wrote the P.S. yesterday.

Yes, a physics engine should take care of collision response and mass as well. I'm not sure about planetary gravity, though. There is surely a gravity setting but whether it's global for the whole scene or you can set stronger gravity around some spots than others, that I don't know.

Before you buy Dark Physics: Matty has written a free wrapper for the PhysX engine, you can find it here:

http://forum.thegamecreators.com/?m=forum_view&t=163701&b=22
iSilver
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 7th Mar 2011 20:30
Thanks to _Pauli_, I've begun looking into the physics wrappers QuickODE and Fulcrum.

QuickODE was really simple to set up and use, but not quite powerful enough yet for what I need.

Fulcrum I'll be trying today as I just got the registration for NVidia PhysX and will be downloading it as soon as I get off work.

Wish me Luck

Login to post a reply

Server time is: 2024-10-02 15:18:20
Your offset time is: 2024-10-02 15:18:20