Commit d79c8ff2 authored by Guillaume Seguin's avatar Guillaume Seguin

Rotate objects around their center in plater

parent 65fc1711
...@@ -308,18 +308,25 @@ class StlPlater(Plater): ...@@ -308,18 +308,25 @@ class StlPlater(Plater):
def export_to(self, name): def export_to(self, name):
sf = open(name.replace(".", "_") + ".scad", "w") sf = open(name.replace(".", "_") + ".scad", "w")
facets = [] facets = []
for i in self.models.values(): for model in self.models.values():
r = i.rot r = model.rot
rot = [0, 0, r] if r else None rot = [0, 0, r] if r else None
o = i.offsets o = model.offsets
co = i.centeroffset co = model.centeroffset
trans = [o[0] + co[0], o[1] + co[1], o[2] + co[2]] if any(o) or any(co) else [0, 0, 0] sf.write("translate([%s, %s, %s])"
sf.write('translate([%s, %s, %s]) rotate([0, 0, %s]) import_stl("%s");\n' % (trans[0], trans[1], trans[2], r, os.path.split(i.filename)[1])) "rotate([0, 0, %s])"
"translate([%s, %s, %s])"
"import(\"%s\");\n" % (co[0], co[1], co[2],
r,
o[0], o[1], o[2],
model.filename))
if any(co):
model = model.translate(co)
if rot: if rot:
i = i.rotate(rot) model = model.rotate(rot)
if trans: if any(o):
i = i.translate(trans) model = model.translate(o)
facets += i.facets facets += model.facets
sf.close() sf.close()
stltool.emitstl(name, facets, "plater_export") stltool.emitstl(name, facets, "plater_export")
print _("Wrote plate to %s") % name print _("Wrote plate to %s") % name
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
import wx import wx
import time import time
import threading
import pyglet import pyglet
pyglet.options['debug_gl'] = True pyglet.options['debug_gl'] = True
...@@ -358,8 +357,8 @@ class StlViewPanel(wxGLPanel): ...@@ -358,8 +357,8 @@ class StlViewPanel(wxGLPanel):
model = self.parent.models[i] model = self.parent.models[i]
glPushMatrix() glPushMatrix()
glTranslatef(*(model.offsets)) glTranslatef(*(model.offsets))
glTranslatef(*(model.centeroffset))
glRotatef(model.rot, 0.0, 0.0, 1.0) glRotatef(model.rot, 0.0, 0.0, 1.0)
glTranslatef(*(model.centeroffset))
glScalef(*model.scale) glScalef(*model.scale)
model.batch.draw() model.batch.draw()
glPopMatrix() glPopMatrix()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment