Page 2 of 3

Posted: Tue Nov 18, 2008 4:17 pm
by Kjell
Hi guys,

What about when you just want to use the collision routines of PAPPE? Would you then leave the UsePhysics checkbox blank, while filling in the GeoStyle / GeoMesh slot?

One of my questions concerning physicalized models would be what PAPPE does when you overwrite the transformation matrix. Does it use separate values for velocity, or is it position / cache based? Which would probably mean that as soon as you input a new position, the collision check would use a trajectory you probably didn't intend to use.

Using matrices is always a little slower then just a bunch of parameters, but a more severe concern is whether or not PAPPE uses quarternions for rotations, since ZGE is completely Euler based.

K

Posted: Tue Nov 18, 2008 4:21 pm
by BeRo
jph_wacheski wrote:humm,. not sure about the Transformation-Matrix vs separate vectors stuff,. is a transformation-matrix more efficient,. perhaps ZGE should adopt this? major rewrite issues aside,. just an intelectual question on speed and engine architecture out of curiosity.
Also I'm thinking this. But only the problem is that matrices are for newbies with weak math howto often too complicated.
jph_wacheski wrote: when UsePhysics is True will the model not get its Collision from the physics engine? perhaps physics should be on the CollisionStyle pulldown? then CollisionBounds/offset could be taken for PAPPE to use as well,. does it not use a cube first or is that created on the fly from the mesh?
PAPPE can generate so such collision volumes from meshs automatically, but with some important rules in the matrix identity state body orientation, fot example at cylinders, capsules, etc.

Posted: Tue Nov 18, 2008 4:30 pm
by BeRo
Kjell wrote: One of my questions concerning physicalized models would be what PAPPE does when you overwrite the transformation matrix. Does it use separate values for velocity, or is it position / cache based? Which would probably mean that as soon as you input a new position, the collision check would use a trajectory you probably didn't intend to use.
PAPPE has a PhysicsObjectSetMatrix and PhysicsRigidBodySetMatrix (also PhysicsObjectSetVector and PhysicsRigidBodySetVector), where PAPPE updates also then the another internal values.
Kjell wrote: Using matrices is always a little slower then just a bunch of parameters, but a more severe concern is whether or not PAPPE uses quarternions for rotations, since ZGE is completely Euler based.
The speed depends also on the used math routines implementations, for example, whether it are SIMD (SSE/SSE2/SSE3/etc.) optimized or not, which these in PAPPE aren't not (yet).

Posted: Wed Nov 19, 2008 7:39 am
by BeRo
Code to convert a 4x4 transform matrix to position+euler rotation in PAPPE:

Code: Select all

Position:=Vector3TermMatrixMul(Vector3Origin,PhysicsObject.Transform); // or simply: Position:=PhysicsObject.Position;
EulerRotation:=Matrix4x4Euler(PhysicsObject.Transform);
Code to convert position+euler rotation to a 4x4 transform matrix in PAPPE:

Code: Select all

PhysicsObjectSetMatrix(PhysicsObject,Matrix4x4Rotate(Euler));
PhysicsObjectSetVector(PhysicsObject,Position);

Posted: Wed Nov 19, 2008 10:13 am
by VilleK
Ok, here is what I will do:

First I make a new release of ZGE with the bug-fixes in the current beta. Then I'll begin with an attempt to use PAPPE in ZGE, and release a new beta of this as early as possible. Then we can continue the discussion and try different approaches. Since the ZGE-source is on a Subversion-repository we can always rollback and cancel the PAPPE-code later if it turns out it wasn't a good idea after all.

Posted: Wed Dec 10, 2008 3:32 pm
by VilleK
I've checked in the source for the first PAPPE integration in ZGE to the Subversion repository at a new branch called "pappephysics".

http://zgameeditor.googlecode.com/svn/b ... pephysics/

This means that the main build of ZGE is not affected and can be developed independently. We can continue to try out PAPPE whenever we have time and when/if we decide to use it we can include it in the main build or as a separate "ZGE Physics" release.

Ben has been very helpful and answered to my questions about the physics engine and made bugfixes and enhancements overnight. As he is now busy with other projects I think this is a good time to release what we got so far.

Here it is if you want to try it:

http://www.zgameeditor.org/files/ZGE_Physics.zip

A small demo-project is included. Please check it out to see how to use the PAPPE features.

Some notes:

- This is just a very minimum inclusion of PAPPE. Only Boxes and Spheres are supported, and there are many limitations on how to use them with ZGE-model components. The ZGE collision system has not been updated.

- The runtime binary have grown in size but is still way under the 64kb limit when compressed with kkrunchy.

- This is just a first test-release so be aware that everything about the physics implementation, including property names and values, can (and most likely will) change in a later release.

Posted: Wed Dec 10, 2008 5:37 pm
by kattle87
really, really nice! I hope the integration goes on, this is really looking promising =)

Posted: Wed Dec 10, 2008 11:47 pm
by turshija
simply WOW !
Good job !
its so amazing ... Although somewhat buggy (small stacking stress test with 50 boxes = around 3 fps :D), but looks promising ...
I will continue testing it ... :)

nice works!

Posted: Fri Dec 12, 2008 4:16 pm
by jph_wacheski
Yes this is quite cool,. I will play around with it and report back.

Just quickly started building a slightly prettier test area, attached. The third RMB press gives a 'pegged' cube to build solid structure stuff,.

Physics sims are netoriously fidgity and requite endless tuning to get usefull games from,. and this seems to be the case here as well,. time will tell.

Posted: Tue Dec 16, 2008 12:29 pm
by VilleK
Nice additions to the physics-project jph, I will use your version for future releases.

Posted: Wed Feb 23, 2011 11:51 am
by keymasher
Sorry if this was answered somewhere else, but what happened to this idea? Sounds really cool!

Posted: Wed Feb 23, 2011 12:15 pm
by VilleK
Rather than to integrate a physics engine into ZGE it is probably better to call an existing engine like Box2D using a dll as we do in this thread.
That project is just begun though, it would be great to use more features from Box2D if someone is willing to look into it.

Posted: Wed Feb 23, 2011 1:22 pm
by keymasher
I'm assuming you lose crossplatformabilty with the dll calls?

Posted: Wed Feb 23, 2011 1:48 pm
by VilleK
Not really. There is currently only a precompiled binary of box2dzge.dll for Windows, but Box2D is available for a number of platforms so the same library could just as well be available there.

Calling external modules from ZGE works on all supported platforms, here you see an example of calling opengl from ZGE on Linux: viewtopic.php?t=528&postdays=0&postorder=asc&start=90

Posted: Thu Feb 24, 2011 12:26 am
by keymasher
Wow! you've thought of everything ;)