Here's the scenario:
I have a video game level design in Blender that needs to have the physics boundaries defined. Right now, I'm doing this by taking as many adjacent faces that, overall, make a tri/quad shape and extracting to a separate mesh. This separate mesh will be its physics wall.
I would like to write a Python script for it. Basically, the script will create a physics boundary for every surface that is a tri/quad shape.
The conditions are:
- Each face in the mesh MUST be a triangle.
- If a physics wall has multiple faces, each face MUST have the same normal.
- If a physics wall has multiple faces, each face MUST have an overall tri/quad shape.
So if you were to take a cube in Blender and subdivide the faces multiple times, but not actually move any of the vertices, the script will produce the original cube except the faces are in a separate mesh.
I've been trying to come up with an algorithm for this and the best I can come up with is:
for each unprocessed face starting from -axii to +axii (distance from origin):
select face
while selected faces have adjacent faces with the same normal:
select adjacent faces with the same normal
traverse outermost edges on all faces starting from -axii
while more than 4 edges with different directions are found
deselect outermost-face with the greatest +axii (distance from origin)
traverse outermost edges on all faces starting from -axii
create a physics wall with the 3 or 4 outermost verticies
mark all selected faces as processed
deselect all faces
Before I start writing this script, does an existing script, or portion of what I want to do, already exist? Does anyone see a problem with writing the script this way?