Computer Science Canada

Prysx, Grade 12 Final Project

Author:  Saad [ Tue Jun 17, 2008 12:13 pm ]
Post subject:  Prysx, Grade 12 Final Project

For my summative project, I made Prysx, which is a particle and rigid body physics engine put together. This is a demo I put together. The graphics engine uses OpenGL, and for window management SDL was used.
code:
CONTROLS:
     If your drawing a polygon
     Right click stops the drawing of polygon
     Left click to set the starting point and left click to set the final radius at your targeted radius

     If point is on a polygon
     Middle click breaks apart the polygon

     Or else
     Left click spawns particles
     Right click pulls the particles towards the mouse
     Middle clicks blows them away from the mouse


Enjoy

Edit: Use this link for the latest versions

Author:  Aziz [ Tue Jun 17, 2008 12:32 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Is sweet. You know my views about it, I'll post the gist of suggestions for others:

- Colors
- Option to take of side boundaries
- Force of attraction/unattraction proportional to distance

I'm having fun with it (great distraction at work!)

Author:  Euphoracle [ Tue Jun 17, 2008 3:52 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Ooo, pretty and fun. I like it. Too bad my school doesn't let us do anything cool like this to show off a bit for our projects ):

Author:  apomb [ Tue Jun 17, 2008 3:59 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Congrats on getting all the bugs worked out. Its very nice.

Author:  Dan [ Tue Jun 17, 2008 5:19 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Very nice and for the linux fans out there, the exe seems to run fine threw WINE if you don't want to complie it.

Author:  Euphoracle [ Tue Jun 17, 2008 6:47 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Saad is more pro at cross compatibility than most commercial identities, so it seems (:

Author:  CodeMonkey2000 [ Tue Jun 17, 2008 7:09 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Saad, what's your secret to blurring?

Author:  zylum [ Tue Jun 17, 2008 7:11 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

Pretty nice! I see you only used convex polygons so I'm assuming you used the separating line theorem for collision detection? If not, can you briefly describe your method? I'm writing a physics engine as well but with arbitrary polygons so I'm using a different method (SLT doesn't work with concave polys).

Author:  Saad [ Tue Jun 17, 2008 7:16 pm ]
Post subject:  Re: RE:Prysx, Grade 12 Final Project

CodeMonkey2000 @ Tue Jun 17, 2008 7:09 pm wrote:
Saad, what's your secret to blurring?


No secret, basically drawing random lines over the current graphics. (Its in Main.cpp should you want to look around).

zylum wrote:

Pretty nice! I see you only used convex polygons so I'm assuming you used the separating line theorem for collision detection? If not, can you briefly describe your method? I'm writing a physics engine as well but with arbitrary polygons so I'm using a different method (SLT doesn't work with concave polys).


I did use convex polygons and separating axis theorem. However should you want to use concave and separating axis theorm, I recommend splitting the polygons into convex polygons. You can achieve this by triangulating the polygons and joining up those triangles that that create convex polygons to create smaller convex polygons. Now you test each of those smaller polygons for collision (Should any collide then you have a collision). I also think you could test it by using intersections of each line its up to you

Edit: Just to say one thing about the collision. It is not perfect right now and the collision doesn't work with polygons that have the same axis (polygons with even number edges, a square has 2 of the same axis). This is why if you noticed the polygon sides was always odd Wink. Perhaps some input?

Author:  Reality Check [ Tue Jun 17, 2008 8:52 pm ]
Post subject:  Re: Prysx, Grade 12 Final Project

Awesome dude. It's great that you guys did C++ in grade 12 though!

Author:  zylum [ Wed Jun 18, 2008 1:10 am ]
Post subject:  RE:Prysx, Grade 12 Final Project

I was wondering which method would be faster as they are both O(n*m). Also they both have very simple loops with few calculations. Though SAT quits when it finds that two polygons aren't intersecting and line intersections quits when it does find an intersection. Typically, it is more likely that two polygons are not intersecting but how much complexity would be added for concave polygons?

Author:  md [ Wed Jun 18, 2008 10:34 am ]
Post subject:  RE:Prysx, Grade 12 Final Project

This is pretty cool!

Author:  Saad [ Wed Jun 18, 2008 10:53 am ]
Post subject:  Re: RE:Prysx, Grade 12 Final Project

zylum @ Wed Jun 18, 2008 1:10 am wrote:
I was wondering which method would be faster as they are both O(n*m). Also they both have very simple loops with few calculations. Though SAT quits when it finds that two polygons aren't intersecting and line intersections quits when it does find an intersection. Typically, it is more likely that two polygons are not intersecting but how much complexity would be added for concave polygons?


For concave polygons you will be testing for which of the convex polygons, but I would go with SAT since it wouldn't check some edges that have no need to be checked.
Also SAT would let you project your edges with velocities which makes it much easier find if they'll collide in a frame or not aswell as give you collision normals and translation vectors so that they don't collide.

And thanks all for the great comments Smile

Author:  corriep [ Sun Jan 25, 2009 9:21 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

The link doesn't work for me Sad

Author:  saltpro15 [ Sun Jan 25, 2009 9:23 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

bad necro paul!

Author:  Saad [ Sun Jan 25, 2009 9:34 pm ]
Post subject:  Re: RE:Prysx, Grade 12 Final Project

corriep @ Sun Jan 25, 2009 9:21 pm wrote:
The link doesn't work for me Sad


Ah sorry, I renamed the file before and forgot to change my post. Link works now, enjoy Smile

Author:  Homer_simpson [ Mon Jan 26, 2009 2:02 am ]
Post subject:  Re: Prysx, Grade 12 Final Project

very nice!
nice motion blur btw Very Happy

question: how does the polygon break

Author:  saltpro15 [ Mon Jan 26, 2009 10:37 am ]
Post subject:  RE:Prysx, Grade 12 Final Project

question : why does the command prompt open when I run it? awesome game btw

Author:  ecookman [ Mon Jan 26, 2009 1:41 pm ]
Post subject:  RE:Prysx, Grade 12 Final Project

coolest.thing.ever

Author:  Saad [ Mon Jan 26, 2009 2:44 pm ]
Post subject:  Re: Prysx, Grade 12 Final Project

Homer_simpson @ Mon Jan 26, 2009 2:02 am wrote:
very nice!
nice motion blur btw Very Happy

question: how does the polygon break


All of the polygons are composed of triangles, and so when they are created they are triangulated (via the ear clipping algorithm). When I want to break a polygon, each of the triangles become a separate polygon, and those get recursively subdivided into smaller triangles until an arbitrary depth is reached, which was just 1 for this demo, but if you want you can have it it subdivide much deeper and get a lot more triangles.

saltpro15 wrote:

question why does the command prompt open when I run it? awesome game btw


I used the command prompt to output debugging information but SDL didn't output directly to the console, and so I recompiled SDL so that it output to the console. Unfortunately I didn't have the time to recompile the source for Prysx with the original library and so the console shows.


: