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…
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.
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: http://gamecode.tripod.com/tut/tut06.htm
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?
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.
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.
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.
Yes…!
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.