1

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:

  1. Each face in the mesh MUST be a triangle.
  2. If a physics wall has multiple faces, each face MUST have the same normal.
  3. 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?

user489481
  • 321
  • 1
  • 4
  • 13
  • What about duplicating and using the [Decimate modifier](http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Generate/Decimate)? – gandalf3 Oct 20 '13 at 00:34

0 Answers0