Ah, so that was you who wrote the C wrapper? I saw that a while ago and
considered using it, but after looking at and exploring how
Chimpmunk2D works, I decided it was smaller, pretty darn good. That and
Chipmunk2D is already C, so very little work was needed from me to convert
it to work with Pascal.

Again, the physics part will be in my second release. The first part is
just getting the vector graphics and a minimal GUI toolkit in OpenGL
working. That plus an overview and reference website similar to my
https://docs.getlazurs.org website.

If anyone cares to know more, here is a brief description of how my object
oriented wrapper around Chipmunk2D physics is organized.

ISpace is the base object to work with physics. If you use the
TPhyiscsScene class it's created and managed for you automatically. ISpace
provides properties for controlling gravity, bodies, and joints. There is
one ISpace object per physics simulation.

IBody objects are added to ISpace using ISpace.NewBody, ISpace.NewDynamic,
and ISpace.NewStatic methods which create kinematic, dynamic, and static
bodies respectively. Kinematic bodies react to collisions with each other
and are affected by forces such as gravity. Dynamic bodies can be moved
manually by the programmer, but are otherwise unaffected by forces and
collisions. Static bodies cannot move but kinematic bodies may bounce off
them.

IShape objects are added to bodies using IBody.NewCircle, IBody.NewRect,
IBody.NewSegment, and IBody.NewPolygon method. A body by itself has no
shape. Its shape is defined by the shapes you add to it. Shapes within the
same body do not collide with each other or move with respect to the other
shapes within the body. Each shape within a body can have different
friction, density, and elasticity (or bounciness).  The mass and center of
gravity of a body is calculated by its constituent shapes.

IJoint includes a list of several joint types (I will not list them all
here), and they can be used to connect two bodies together. Some joint
types are motors, other are springs, and some are hinges or pivots.
Collisions between bodies connected by a joint can be set to be ignored for
those two bodies.

IArbitors allow you to either detect and handle collisions between body
types you define. You can ignore them if you simply want the physics system
to handle collisions for you.

Masks can be applied to body types, allowing you to say which bodies can
collide with which other bodies. For example, if you were writing a game
you could setup enemy bullets bodies to pass through enemy bodies using a
simple mask. The enemy bullet bodies could then be setup to collide with
the player body and wall bodies.

There is a lot more to the physics system, but my object orient design,
plus some documentation and examples ought to get most people running in
short order.

I have been mostly working on the graphics portion for the past week and
haven't been working with the physics system in that time. Last time I was
working on it I was trying to figure how how to make a decent rope. I am
not at all satisfied with my initial work, and maybe someone can help me
get rope physics working better, but below is the result of my first
attempt.

Rope test : https://streamable.com/lli866

I'll put all the information above and the source code online in a git
repository soon with a FOSS license. If anyone wants to help, let me know.
Join me in the discord channel listed in my initial message, or see me on
liberachat irc in the #fpc channel.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to