Writing plugin's in C++?

Is Python the only way to write plugin’s for Blender? Is there any means to access Blender’s data structures/routines via C++? I was looking into ways of writing plugin’s for mesh objects and the Texture/Sequence plugin method don’t seem provide this sort of thing… or am I wrong?

you can write python modules in c/c++

but that is about as close as you can get, without coding something inside of blender

But does that give me access to data provided by Blender API such as mesh vertices, faces, etc? If I write something in Python itself I will be able to do so but I’m doubtful of efficiency. Besides, I’m more comfortable with C/C++.

A question comes to mind… how was Yafray plugin written for version 2.34?

You might look at the bpy API docs to see what it provides; theNMesh module in particular.

As to efficiency, bpy itself is implemented as python extension modules written in C. It is designed to be a thin wrapper around Blender’s data structures.

A decent C++ programmer should have no problem picking up Python as a language. Especially if you are familiar with things like the STL.

Maybe bpy is a better way to work with meshes in Blender if things don’t get too complicated. I’m familiar with Perl & TCL/Tk so Python isn’t a problem. I’ll look into the API. Thanks for the info.

Okay, I’m faced with some issues; maybe you Blender/Python gurus can help with. I need to be able to access information about relationships between vertices, edges, faces in order to implement an algorithm via a plugin. Here are examples:

  • Determining all faces & edges incident on a vertex
  • Determining all neighbouring vertices of a given vertex

There doesn’t seem to be enough info in the docs to answer such questions from Python. Thats why I originally thought of writing the plugin in C. Writing a Python extension seems like a daunting task but I could implement a half-edge or winged-edge structure extension.

If any of you have a better solution, I’d like to hear from you.

writing a mesh library to generate edge and mesh info is easy to do and has been done several times

also, it shouldn’t be that difficult to code in c [you’d probably use an array of pointers instead of dictionaries as is easier in python]

simply you’d need to go through the faces, and add edges to your edge list, and if they are already there add the existing face to them. Also do this for the verts if you want the info of the verts they are connected to.

in python I did this [I used someone else’s mesh lib though, I have my own now] in my autosmoothing script:

Cool. Thats a good start for me. Thanks.

Oh well! It seems the idea of writing a python script might not be very good.

First, I’ll explain what I was attempting to do; maybe some of you gurus out there can comment on this.

I wanted to implement a paper on Multiresolution Adaptive Parameterization of Surfaces (MAPS). The uses are:

  • Generating coarse approximations of a triangle mesh and then re-meshing it to give several level of detail meshes.
  • Generate automated morphs between meshes with the same genus (same number of holes).

Any how, some of the stuff is quite difficult to implement in Python; e.g. Constrained Delaunay Triangulation (CDT). Some of the stuff is already in Blender but not exposed; e.g. Beauty Fill could easily replace CDT!

The original idea was to obtain the mesh hierarchy from an input mesh via MAPS and store it in a file that can be later loaded by another script that can provide the different levels of details and allow for morphing two such files.

Anyhow, I am very close to dumping this idea. What I’m wondering if this would be useful for anyone as a feature? Maybe implement it myself in Blender using C++ (which I think won’t be that big a problem as I looked at the source).

So, enough of my rambling, and on with your comments and suggestions!

  • Generate automated morphs between meshes with the same genus (same number of holes).

That is cool, Terminator!

Any how, some of the stuff is quite difficult to implement in Python; e.g. Constrained Delaunay Triangulation (CDT).

I have come across a code. But I think a source in C/C++ will speed up.