3D Physics with ZgeBullet

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

3D Physics with ZgeBullet

Postby Rado1 » Tue Nov 15, 2011 10:17 am

ZGEBullet DLL is a 3D physics library for ZGE. It is created as a wrapper of the Bullet library. Bullet is a high-quality open-source collision detection and rigid body dynamics library.

I took inspiration from GMBullet DLL developed for Game Maker, however, I implemented ZGEBullet from the scratch. ZGEBullet is simpler and smaller.

ZGEBullet is still in an early development stage, ie., it is stable, working well, but incomplete. During next days and weeks (months) I'm going to add more collision shapes, more properties for rigid bodies, constraints, etc.

Attached you will find the ZGEBullet DLL and a small ZGE demo project I'm using as a testbed for the implemented features. Move with arrows, generate single objects with 1,2 or 3, generate formations of objects with 7, 8, or 9, clear the scene with Space.

Note: I decided to create a wrapper for some good physics engine because I was missing this functionality in ZGE for longer time. PAPPE integration in ZGE was interesting, but unfortunately it was excluded from the main development stream of ZGE. Even if the ZGEBullet is bigger than usual 64kb, I hope you will enjoy it in your physics-aware applications.

Any comments are welcome.

Have a fun!
Attachments
Physics.zip
ZGEBullet.dll + demo ZGE project
(233.51 KiB) Downloaded 496 times
Last edited by Rado1 on Mon Jun 08, 2015 9:09 pm, edited 2 times in total.

User avatar
VilleK
Site Admin
Posts: 1693
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Tue Nov 15, 2011 3:58 pm

Hi Rado1,

Wow, this is another impressive project of yours!

PAPPE integration could be resumed again one day if there is enough interest in it. I remember there being some problems and small bugs but I see that BeRo updated the code this year so maybe that is solved now.

On the other hand I think that physics is probably one of those features that is best implemented as an extension to a well-known physics engine just like you have done here.

Let me know if you need help. You could put the source on Google Code if you want, just like Diki did with Box2D for ZGE.

Also I'm sure this project could be made to great use in the Visualizer. We are adding features right now, let me know if you want the latest beta!
Attachments
rado1_physics.jpg
rado1_physics.jpg (60.53 KiB) Viewed 5899 times

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Tue Nov 15, 2011 4:30 pm

Putting source code of ZGEBullet to Google Code is a good idea. Once I achieve personal confidence with the code and sufficient feature richness I put it there. The library is still too volatile, I'm fixing and adding new features each day (or rather night).

Yes please, send me the latest beta of Visualizer.

User avatar
jph_wacheski
Posts: 1004
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Wow!

Postby jph_wacheski » Tue Nov 15, 2011 5:35 pm

Very cool! I will check it out and give any feedback I come up with. Physics is a great addition to ZGE and will make many more advanced gameplay concepts much more possible.

Thanks Rado1.
iterationGAMES.com

keymasher
Posts: 39
Joined: Sun Feb 20, 2011 8:54 am

Postby keymasher » Wed Nov 16, 2011 5:52 am

I love the idea of a physics engine, it always reminds me of Sumotori Dreams, I'd love to try my hand at something like that in zge.

I noticed that this requires MSCVR100.dll, some C runtime lib ~300kb
So I'm guessing it would unlikely to be easily cross-compilable for use on osx/nix zge runtimes?

I always thought PAPPE was really nifty as well, I haven't really played with it since it never took off in zge.

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Wed Nov 16, 2011 7:42 am

This particular version of ZGEBullet was compiled in MSVC 2010 Express, so it is Windows-specific. However Bullet declares it can run on PLAYSTATION 3, XBox 360, Wii, PC, Linux, Mac OSX and iPhone. ZGEBullet is quite a simple wrapper which uses nothing special from Windows API; I tried to use generally written Bullet API as much as possible to avoid platform dependency. So if Bullet can be compiled on several platforms, I expect that also ZGEBullet can be. It's just a matter of compilation. But I have no experience with compiling to other platforms. Once, the source files are available, someone can try to compile it also for other platforms.

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Wed Nov 16, 2011 8:49 am

I played little bit with compiler options and reduced the size of the DLL from 504 KB to 284 KB. I hope it can be even better after some more exploration of MSVC.
Attachments
ZGEBullet.zip
ZGEBullet DLL
(140.87 KiB) Downloaded 414 times

keymasher
Posts: 39
Joined: Sun Feb 20, 2011 8:54 am

Postby keymasher » Wed Nov 16, 2011 9:27 am

awesome, i'll see if i can give it a go. Just read my post and sorry for being such a buzzkillington. Great work!

User avatar
Kjell
Posts: 1529
Joined: Sat Feb 23, 2008 11:15 pm

Postby Kjell » Wed Nov 16, 2011 11:17 am

Hi Rado1,

Nice work :) One small ZGE related tip .. instead of using a bunch of conditions to select which Mesh to render each frame, you can simply set the to-be-rendered Mesh of a RenderMesh component directly once. So ..

Image

.. and then use the following in the OnSpawn node.

Code: Select all

switch(ModelShape)
{
  case 0: ModelMesh.Mesh = BoxMesh; break;
  case 1: ModelMesh.Mesh = SphereMesh; break;
  case 2: ModelMesh.Mesh = CylinderMesh; break;
}

Attached is a basic example ( spawn shapes with key 1, 2 and 3 ).

K
Attachments
Shape.zgeproj
(3.08 KiB) Downloaded 391 times

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Wed Nov 16, 2011 12:38 pm

Yes, sure... thank you Kjell for the tip. That's why I like to share source files - learning from others.

StevenM
Posts: 141
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Fri Nov 18, 2011 3:15 am

Thank you!!!

I tried to get bullet workig in ZGE - It seemed impossible - and I had lot of trouble just compiling it - I hate working with SDK's. So this is really appreciated, hope we can get the source code and continue to develop this as a team - there is some great potential here. Bullet is an extraordinary and very popular physics engine - perfect choice. The fact that it is now a part of ZGE is a huge asset.

User avatar
jph_wacheski
Posts: 1004
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Postby jph_wacheski » Thu Nov 24, 2011 2:53 pm

Gave this a quick look,. it seems very usable (and powerful) so far. Just needs a few more functions to add impulses to objects, and get collisions for interactions, and we will be able to build interesting games using this.

Any updates?
iterationGAMES.com

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Sun Nov 27, 2011 10:51 pm

Hi all,

ZGEBullet v2 comes with the following improvements:

- New shapes: cone, capsule, and compound.
- Dynamic setting of more properties of rigid bodies: mass, restitution, hit fraction, and gravity.
- Setting position and rotation of rigid bodies.
- Getting and setting linear and angular velocity of rigid bodies.
- Applying impulses for rigid bodies.
- Constraints and limits.

The demo application has been improved by constraints - press 4 for a worm and 5 for a ragdoll, and velocity - press Enter to shoot a red sphere.

Further plans: even more shapes, collision detection (propagation to ZGE), constraint motors, enabling deactivation and sleeping thresholds, maybe also soft bodies (needs more exploration), etc.

I would really appreciate your testing. Thanks.
Attachments
scr.jpg
Screenshot
scr.jpg (58.67 KiB) Viewed 5701 times
Physics_v2.zip
ZGEBullet.dll v2 + demo ZGE project
(187.24 KiB) Downloaded 423 times

User avatar
Rado1
Posts: 669
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Mon Nov 28, 2011 2:02 pm

Another improvement is removing dependency on MSVCR100.dll. The size increased by 80KB, but this is probably more acceptable than installing C++ runtime libs for VS 2010.
Attachments
ZGEBullet.zip
ZGEBullet DLL v2
(231.14 KiB) Downloaded 426 times

User avatar
Kjell
Posts: 1529
Joined: Sat Feb 23, 2008 11:15 pm

Postby Kjell » Mon Nov 28, 2011 2:34 pm

Hi Rado,

Rado1 wrote:Another improvement is removing dependency on MSVCR100.dll. The size increased by 80KB, but this is probably more acceptable than installing C++ runtime libs for VS 2010.

This is definitely the way to go yes.

By the way, using stdcall instead of cdecl should generate a smaller dll.

+ What happened to the movable flag on AddRigidBody? I'm aware it didn't work before, so I'm guessing you've taken it out temporarily?

K
Last edited by Kjell on Mon Nov 28, 2011 6:36 pm, edited 1 time in total.


Return to “Extensions”

Who is online

Users browsing this forum: No registered users and 0 guests