1
$\begingroup$

Kind of a generic title, I know, but I haven't decided on any specific implementation at the moment because Blender offers many different potential ways to accomplish what I want.

Basically, I'm trying to setup a quick level editor for a project I'm working on. Rather than write my own from scratch, I decided it would be much simpler to just extend Blender with the Python API, especially since my requirements are very simple.

What I need is just a method to create a network of "nodes", and give each node a small set of custom properties including a unique 32 bit integer ID. An Armature, Mesh, or Curve seem like the most obvious objects to use, since they are easy to work with and are even connected visually in the editor. However, I can't seem to find out if it's even possible to add custom properties to each bone or vertex.

The only other solution I can think of is to use empties and connect them manually. This works, and I actually wrote a script already to do just that. However, working with a large map with many of these "nodes" would get very difficult to manage since the relationships/connections need to be input manually (e.g. each node has Next and Previous list properties which contain IDs of the nodes connected before and after). Also, there isn't any visual representation of these relationships in the editor (like a line connecting them as you would see in meshes or armatures)

So is it possible to add custom properties to individual vertices or bones? If not, is there a better method to accomplish what I'm trying to do besides creating and manually connecting empties?

Alternatively, if I DO have to use the empties method, is there at least some way for me to represent the connections between them visually in the editor? Something as simple as drawing a line between two nodes, or even just displaying some of the properties as text.

Here is an example of the data/relationships I need to store in properties as JSON:

{
"TestMap":[
        {
            "ID":0,
            "ntype":0,
            "RulesetType":0,
            "RPreset":0,
            "x":0,
            "y":3,
            "plist":[-1,-1,-1],
            "hlist":[false, false, false],
            "Prev":[0],
            "Next":[1]
        },
        {
            "ID":1,
            "ntype":0,
            "RulesetType":0,
            "RPreset":0,
            "x":1,
            "y":3,
            "plist":[0,2,1],
            "hlist":[true, false, false],
            "Prev":[0],
            "Next":[2]
        },
        {
            "ID":2,
            "ntype":0,
            "RulesetType":0,
            "RPreset":0,
            "x":3,
            "y":3,
            "plist":[-1,-1,-1],
            "hlist":[false, false, false],
            "Prev":[1],
            "Next":[3,4]    << Notice there's a fork here
        }
        ...
    ]
}

As you can see, the data is just basic numbers, lists, bools, and (possibly in the future) strings

Thanks, any help is appreciated!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.