PDA

View Full Version : Physics engines



Ingemar
04-09-2011, 04:34 PM
I have been working a bit on game physics lately, especially on ragdoll physics, with lots of constraints. I have tried to make it work myself, and it isn't too bad... but it took some time.

I have to ask me if I can save time by using a physics engine, but it is kind of hard to pick one. Some have FPC interfaces, like Chipmunk Physics, but I don't see any demos, at least not any without a lot of additional dependencies. Pappe seems not to be Mac compatible. Etc. The amount of work before I can see if an engine is anywhere near what I need mustn't be too big.

Any suggestions for portable, Mac compatible physics engines with FPC interfaces (or, even better, written in FPC) without lots of dependencies and decent demos - in FPC?

Andru
06-09-2011, 11:43 AM
There is a full Chipmunk port to Delphi (http://www.par-com.net/~paulr/GLScene/chipmunkdemo.zip), which is very old and you will be needed to make an effort to make it works with FPC :) But it's can be done, year ago or so I done this, but then decided to make bindings instead of this :)

Also there is a port of Box2D for Delphi (http://code.google.com/p/box2d-delphi/). I don't know how it works now with FreePascal, but long time ago I didn't like it.


like Chipmunk Physics, but I don't see any demos, at least not any without a lot of additional dependencies.
That is ridiculous... really, if you just can't remove only one function(cpDrawSpace) of rendering via ZenGL(or just use latest svn revision from chipmunk-pascal with adding your own rendering functions), then I don't know... how are you planing to develop something using Pascal, world of which is far from "easy way to develop" in some cases? O_o At the end of the week I can spend some time for improving chipmunk-pascal and trying to port demos which I have to Linux/MacOS X(these demos use only OpenGL and GLUT, but now works only on Windows), but I don't think it will help you a lot... because if you want to develop something with non-Pascal libraries - you should understand C/C++ and be prepared for learning C/C++ demos. Just waiting for someone help, when almost everything is ready(bindings, simple demo) - luxury which other developers have no in other cases.

Maybe I'm too rude, if so - excuse me, but text above is true.

Ingemar
06-09-2011, 05:21 PM
That is ridiculous... really, if you just can't remove only one function(cpDrawSpace) of rendering via ZenGL(or just use latest svn revision from chipmunk-pascal with adding your own rendering functions), then I don't know... how are you planing to develop something using Pascal, world of which is far from "easy way to develop" in some cases? O_o At the end of the week I can spend some time for improving chipmunk-pascal and trying to port demos which I have to Linux/MacOS X(these demos use only OpenGL and GLUT, but now works only on Windows), but I don't think it will help you a lot... because if you want to develop something with non-Pascal libraries - you should understand C/C++ and be prepared for learning C/C++ demos. Just waiting for someone help, when almost everything is ready(bindings, simple demo) - luxury which other developers have no in other cases.

Maybe I'm too rude, if so - excuse me, but text above is true.
I am not sure we are talking about the same thing. The dependencies I want to avoid are dependencies of large additional libraries, especially those that don't exist on all platforms. A package tightly integrated with some huge Delphi framework might take ages to port. If it uses a lot of Win32 calls, it can be complicated to replace that with something else (unless there is a well defined interface so there is only one place to make limited changes). If I can compile and run simple demos using only the package itself plus OpenGL, then it is pretty much perfect.

The inspiration to the post came from the Box2D port you mentioned. It should be so right, but what I saw was a lot of porting work I had to do, for something I didn't even know if it worked properly. Coding in the dark is rather scary.

However, Windows OpenGL code is no problem at all. Pretty much effortless.

I do understand C/C++ code, and port (and to some extent - more often that I'd like - write) such code pretty much on daily basis. I have ported a lot of headers and code. But if someone has a comprehensive and complete API for FPC, then it would be a pity to be without just because I didn't know about it. My main target right now is to work from Chipmunk's C demos with the FPC headers... but maybe someone else had something similar, I thought.

Andru
06-09-2011, 05:52 PM
The dependencies I want to avoid are dependencies of large additional libraries, especially those that don't exist on all platforms.
Strange, because Chipmunk(about which you wrote in first post) exists on every platform - Windows, Linux, MacOS X and some time ago I compiled it for iOS (http://code.google.com/p/chipmunk-pascal/source/browse/#svn%2Ftrunk%2Flib%2Fios_arm), so it can be used with FPC via static linking... :)

Ingemar
07-09-2011, 04:59 AM
Strange, because Chipmunk(about which you wrote in first post) exists on every platform - Windows, Linux, MacOS X and some time ago I compiled it for iOS (http://code.google.com/p/chipmunk-pascal/source/browse/#svn%2Ftrunk%2Flib%2Fios_arm), so it can be used with FPC via static linking... :)

Yes, and that is my primary choice as I mentioned, and I have the static library on my disc already. But if someone had some FPC demos ready, it would be unnecessary to port the C ones. Or pointer to other alternatives which don't require major rewrites.

But Chipmunk isn't generally what I see people recommend for ragdoll physics. They recommend Box2D, and there is also the Pappe library which promises support for ragdoll physics, but both these seem awkward to port to me.

I am not afraid of porting code, far from it, but my time is limited and I must choose my battles. Small demos are easy to port, big ones are harder, and entire frameworks might take lots of time. Sometimes you just have to step back and see if there are other paths than the one you had in mind, before going too far on that one.

Andru
07-09-2011, 09:00 AM
Here the chipmunk demos (http://zengl.org/tmp/chipmunkDemo.7z) for Windows. OpenGL and GLUT the only dependencies.

virtual
07-09-2011, 01:15 PM
thanks Andru , the speed is about equal to the original c++ demos , i recompiled it with delphi 2006 , seems delphi produce fast code than fpc

Ingemar
07-09-2011, 07:04 PM
Great! It compiled immediately, I have some link trouble so far but that should be managable.

Ingemar
12-09-2011, 06:53 PM
thanks Andru , the speed is about equal to the original c++ demos , i recompiled it with delphi 2006 , seems delphi produce fast code than fpc

What is equal, Delphi? Do you mean Delphi is as fast or faster than FPC?

mds
07-08-2013, 10:19 AM
Here the chipmunk demos (http://zengl.org/tmp/chipmunkDemo.7z) for Windows. OpenGL and GLUT the only dependencies.
It certainly is compiled, but an arithmetic overflow occurs at startup. Physics dovno not been updated, and of course with the current version of the compiler I think these errors are possible. How can I fix this? Or what other options there are, that would not suffer, and to connect the physics and can already be working.
The very error occurs here:



if options.drawShapes then
begin
cpSpaceHashEach(space.activeShapes, drawObject, space);
cpSpaceHashEach(space.staticShapes, drawObject, space);
end;


in the funtion draw by drawSpace module