Building Hierarchies/Blender as Gameeditor- can it be done?

(Florian) #1

Ok. Here´s what I want to do and why I´m getting into this hole Blender/Python thingy.

I have written a 3D-engine and want to use Blender as a Modelling-Tool/Editor.
The engine is using hierarchical bounding boxes and portals.
Now guess what:
I´d like to write a couple of python scripts to use Blender for tasks like bulding these hierarchies, assigning objects to portals and so on…
Do you think this is possible?
I got the impression the PythonAPI is very limited, but on the other hand there is Game-Blender, which is scriptable…

Thanks in advance

(bmax) #2

cool idea, i dont know much about python script myself; but you could ask eeshlo. he seems to be quite good at it, he made an lf export script and HDRI support for blender.

(yann) #3

Yes, it’s possible, although I’m not sure what your portals are. As an example my NWN model importing script preserves the hierarchy correctly.

(Florian) #4

well, Portals are a modern concepts used to make potential visibility
sets for indoor-environments. I think, the Quake engine is based on
Portals, too.
Here´s an explanation of the concept:

To edit a scene, I would have to assign an object-hierarchie to quads.
Another concepts I´m making use of is hierarchical bounding boxes.

But I don´t know yet how to edit hierarchies in Blender nor how to
access them. I think, however, most of it will have to be done in
Python, or is there a way to edit hierarchies in Blender and access
them via Python?

(yann) #5

Editing hierarchies is simple; use shift and right mouse button to select multiple objects. The one you clicked on last is “active”, all of them are “selected”; you see that the active is a lighter shade of pink. Hit Ctrl+P to make all selected objects children of the active object. Selecting an object and hitting Alt+P lets you make it unparented.

(Florian) #6

thanks, yann :slight_smile:
than solves the first part.

the next (even more interesting) question is, can I read the
hierarchy using Python (in order to make an exporter) ?

(yann) #7

Yes, Python can read the relation - each object has a parent property, which yields either the parent object or None. However, there doesn’t seem to be an elegant solution for traversing the list the other way. I’m going to look more closely at the python interface when I get access to the source, which should be in just a few days.

(Florian) #8

Ah, I see. So a way would be to select all objects (or none) and
use GetSelected (Get) to read all objects into a list and then rebuild
the hiearchie by checking the parent property of each object.
That´s great. To make a Portal I´d simply attach a flag-property to
a Plane-Object using some custom-scripted button.

(yann) #9

Or use some name convention for the object, such as all objects called somethingPortal are to be marked as portals. The name is readily accessible in python, but a scripting button is trickier imho.

(Florian) #10

you´re right, that way it will be lot easier :smiley: