View unanswered posts | View active topics It is currently 26 Nov 2024, 11:11



Reply to topic  [ 24 posts ] 
 Collision Detection System 
Author Message
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Hi all,

I'd thought there might be someone more mathematically inclined so here goes. As some of you may know i've been trying my hand at building a 3D combat engine for both Supremacy and BOTE.

It is a very step by step process and you can find yourself wanting to do one thing but unable to until you complete another.

So i find my self wanting to build an accurate and intelligant collision detection system :)

Now what i was hoping someone might know is how do you check whether a point in 3D space, i.e a vector(XYZ), lies within an ellipsoid. this way i can check when two ellipsoids collide :)

Image

Above are the visibile ellipsoids as an example.

Regards Wolfe

_________________
Image


16 May 2008, 19:56
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
that should work rather simple by using the formula as here: http://en.wikipedia.org/wiki/Ellipsoid

a,b and c are half the length of the mesh in each direction, i.e. the radii.

When summing up the equation and a value less than 1 comes out, you're within the ellipsoid.

Are you using that irrlicht tutorial for collision detection: http://irrlicht.sourceforge.net/tut007.html ?


16 May 2008, 21:11
Profile WWW
Jig of the Puff
Jig of the Puff
User avatar

Joined: 10 Sep 2004, 01:00
Posts: 1305
Location: I wish i knew
is this for shields? if not polygon detction would be more realistic

_________________
ImageImage


16 May 2008, 22:02
Profile
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
That particular collision detection tutorial isn't applicable, it is only for picking, irrlichts collision system is borked at the moment.

I'am not sure how the first formula is going to work though?

Regards Wolfe

_________________
Image


16 May 2008, 22:07
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
x,y and z are the 3d coordinates of a point out of your enemy vessel's mesh minus the 3d coordinate of the central point of your vessel's mesh that you need for creating the ellipsoid and center it right, and a, b and c are the radii of your vessel's mesh.


16 May 2008, 22:12
Profile WWW
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
What exactly do you mean by polygon detection jig?

Regards Wolfe

_________________
Image


16 May 2008, 22:13
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
I think he means that the polygons of two meshes are checked if they intersect each other, i.e. if one polygon has intersecting points with another polygon of the other mesh, much like this newton method: http://www.irrlicht3d.org/wiki/index.ph ... nDetection

Found some other things that might be good to read:

http://gpwiki.org/index.php/Polygon_Collision
http://www.codercorner.com/Opcode.htm

Edit: For the point of the enemy's vessel you just can take the point of the enemy's ellipsoid that is nearest to the center of your ship's ellipsoid. That's just a simple intersection test since that point must be on the direct axis between both central points.


16 May 2008, 22:17
Profile WWW
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
has it helped?

I thought about making it a bit easier to check if two ellipsoid intersect each other and the easiest solution comes from the two-balls case. When the vector connecting both central points of the balls has smaller length than the two radii summed up, then they are hitting each other.

In the ellipsoid case that works on a similar ground. Take the distance vector again and check each dimension's entry with the ellipsoid radii (summed up again). If that vector is smaller in each dimension, they intersect, otherwise they don't.

By subtracting both vectors you'll even get a usable "damage" vector of the collision both for the direction of the "reflection" of both ships off each other and the amount of damage done to the ships.


17 May 2008, 18:47
Profile WWW
Klingon Honor Guard
Klingon Honor Guard
User avatar

Joined: 22 Apr 2005, 01:00
Posts: 1527
Location: UK
http://www.gamedev.net/reference/list.a ... yid=45#199

This one seems a nice layed out view of the concept http://www.gamedev.net/reference/articl ... le2045.asp

_________________
Image
My youtube channel


22 May 2008, 19:18
Profile
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Malvoisin wrote:
has it helped?

I thought about making it a bit easier to check if two ellipsoid intersect each other and the easiest solution comes from the two-balls case. When the vector connecting both central points of the balls has smaller length than the two radii summed up, then they are hitting each other.

In the ellipsoid case that works on a similar ground. Take the distance vector again and check each dimension's entry with the ellipsoid radii (summed up again). If that vector is smaller in each dimension, they intersect, otherwise they don't.

By subtracting both vectors you'll even get a usable "damage" vector of the collision both for the direction of the "reflection" of both ships off each other and the amount of damage done to the ships.


Yep it helped, ironically for some reason i thought the orignaly xyz/abc method wouldn't work but afterwards as you pointed out it easily does lol.

The first rough/alpha/needs improvement pass is done. Though for some reason rotation if the collision ellipsoid is working when it should lol.

At the moment it is a crude imitation of the battlestations collision response in that it just offsets each ship in ther vertical axis by a certain velocity.

I'll look to cleaning some other aspects up and releasing a more up to date demo, though not much has changed.

Regards Wolfe

_________________
Image


26 May 2008, 16:32
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
have you already updated your demo in the meantime since last demo III release? Cause I wouldn't say not much considering you implemented some basic commands and stuff ;).

anyway, lookin forward. also to see how far off from a playable state it is. What would you say, how much of those features you want in it have you already achieved?


26 May 2008, 18:25
Profile WWW
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Still a good chunk of code to go ;)

Next set of work will focus on GUI with regards to a start screen and set up. Give me some experience needed when i begin to implement the needed GUI for the actual combat screen.

Afterwards some work on the AI.

Then there is networking which needs to be set up. After that i'll look to add as much whizz and bangs as possible.

With some hopefully stableish two player demo going i'll have to stop all work on the demo and rewrite everything with optimisation in mind and tailoring to each game whether or not you still want to use it by then lol.

Either way it should be fun, and i want to make it as open ended and moddable as possible, especially with regards to AI as a secondary part of me making this game was to allow other people to download the game and create there own AI's for combat, but who knows thats in the future for now :)

Regards Wolfe

_________________
Image


26 May 2008, 18:54
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
good. As for the GUI, will you use WPF or .NET anywhere there or does Irrlicht support its own set of GUI calls and functions? I still have to check with my ".NET-free" if your demo works but in theory, the tailoring part towards bote's mfc and gdi+ shouldn't be impossible since Irrlicht is not based on .NET so most if not all libraries can be used later on.


26 May 2008, 19:49
Profile WWW
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Irrlicht does support some basic GUI, though i don't know how advanced it is at the moment.

Naturally i want it as user friendly as possible with regards to modding and changing templates and textures.

Regards Wolfe

_________________
Image


26 May 2008, 20:13
Profile
Chief Software Engineer
Chief Software Engineer
User avatar

Joined: 11 Aug 2005, 01:00
Posts: 2688
FYI, the next service pack of WPF will support hosting of Direct3D scenes. Supposedly it works with Managed DX too. That would integrate real nice with Supremacy, since you could have a nice WPF UI controlling the combat system.

_________________
Lead Developer of Star Trek: Supremacy
253,658 lines of code and counting...


28 May 2008, 05:31
Profile WWW
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
I'am guessing you use WPF Mstrobel?

I had a look at it briefly last night may seem the way to go if it works with irrlicht.

Does it need to work within winforms or something like that?

Regards Wolfe

_________________
Image


29 May 2008, 14:25
Profile
Chief Software Engineer
Chief Software Engineer
User avatar

Joined: 11 Aug 2005, 01:00
Posts: 2688
From what I understand, it only needs a Direct3D surface handle.

_________________
Lead Developer of Star Trek: Supremacy
253,658 lines of code and counting...


30 May 2008, 05:12
Profile WWW
Jig of the Puff
Jig of the Puff
User avatar

Joined: 10 Sep 2004, 01:00
Posts: 1305
Location: I wish i knew
you should expand on this and make a multiplayer game were people can team up and fight each other, like legacy without the hideous lag :)

_________________
ImageImage


30 May 2008, 08:36
Profile
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Here is a small vid of some collision response, notice it isn't perfect, but in this case it was only checking every 1.5 seconds where as it should be at 0.5 seconds.

http://www.megaupload.com/?d=KMGNL4D9

Considering MOE isn't here i feel i can get away with mega upload lol

Regards Wolfe

_________________
Image


30 May 2008, 21:41
Profile
Jig of the Puff
Jig of the Puff
User avatar

Joined: 10 Sep 2004, 01:00
Posts: 1305
Location: I wish i knew
http://startrek-games.com/startrekforum ... hp?t=10502
i rackon you should answer that question wolfie

_________________
ImageImage


31 May 2008, 09:07
Profile
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Well i'am glad i posted a reply before the forum owner decided to cull the forum lol.

Regards Wolfe

_________________
Image


31 May 2008, 22:54
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
BTT: What happens when more than 100 ships are gathering around one single location in 3d space causing multiple collision warning instances for certain ships. How do they evade then when multiple conflicting evasion vectors are assigned to them? Do they just use and carry out the first vector movement order they get ignoring the rest leading to collisions and fly-throughs or are you adding up those evasion vectors and if they point in opposite directions, just cause a full-stop for such a ship and then afterwards re-plot new courses and how would those courses be calculated?

And how about deliberate collision aka ramming order? I'd turn off evasion vector assignment then and just let one of the ships explode based on their hull strength once they get into each other's ellipsoid.


06 Jun 2008, 18:39
Profile WWW
Combat Engineer
Combat Engineer
User avatar

Joined: 18 Jul 2005, 01:00
Posts: 1001
Collision detection isn't err that great at the moment.

I had envisaged and two tier system, where it would avoid head on collision by moving away from them, i.e stop ramming. Followed by the final check of if two ships ellipsoids collide then respond.

I had to comment out the code for the first one as it isn't working quite right.

The second one works err i hope, in a kind of pinball / master-slave method :)

Where if two ships have met and aren't currently responding to another collison then they check off against each others hieght, highest goes up lowest goes down.

Pretty simple really, they also take into account each others current velocity/ direction.

The main problem i have at the moment is that (bar look and feel of it), the ellipsoids attached to each ship aren't rotating along withe the ship so therefore are not covering the correct 'position'. That needs to be solved first.

I've just spent a good two hours adding ship models, next i've got to add all the hitpoints and various sounds beam textures etc associated with each ship.

Then right up a more uptodate readme and release it for evaluation ;).

Also i really hope it works for you Malv, considering the last one didn't.

Regards Wolfe

_________________
Image


07 Jun 2008, 00:20
Profile
Fleet Admiral
Fleet Admiral
User avatar

Joined: 13 Nov 2006, 01:00
Posts: 2111
Location: Germany
I'm confident it does :D

Anothing thing, in the follow command video, the ship's adapting movements looked a bit abrupt and stepwise. I think instead of checking each 2 seconds if the path is still headed directly towards the enemy it would look better if a certain path assumption based on current vector heading (and angular velocity if it is constant enough like in a turn around maneuvre) is precalculated for let's say 6-10 seconds flight time and the ship is heading directly towards that point and not the current position of the enemy's ship. Now each 2 seconds a short check if those projected coordinates are still valid given the new vector heading and position of the ship could be performed. After those 6-10 seconds, a new projection could be calculated. With that, we won't have constant course corrections and if possible, it could also be programmed that once a ship is sufficiently close behind an enemy's tail (let's say in a larger ellipsoid around that ship; but only at the rear or side part; no captain is that stupid as to "follow" a ship by flying directly in front of it effectively pointing his rear towards him to blast away ;)), that it automatically gets the same movement vectors and follows them as the ship in front or side of him. Of course with a certain time delay depending on the crew's experience in order to give the followed ship the chance to break out of the "chainlock" and get behind the rear of the former follower itself.


07 Jun 2008, 08:21
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 24 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.