How to add a new object type to Blender


A few days ago I asked a question regarding a minimal build of Blender so as to be able to get an idea and evaluate if I could integrate a new object and associated code of a project of mine into Blender. I got the information I requested to do this and from the time I have spent, I think I have a decent idea of how Blender is structured and where, or at
least how to find a desired aspect or feature of Blender to inspect.

The problem is how everything is linked together, and what needs to go where to get a new object type embedded and working in Blender.

I have tried to use the MantaFlow module as a guide, but I have found what looks like references in the core blender source code exists that is directly related to the manta flow module and essential to its operation. I have come to the conclusion that if I am to add a new object data type I would need to add/modify the core blender source code, and if I start changing things there without knowing what needs to be done, I can potentially create problems that will crash the application without knowing why because a certain modification needs to be made in a certain header or .c file.

For example, I have found in the makesdna.c file a list of DNA types initialising in a includefiles array that I did not expect. Another unexpected find in the External Dependencies folder of the Visual studio project makesrns is that there exists a rna_internal.h file that has definitions of RNA functions that are scattered in various .c files. So I am going now to be more specific in this question and hope someone with some knowledge can help, or point me to some documentation or information.

The object I wish to include is not complex in structure, and does not use any external libraries or dependencies except for a single, very large .h file that cam easily be referenced or embedded. I have inspected the volume object type and found it to be a C++ structure type, which tells me if I convert my C++ class into a C++ structure, I should be able to define it in Blender.

If one is going to add a new object type to Blender, what new files needs to be included, where do they need to be included, and what existing files need to be modified to so blender recognises a new object type that can be used ?

I hope this is not too much of an ask, but I am not confident to go into the code and start adding/changing things just yet and just cannot find any information on the web, or in the forums.

Thanks in advance and appreciate any help provided.

Adding a new object type is no trivial task unfortunately. You have to make changes in quite a few places. I suggest you take a look at this commit:

1 Like

Thanks jacqueslucke. The reply was so quick that I had not finished my cup of coffee I made after I made my query, and just happened to have the blender forum web page still open.

This seems to help immensely and I am grateful. It seems so many changes has to be made that are far more than I ever imagined, and I hope I have not bitten off more than I can chew.

All the best. Thank you .

1 Like

What type of object did you want to add?

Greetings Josephbburg

The object I am evaluating Blender to see if I can add it is what I call a Hexaganal Close Packing (HCP) voxel volume.

I do not know how much detail you wish to know, but I will be as brief as possible without waffling on too much. I tend to waffle at times.

This Wikipedia URL and this one I just found with this https://mathworld.wolfram.comHexagonalClosePacking.html may give an idea of what this object represents in 3D space.

The object I am wanting to add is a C++ class that represents a lattice of trapezo-rhombic dodecahedron shapes which gives a space filling tessellation in 3D space. The distance rom the center of any voxel to any of its 12 neighboring voxels is the same, and the line joining any two neighbors goes through the center of a shared face.

What I have thus far done in the prototype application I have created is to represent a 3D volume of form f(x,y,z) = 0 and generate proceduraly a value for each voxel to indicate if it is inside the volume or not using a mathematical expression library called ExprTK by Arash Partow. By passing a value that represents a frame or time value to this mathmatical expression, an animation of this voxel volume can be generated. In addition I have added a cellular automata capability that modifies the voxel data within this object for each frame step of an animation.

As a final capability, and the reason I want to see if I can add this to blender is that this voxel data can be used to generate point cloud data representing a volume, or a surface with a surface normal value. In addition, a volume surface of faces can be generated that has normal data at each face vertex point.

The purpose of what I began was to proceduraly generate content and export this surface and volume data in .ply format to import into Blender. But since I realised animation, cellular automata capabilities and thinking about using this for simulations, it would be better to just bite the bullet and see how and if this is better to do in blender than reinventing the wheel as it were, and expanding my Qt C++ prototype to display and handle 3D visualisation like a 3D modeling software such as Blender can.

At this time I am still in the evaluation stage and seeking help when required. Right now I just don’t know, there is just so much I need to get my head around.If I am able to add this object and decide Blender is the way to go, I expect I will be making a fork of blender and sharing it if anything comes of it.

I hope this gives a bit of background as to what I am trying to do and the reasons.

I also hope I have not waffled on too much and bored you with too much detail.

All the best.