Bullet 'Hello World' example

pascal's picture

I've just put together a sort of "Hello World" example of using the Bullet game physics engine in a QCPlugin :

The folder contains : - a QCPlugin : tLBulletHelloWorld.plugin - a QCComposition : tLBuller_HelloWorld_b1.1.qtz - the related XCode project ( with all Frameworks , and sources included )

To start a project from the scratch you'll need to :
- copy the bullet-2.78/src in your project directory ( and include this in the project search paths ) - import/link the bullet frameworks ( from the Frameworks folder in the Xcode sample project ) .

Voila , sure there might be smarter ways to do it ..just thought this could interesting .

P.

pascal@t-linked.com

PreviewAttachmentSize
tLBullet_HelloWorld.zip9.68 MB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

photonal's picture
Re: Bullet 'Hello World' example

I'm getting "tLBullet_Hellowrld_b1.1.qtz" was not restored successfully.

This is with trying with the tLBulletHelloWorld.plugin in 'Quartz Composer Plug-Ins' or in 'Quartz Composer Patches'.

Which folder should it go in?

[I wish a future version of QC would consolidate these folders into just one Folder - or at least change the required file type of Patches to QUARTZ_FILENAME.patch ]

Also, should this Plugin/Patch appear in the Patch Library?

pascal's picture
Re: Bullet 'Hello World' example

/Library/Graphics/Quartz Composer Patches should make it .

photonal's picture
Re: Bullet 'Hello World' example

Strange one this. I have placed your plugin in the /Library/Graphics/Quartz Composer Patches folder but am getting the following:

(null) : Bundle at path "/Library/Graphics/Quartz Composer Patches/tLBulletHelloWorld.plugin" is not a valid Graph Foundation plug-in

pascal's picture
Re: Bullet 'Hello World' example

Could not really reproduce the problem from here . But I'll investigate . What's your configuration though ?

P.

hiltmeyer's picture
Re: Bullet 'Hello World' example

hello pascal i got the same problem as photonal.

pascal's picture
Re: Bullet 'Hello World' example

Well sorry , the plugin should be copied to "/Library/Graphics/Quartz Composer Plug-Ins" , and that should make it .

( I mentioned the wrong path in the previous post )

photonal's picture
Re: Bullet 'Hello World' example

Could it be that the comp is expecting a different 'plugin name'?

I can't find your plugin either in the Patch Library - what is it called here? (I have placed the plugin in /Library/Graphics/Quartz Composer Plug-Ins)

(null) : Patch with name "QCPlugInPatch:tLBulletHelloWorldPlugIn" is missing

Macro Patch Cannot create node of class "QCPlugInPatch" and identifier "tLBulletHelloWorldPlugIn"

Macro Patch Cannot create connection from ["output" @ "Splitter_7"] to ["inputGravityZ" @ "PlugInPatch_tLBulletHelloWorldPlugIn_1"]

pascal's picture
Re: Bullet 'Hello World' example

OK :

Would that will work for you ? :

PreviewAttachmentSize
tLBulletHelloWorld.zip9.66 MB

dust's picture
Re: Bullet 'Hello World' example

i got this running. the plugin is looking for the bullet frameworks inside pascals documents folder.

what i did was.

download bullet and recompiled the frameworks for my computer as libs and then added them to plugin and deleted pascals frameworks and bullet src files then built the plugin.

see attached plug. built... 32/64bit i386, x86_64

bullet looks pretty sweet. i always learn a lot from tl files. this hello world is a box / sphere drop with gravity and collisions. see pic.

photonal's picture
Re: Bullet 'Hello World' example

not really, now I get:

(null) QCPlugIn: Cannot preflight plug-in at path "/Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin" (Error Domain=NSCocoaErrorDomain Code=3587 UserInfo=0x665aa0 "The bundle “tLBulletHelloWorld” couldn’t be loaded because it is damaged or missing necessary resources." (dlopen_preflight(/Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin/Contents/MacOS/tLBulletHelloWorld): Library not loaded: /Users/pascal/Documents/tLBullet/bullet-2.78/src/BulletCollision/BulletCollision.framework/Versions/2.78/BulletCollision Referenced from: /Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin/Contents/MacOS/tLBulletHelloWorld Reason: image not found))

pascal's picture
Re: Bullet 'Hello World' example

Cool .. Strange that the plug is looking for the bullet frameworks , outside the build since they are included in the plugin .

Thanks anyway .

photonal's picture
Re: Bullet 'Hello World' example

I get the following with Dust's version:

(null) QCPlugIn: Cannot preflight plug-in at path "/Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin" (Error Domain=NSCocoaErrorDomain Code=3585 UserInfo=0x66c480 "The bundle “tLBulletHelloWorld” couldn’t be loaded because it doesn’t contain a version for the current architecture." (dlopen_preflight(/Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin/Contents/MacOS/tLBulletHelloWorld): no suitable image found. Did find: /Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin/Contents/MacOS/tLBulletHelloWorld: mach-o, but wrong architecture))

pascal's picture
Re: Bullet 'Hello World' example

have you tried with the last bundle I've attached ?

https://kineme.net/forum/Discussion/Programming/BulletHelloWorldexample#...

photonal's picture
Re: Bullet 'Hello World' example

yes I tried the last one but got:

(null) QCPlugIn: Cannot preflight plug-in at path "/Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin" (Error Domain=NSCocoaErrorDomain Code=3587 UserInfo=0x665aa0 "The bundle “tLBulletHelloWorld” couldn’t be loaded because it is damaged or missing necessary resources." (dlopen_preflight(/Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin/Contents/MacOS/tLBulletHelloWorld): Library not loaded: /Users/pascal/Documents/tLBullet/bullet-2.78/src/BulletCollision/BulletCollision.framework/Versions/2.78/BulletCollision Referenced from: /Library/Graphics/Quartz Composer Plug-Ins/tLBulletHelloWorld.plugin/Contents/MacOS/tLBulletHelloWorld Reason: image not found))

dust's picture
Re: Bullet 'Hello World' example

yes this build works tl. just noticed the OSX stuff in bullets extra folders. i built the frameworks from bullets cmake file and got libs. "libBulletCollision.a" before i found the osx demos. nice example

pascal's picture
Re: Bullet 'Hello World' example

sorry for the noise .. I'll be correcting that and repost . At the mean time there still an Xcode project included , to build you own .

photonal's picture
Re: Bullet 'Hello World' example

Sorry I'm being so dim here but it seems I need to build the Bullet library before building the bullet plugin right?

or does the tLBulletHelloWorld.xcodeproj do this automagically for me?

dust's picture
Re: Bullet 'Hello World' example

works fine for me with xcode 4 64bit build. maybe you have qc in 32bit mode ? try building this src with native machine settings.

PreviewAttachmentSize
tLBulletHelloWorld.zip1.64 MB

photonal's picture
Re: Bullet 'Hello World' example

Well finally got it working but a nightmare to compile it!

and a great plugin btw pascal!

cybero's picture
Re: Bullet 'Hello World' example

Well, I only picked up on this late on in the day, but it ,compiled afresh, works nicely indeed.

Thanks for sharing pascal.

PostScript //////////

Have only compiled to 64 bit thus far. 32 bit provokes an error.

PreviewAttachmentSize
tLBullet_HelloWorld1.png
tLBullet_HelloWorld1.png56.21 KB
tLBullet_HelloWorld2.png
tLBullet_HelloWorld2.png77.74 KB
tLBullet_HelloWorld3.png
tLBullet_HelloWorld3.png100.68 KB

gtoledo3's picture
Re: Bullet 'Hello World' example

I looked at for a few minutes... Patch didn't restore. I haven't read through the whole thread. Is this being setup so that bullet is an external framework? If that can be changed, it would be way better.

pascal's picture
Re: Bullet 'Hello World' example

Same plugin , but this time the bullet engine is exported as C++ static libraries . The zip includes the QCPlugin , a demo patch , and an Xcode code project to demo how to build a project from the scratch .

PreviewAttachmentSize
tLBullet_HelloWorld.zip15.11 MB

gtoledo3's picture
Re: Bullet 'Hello World' example

You know what's a real trip... a trackball environment only changes the gl light position! Crazy! I haven't looked at the actual project yet.

Sometimes there's some weird stuff w/ QC projection / light, etc. It seems like when one implements GL Ortho/FOV/whatever type stuff, that sometimes Lighting or culling flip, or don't respond how one would think... but if you change your default parameters to be in ranges that are opposite of what is usually suggested as defaults in OpenGL literature, stuff starts looking "correct" (whatever that is...). I notice this in GL Tools and other stuff, so I know it's not just me! :)

dust's picture
Re: Bullet 'Hello World' example

pascal this is a great example. i took a class in physics modeling this semester so this plugin really interests me. i made a few physics examples in cl, nothing to the extent of bullet though.

actually your cl particle series helped me a lot, once i figured out how to integrate euler and verlet's into a cl particle system. now this plugin has inspired me to learn core gl programming. something i have been putting off for a while seeing there are so many higher level abstractions of the gl language.

actually working on incorporating the bullet raycast into this hello world so you can grab each box or sphere or well the nearest one to the ray cast. i almost have mesh collisions worked out by passing vertex, color, normal, and indices structures from qc to the plugin. slow going though. there really is a lot going on behind the scenes with GL that in quartz you sort of take for granted i guess let alone sorting out all the bullet classes.

i also added a trackball to the scene and noticed it updates the lights. haven't really any ideas what the issue is as i have never made a gl based plugin.

pascal's picture
Bulllet Soft Body example

Thanks for your comments .. So , again a bullet based QC example . Not pretending to be a very useful plugin though , but just a demo on using soft bodies algorithms within the bullet engine ( needs also for sure some OpenCL implementations to run complex meshes ) . Attached : a qcplugin , a comp , and the Xcode project .

PreviewAttachmentSize
tLBulletSoftBody.zip15.93 MB

photonal's picture
Rotate Soft Body World?

I'm doodling around in the great work done by pascal and have a question regarding rotation of the environment.

My C++ is very limited.

I declared:

btTransform* m_transform;

and am trying to use this in the '- (BOOL) execute:(id)' part of the code to rotate the 3D world via:

m_transform->setRotation(btQuaternion(0, 0, 0, self.inputRotateX));

[I've also declared inputRotateX with the other QC parameters: @dynamic inputGravityX, inputGravityY, inputGravityZ, inputRotateX; ]

It compiles but crashes when opened in QC.

Any tips very welcome.