Blenders C(++) plugin system in 2.5?

As we don´t have a programming subforum here yet, I guess here´s the best fit.
I can´t really find any decent information or documentation on it and I am stumbling around like a drunken dude in a cornfield on his way home.

Specifically I plan to introduce 3dConnextion support again for Blender 2.5
In 2.4 it was done via a compiled .plug but as far as I found out there wasn´t much use of this system at all. Either it´s not very usability friendly or there weren´t many taking advantage of it or I simply can´t find any information on it.

The 3dConnextion SDK is in C++ and I have no idea if I can somehow wrap it in a pyhton plugin, or if the .plugs will still be used in 2.5, or if it would be better to just implement the whole code in /external/3dcx for instance and offer a patch/binaries. Latter would be the easiest method IMO but not too elegant.

So, anyone out there with advice or who can give me a gentle push in the direction of information or documentation?

The wonderful coolnes of python is that it can be integrated as hell with C. I don’t know the program you refer to, but you can take it in 2 way.
1(more efficient and elegant solution, maybe more difficult): code your own C/python module. This helped me a lot in starting writing modules. Once you get it, it become easy as writing python scripts, just look often in the python api (that is well documented). From c you can access every c function including it in the source, or dynamically loading with LoadLibrary.
2: use python ctypes to access a library. You can create your python class that wraps the c/c++ library

I don’t know if this can be the solution, i don’t know 3dConnextion, but probably it is :wink:

You may want to check out the gsoc project from last year, summer of fancy input devices one. I believe that included 3dconnexion devices already. I would poke around a bit and check on it’s status.

I remember.
As the 3dcx support never came to blender 2.5 I assumed the project simply failed, but tbh I didn´t really follow it.

That would be this one :

For 3D mice, I’ll focus on 3DConnexion’s SpaceNavigator. This device is a deceptively simple knob that offers simultaneous control of translation and rotation, each in xyz. Blender 2.4 supported the SpaceNavigator through a plugin, but it has not yet been integrated with 2.5’s new event system. Low-level structures already exist for 6DOF (six degrees of freedom) events within Blender, waiting to be filled with live device input. The obvious first step is to get it working. The plugin for each platform needs to be updated to work with Blender’s new event system. In addition, the Macintosh plugin needs to be rewritten with Cocoa or CoreFoundation. The 2.4 plugin uses Carbon, which is incompatible with the latest Blender code.

I´ll check the source out.
But I think if it´s possible it would be more elegant to wrap the C++ in python and make it a plugin, rather than squeezing it into Blenders source.

Might this be something that Boost would be useful for? Someone reference boost while I was lurking on IRC so I started poling around on the Boost website.

My programming experience is fairly limited so please excuse me if this is a naive question.

Boost.Python is certainly the best way to communicate between C++ and python. Especially exporting classes is fairly easy.

There are quite some possibilities alright but there should be an intended way to do it and I guess that answer requires a core dev… I am sure jK will drop by anytime soon, else I´ll try IRC.

I´ll simplify the question:
What´s the designed/intended way to implement a C++ library based addon in Blender?

Right now, the only possible way is the one(two) i told you. If you really want to load library inside blender, than you’ll need to write your patch for blender that adds a new add on system that works with compiled non-python code. I can’t really get what is the problem in writing

import ctypes
mylib = ctypes.cdll.LoadLibrary("path/to/my/library")
mylib.name_of_the_function(args, to, pass)

and this will work even with already compiled libraries(so you don’t need to have the source and compile it). If they are C++, extern C {… } will allow to call them.

All I wanted to know was if BF had a plan or a current method thought out on how to do it. Call it a masterplan or yet better an implementation convention.
Personally I can think of many ways to squeeze a c++ library into Blender - that´s not really the issue :wink:

no plan other than if you want an addon use some external lib, either the ctypes way, or writing a module out of it are your options - these are the python ways, and in no way need to be addressed in Blender.

If you think about the old texture and sequencer plugins - that API hasn’t been reinstated yet, and I’m not sure when we will. Just integrating a C++ library in Blender and using its functionality means you will write a C API and use that. See for instance GHOST or Bullet in Blender.

The actual reason for this topic was that I was thinking of portability and ease of access.
I could easily implement it directly into Blender, but that would mean to have seperate builds for a “stupid” input device.
One could supply a patch and leave it to the people to supply builds, or even get it into trunk but that´s not too cool either IMO.
Blender´s core should stay slim and fancy like the Brontosaurus (tehehehe) it is, the rest should be done with plugins.

So I guess ctypes´ the elegant way I was looking for.
I can supply a plugin and the compiled library, and an installer would only have to copy the files to the right place and the users just have to activate the plugin in Blender.
I think that´s a desireable solution.

Will take some time though before I can start, just when I make a plan what to do with my spare time, 3 client projects hit me out of the blue same time =)