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 / Ray Tracing Bullets

Author
Message
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 16th May 2006 22:31
I am going to try adding a ray tracing bullet system now to my engine. I have never done this in any language, so I may need some help. Ive got the theory down in the game design theory thread, now I need a little language specific help. What functions would I need to use. I am guessing these functions.

dbMakeVector3
dbLengthVector3
dbProjectVector3
dbScaleVector3

I am just assuming these are the functions Ill need.
If you have done ray tracing bullets in an fps, please help!

5/14/06- 1327 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th May 2006 23:13
Would you not be able to just download Sparky's collision dll and call it with the db prefix? It already has all of the commands you'll need neatly packed into easy to use functions.

Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 17th May 2006 04:25
Is it free, and where can I get it.
I dont think that will work, calling it with the db prefix unless the dll has that programmed into it.

5/14/06- 1327 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th May 2006 04:36
Its free, go check the Program Announcements board (its stickied). I wouldnt know about the prefixing, I use DBP not DGSDK, but its worth a try I suppose. (Also, DBP has the Intersect Object command, it will tell you if a 3D model is intersecting two points, the only downside is it only returns the distance to the point of intersection, nothing else like the angle of the normal hit or the bounce direction.)

- RUC'

Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 17th May 2006 05:38
I cant find it there.

In the mean time, can anyone else get me DGDK help

5/14/06- 1327 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
Uncle Sam
18
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 17th May 2006 07:31
http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5

Sparky's DLL.

Uncle Sam
Nvidia Geforce 7600 GS 256MB PCIEx, 2.66 GHZ Pentium 4 proccessor, 768MB RAM
Need particles? Click here!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th May 2006 07:58
I'm not sure what you mean by ray tracing bullets, but I'll take a guess.


A,B are vectors for the starting point of the bullet and ending point, respectively. This forms a line segment which you then use to check for collision. Test the line against all polys in each object using a ray-plane intersection. If the line intersects the plane that a poly lies in, then check that intersection point against the actual boundaries of the triangle. This can be done simply by projected the triangle and the point onto the axis of the plane's normal with the largest component, thus turning the problem from 3D into 2D. At that point you can then just look up any point in a triangle algorithm.

let T1, T2, T3 be the 3 points making up a poly

Subtract vectors to form 2 lines that lie in the plane, then normalize the cross product of the 2. This will give you the normal of the plane.

N = normalize((T2 - T1) * (T3 - T2))

Now form a ray representing the bullet, using A and B as defined above.

V = B - A

Assuming the vertices are in clockwise order, take the dot product of the plane's normal and the ray to check for which side of the plane we're on. If the result is less than 0, then we're facing the front of the plane and thus we should check it for collision. This simple check can greatly reduce the number of needed calculations.
(remember that a dot product of 2 vectors returns a single value)

if N.V <= 0 then check for collision

We form a ray from any point on the plane and the origin of the bullet ray.

R = T1 - A

Dot product again to form the parts of our quadratic equation.

num# = N.R
den# = N.V

Now get the time of intersection between the ray created from the bullet and the plane.

t# = num# / den#

Since a line can be infinite, so can our answer. To make sure the collision happens between the starting and ending point of our ray, t# must be between 0 and 1, inclusive.

If t# meets the above condition, then get the point of intersection.

I = V * t#

Use this point 'I' and the 3 points from earlier 'T1,T2,T3' to do the triangle check. If that returns true, then the bullet has in fact collided with the object at this point.

But you're not done yet. Store the value of t# and perform the collision checks all over again. You need to check every poly in every object, because more than 1 collision is possible. The first collision, the one you want to respond to, is the collision which has the smallest value of t#


I hope this helped you.


Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 18th May 2006 22:19
Thanks for that write up.
Anyone help me with the db commands?
Im not quite sure what to use.

5/14/06- 1327 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 18th May 2006 22:56 Edited at: 18th May 2006 22:57
In dgsdk like ruccus mentioned there is the dbIntersectObject
but its not very good for a bullet system as it is limited, I use newton but sparky's dll is pretty good for this too, again as mentioned above.

EDIT: it depends on what your are doing as to what system to use, if you are implementing a physics system use newton, if its just simple collision use sparky's.

My W.I.P project
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 20th May 2006 01:16 Edited at: 20th May 2006 02:07
What do I have to type to be able to use the commands in the dll.
I have downloaded it and added it to the the project.

But using the dgdk commands, can anyone help me out?

All I know how to do is make the start and end vecotrs.

5/14/06- 1327 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 20th May 2006 21:57
Does anyone use the DGDK for this?

5/14/06- 1427 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 6th Jun 2006 05:42
bump

5/14/06- 1720 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 12th Jun 2006 21:38
anyone?

5/14/06- 1720 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.

Login to post a reply

Server time is: 2024-05-18 19:40:01
Your offset time is: 2024-05-18 19:40:01