bmax physics engine

Community Forums/Showcase/bmax physics engine

flounder22001(Posted 2006) [#1]
I've been working on this engine for quite a while now. it currently features:
circle-circle collisions
line-circle collisions
line-line collisions

the circle to circle and line to circle collisions are time based, meaning they won't pass over eachother when they are moving really fast. Line to line time based collisions are soon to come but my current idea for it is very slow.

will i release the source? If i get some complements or some constructive criticism ;) .

Theres still *a lot* of things i need to add, including documentation, even though the demo might seem near complete. Some of the things i need to add are:
>rolling balls
>making polygons seem non-hollow (they are joined lines)
>friction between circles and lines. think jumping on a moving platform and not moving with the platform.
>faster time based line-line collision
>a method to handle collisions between parralel lines

use WASD to move turret, mouse to aim, and click to fire. The balls are shot at 100 pixels per loop to test the time based collisions.
http://agogsoft.com/physics3.zip


tonyg(Posted 2006) [#2]
Flounder, I can't get to the server for download.


Haramanai(Posted 2006) [#3]
Looks good.
About rolling balls I may sugest you to have a look at this : http://www.blitzmax.com/Community/posts.php?topic=55799
the ellipsoid always sliding but I think it can be tricked to bunce and slide.
Also it have very good intersection functions.
Be sure to read the original document.
For the boxies I thing you better give up the idea of the line-line collision and starting to learn about separetion axis and OBB ( oriented Bounding box . if I rember it right )
About Parrarel lines you must create a Global that will be your minnimum float calculation and check if the collision between the parralel line is lower of this otherwise you may get infinity numbers.

>making polygons seem non-hollow (they are joined lines)
this will work for circle but not for other shapes.


tonyg(Posted 2006) [#4]
Does look good.
Ball is a bit quick to really check the collisions but some of them get inside the squares... Is that expected? Also, if you move the canon to the bottom left or right behind the 'wall' and fire a single bullet it will get stuck behind the wall with seemingly no way out. If you go mental on the fire button they begin to escape.
Not sure how this should be handled but seems to miss the collision.


Haramanai(Posted 2006) [#5]
It's not expected but the way the balls are reacting with each other looks good and the way the boxies are reacting when the collision it's right looks good.


flounder22001(Posted 2006) [#6]


Here's an overview of how the system is structured:
there's points and constraints. Points can have masses, radius's, velocities, etc. Constraints can connect 2 points and potentialy become lines. The circles in the demo are points with radius's, the lines are constraints flagged to be lines.
When a line or circle gets created, it gets added to a list in a group. To begin with the only group is world_group and if a circle or line isn't assigned a group, thats where it goes. Groups can have self collisions enabled/disabled. Each group also has a bouding box to determine if it's colliding with another group.
A line is 2 connected points. If the masses of the points differ, then the mass of a point on the line is determined by how far/close the point is to the end points. Lines can also have circles on the each end by raising the radius of the end points in the demo.

tonyg, the reason the balls won't move out from the corners is because the corner isn't a polygon in the sense you are thinking of it. It is just a line...if the ball hits the line it responds, it isn't a filled corner. This is also why balls can stay inside the boxes.

The reason why the balls get in them boxes or out of the corners is because other objects force them to move to a point that is at least half way on the other side of a line, so when the ball and line collide it forces it the rest of the way to the other side.

Haram, i've heard about the SAT but my understanding of it still has some holes:
1) get the angle between the 2 bodies
2) draw a line in between them perpendicular to the one connecting them
3) if a point from both bodies crosses the line then they are colliding.

If this is correct then it seems like a bad idea waiting to happen...

The lines do abort detection if they are parallel (see the LinesCross function).


Haramanai(Posted 2006) [#7]
Yes SAT it's to complicated to get used to it ( I haven't implimented any it's still confusing for me too )
The method you are saying may work but it's not the best way to do it. I tried sometime before with no success. But the overall idea is to make all the checks in 1D. A good place to start is : http://gpwiki.org/index.php/Polygon_Collision
Also make a search for the polycollly. It's maybe safe to say to you not to stuck with this method.

If I am not wrong you are using Verlet integretion.
Make a try of Flade's traslation in BMax by Dooz you can find it near the end of : MaxPhisics Comunity project thread. Click it in my sig to go there.

Last grap a vector lib or start to create one. I am sure coding will be easier and you will find out that you were repeating your self. This is what I am doing. I am using a Vector lib for expirimenting and when I have the disired output I break down the equations to get as minnimum equations I can get.

I am not the best person to help but I hope I helped.


Head(Posted 2007) [#8]
May someone tell me how i can change friction and gravity on flounder22001's example, pls?

Edit:
Ok, i found the gravity, but not the friction :(