Blender C++ API for plugins?

Hi everybody

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

Tantor

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. ^-^

as far as i know Blender only support plugin for texture and sequencer. for implement physics simulation system you must coding directly to Blender source code, for further information check:
http://www.blender.org/forum/ – thread Coding Blender
http://www.blender.org/cms/Get_Involved.233.0.html

i’ve seen your sites, really great physics simulation system and that will be great addition for Blender if you can implement it at Blender :smiley:

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.

Visit http://projects.blender.org/mailman/listinfo/bf-committers to subscribe to the BF-committers mailing list. The guys who read that are the ones who will review and incorperate your code into the blender base.

Hope this helps.

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.

LetterRip

Hello

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!

all the best

Tantor

What license is your project? Is it open source?

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:
blender\source\gameengine\Physics

By the way, what collision detection primitives do you support?
Erwin Coumans
www.continuousphysics.com