Exporting 2d shapes in clockwise order

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
phosphoer
Posts: 0
Joined: Wed Oct 02, 2013 1:30 am
Location: United States

Exporting 2d shapes in clockwise order

Post by phosphoer » Wed Oct 02, 2013 1:37 am

Image

I'm trying to write a script that will take this mesh, find each "island" of vertices, and then export each shape as a list of vertex coordinates in some linear order around the shape (e.g., I don't want triangle order, I want to list the vertices by following each edge)

The goal of all this is to write an exporter that will allow me to draw the shapes in an html5 canvas as filled polygons.

I'm stuck in 2 places. I don't know how to programmatically select each island (the equivalent of pressing L with mouse over one of the shapes), and I haven't been able to figure out how to traverse the vertices in the order that I want. Ideally, given a vertex, there would be some way to find the connecting vertices.

Thanks for your time

phosphoer
Posts: 0
Joined: Wed Oct 02, 2013 1:30 am
Location: United States

Post by phosphoer » Wed Oct 02, 2013 3:35 am

I ended up solving my problem like this:

Image

(messy) code:
http://pastebin.com/xYn6Gfjb

I used the parented text objects just to classify the "type" of shape that is being exported, which is specific to my own needs.
[/url]

gesky

Post by gesky » Wed Oct 16, 2013 5:26 pm

I do consider all the ideas you have introduced for your post. They’re very convincing and will certainly work.

Thanks for this post!

Post Reply