X-Git-Url: https://git.ao2.it/vrm.git/blobdiff_plain/b68056f960f3135bfa0d7e6327d06bf412b420cf..08e34a873729c718a510ec642d36eebaef6f4ee7:/vrm.py diff --git a/vrm.py b/vrm.py index 00c8ed4..d85b085 100755 --- a/vrm.py +++ b/vrm.py @@ -34,7 +34,7 @@ Tooltip: 'Vector Rendering Method Export Script 0.3' # # Additional credits: # Thanks to Emilio Aguirre for S2flender from which I took inspirations :) -# Thanks to Anthony C. D'Agostino for the backface.py script +# Thanks to Anthony C. D'Agostino for the original backface.py script # # --------------------------------------------------------------------- @@ -179,7 +179,7 @@ class Projector: # --------------------------------------------------------------------- # -## Mesh representation class +## Object representation class # # --------------------------------------------------------------------- @@ -264,6 +264,8 @@ class SVGVectorWriter(VectorWriter): for face in obj.getData().faces: self._printPolygon(face) + self._printWireframe(obj.getData()) + self.file.write("\n") self._printFooter() @@ -276,7 +278,9 @@ class SVGVectorWriter(VectorWriter): """Print SVG header.""" self.file.write("\n") - self.file.write("\n") + self.file.write("\n\n" % self.canvasSize) @@ -287,6 +291,31 @@ class SVGVectorWriter(VectorWriter): self.file.write("\n\n") self.file.close() + def _printWireframe(self, mesh): + """Print the wireframe using mesh edges... is this the correct way? + """ + + print mesh.edges + print + print mesh.verts + + stroke_width=0.5 + stroke_col = [0, 0, 0] + + self.file.write("\n") + + for e in mesh.edges: + self.file.write("\n") + + self.file.write("\n") + + + def _printPolygon(self, face): """Print our primitive, finally. """ @@ -407,6 +436,13 @@ class Renderer: transformed_mesh = NMesh.New("flat"+obj.name) transformed_mesh.hasVertexColours(1) + # process Edges + for v in obj.getData().verts: + transformed_mesh.verts.append(v) + transformed_mesh.edges = self._processEdges(obj.getData().edges) + print transformed_mesh.edges + + # Store the materials materials = obj.getData().getMaterials() @@ -558,9 +594,29 @@ class Renderer: return (d<0) - def _doClipping(face): + + def _doClipping(): + return + + + # Per object methods + + def _doVisibleSurfaceDetermination(object): + return + + def _doColorizing(object): return + def _doStylizingEdges(self, object, style): + """Process Mesh Edges. (For now copy the edge data, in next version it + can be a place where recognize silouhettes and/or contours). + + input: an edge list + return: a processed edge list + """ + return + + # --------------------------------------------------------------------- # @@ -605,12 +661,22 @@ def depthSorting(scene): scene.link(o) def vectorize(filename): + """The vectorizing process is as follows: + + - Open the writer + - Render the scene + - Close the writer + + If you want to render an animation the second pass should be + repeated for any frame, and the frame number should be passed to the + renderer. + """ print "Filename: %s" % filename scene = Scene.GetCurrent() renderer = Renderer() - + flatScene = renderer.doRendering(scene) canvasSize = renderer.getCanvasSize() @@ -624,6 +690,7 @@ def vectorize(filename): # Here the main if __name__ == "__main__": + # with this trick we can run the script in batch mode try: Blender.Window.FileSelector (vectorize, 'Save SVG', "proba.svg") except: