I’m a complete beginer with Blender… and I’d like to use it to visualize mechanical simulations. I have coded a C++ physics engine that works fine, now I need to implement it within blender, by coding a plugin, using an hypothetical C++ API. Please do you know if this API exists?
Otherwise well i guess that I would have to use Python. I think it is possible, just like for Perl, to compile C/C++ functions to get Python modules, so these functions can be called from Python code… Is it right? I’m not sure i was clear…
Thanx indeed for your help (I guess I’m not the first one to encounter this kind of problem…)
All the best
Ps my physics engine is presented at www.cardynals.com , check it out to see simulation movies!
There’re plugins written in pure C; you could always write a C barrier between your C++ code and blender. Check in the online manual for details (http://download.blender.org/documentation/htmlI/ch27.html). However, it would seem that only Texture and Sequence plugins can currently be written…? I don’t think that an actual API was ever written, not for what you’re looking for.
It’s possible to link Python code to external C/C+±coded libraries; I know of at least one plugin using it-- the mesh sculptor. It uses an external DLL under windows to add calls to python for pressure sensitivity with pen tablets. Might want to search on the forum for the authors or just peek at the script to see how it was done. However, just running your C++ code through some sort of compile-converter isn’t something I’ve ever heard of. Perl’s a very different story.
The biggest hurt would be the having to write the glue code between your C++ functions and Python; I’d recommend SWIG. I have no experience doing such things with Blender, but since all the code is open to you I’m sure you’ll be able to figure something out if you try at it.
'Course, the above is all conjecture; I don’t code plugins, only Python. ^-^
If you’ve written it all in C++, why not just add it to the Blender code base? Jump on over to http://www.blender.org/forum/ and check out the Coding Blender forum for information on how to download the Blender CVS and compile it.
How big/np-complete is your physics engine? If it’s better than the current Sumo engine a lot of blenderheads would worship you for adding it.
Oh yeah. Once it is in the blender code you can easily add a python interface so that python scripts can access your physics engine.
Hi a better forum for this question would be the ‘python and plugins forum’
there is not an external API available - so you currently have two options - code it in directly (see Bullet) or use the Python API.
If you code it in directly it would need to be licensed GPL to distribute a Blender version with it compiled in. If you code it by exchanging information via python then your license on your code can be whatever you like.
Thanx very much for your clues. I’m sure I’ll manage somehow to implement my physics engine in Blender. Anyway, I’ll probably start a post about that, since the engine could be useful to programmers here. Feel free to check animated demos of mechanical simulations (22) at www.cardynals.com . I’ll be honored to get your impressions!
The easiest is to add it in the real-time part, similar to Sumo and Bullet rigidbody dynamics engines. There is already an abstraction layer in place. Also, it allows to bake your simulations and render them.
See the c++ physics integration files at: