[Bf-python] Blender Plugin Question:

Jeremy Moles jeremy at emperorlinux.com
Thu Jan 26 05:29:49 CET 2006


I've written a very simple mesh format for a demo I'm working on that
does two things:

	1 - Contains "typical" vertex lists describing a single mesh object;
very simply, nothing fancy.

	2 - Contains another special list of quads that represent "spaces" on
the mesh upon which any of my "units" can move.

Here is a VERY oversimplified example (read terrain meshes aren't as
flat as this, nor are all the quads uniform in size) I whipped up in
Blender relatively quick:

	http://www.cherustone.com/Screenshot.png

My question is: in the past I've been create the "quad" metadata by
hand, going into the file and basically inputting the vertices that make
up each "space" manually. This working find as I was speccing the format
out using very, very small meshes. Now, however, I'd like to scale it up
a bit and use Blender's excellent UI to do the picking for me.

Does anyone have any recommendations on the best way to do this? I'm
familiarizing myself w/ the Blender Python modules, and have spent the
last few hours or so playing around with the Blender.Mesh.* namespace.
My idea was to do something like the following, though I'm not entirely
sure if all the tools are available and/or the functional is exposed:

	1. Designer creates the "board" mesh.
	2. Designer uses Blenders builtin face selector to pick
1 - n faces.
	3. Designer (perhaps) presses a key, adding the quad to a list within
the script.

I pretty sure the above is possible but the problem I'm having is
getting my head around the best way to implement it. I was thinking
something like the following (using psuedocode):

-----------

quads = []
mesh  = Blender.Mesh.Get()

def GetFaces():
	Blender.Window.EditMode(0)

	faces = [f for f in mesh.faces if f.sel]

	# Do face2quad calculations or whatever here
	# and append to quads

------------

where "GetFaces" is a callback bound to some key/button press. This
seems like it should work okay, but I figured I'd ask on this list
before I spent the time doing it, especially if there's an easier
way--of if it's been done before. I'm certainly not affected by "Not
Invented Here" syndrome, and would be more than willing to use existing
solutions. :)




More information about the Bf-python mailing list