summaryrefslogtreecommitdiff
path: root/polyset.cc
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-06-26 23:36:23 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-06-26 23:36:23 (GMT)
commit9479f8e77ba5af4778b1efe417f6c4452811d459 (patch)
treedfbc63a91e60f3e597cfb78f76865b05855da23c /polyset.cc
parent221ae1832702367047232bd0f12970f0422a0478 (diff)
Clifford Wolf:
Transforms (scale, rotate, translate, multmatrix) Various matrix related fixes git-svn-id: http://svn.clifford.at/openscad/trunk@29 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'polyset.cc')
-rw-r--r--polyset.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/polyset.cc b/polyset.cc
index 23c890c..f811fa3 100644
--- a/polyset.cc
+++ b/polyset.cc
@@ -24,6 +24,8 @@
PolySet::PolySet()
{
+ for (int i = 0; i < 16; i++)
+ m[i] = i % 5 == 0 ? 1.0 : 0.0;
}
void PolySet::append_poly()
@@ -41,6 +43,12 @@ void PolySet::insert_vertex(double x, double y, double z)
polygons.last().insert(0, Point(x, y, z));
}
+void PolySet::setmatrix(double m[16])
+{
+ for (int i = 0; i < 16; i++)
+ this->m[i] = m[i];
+}
+
static void gl_draw_triangle(GLint *shaderinfo, const PolySet::Point *p0, const PolySet::Point *p1, const PolySet::Point *p2, bool e0, bool e1, bool e2)
{
#ifdef ENABLE_OPENCSG
@@ -75,6 +83,8 @@ static void gl_draw_triangle(GLint *shaderinfo, const PolySet::Point *p0, const
void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const
{
+ glPushMatrix();
+ glMultMatrixd(m);
if (colormode == COLOR_MATERIAL) {
glColor3ub(249, 215, 44);
#ifdef ENABLE_OPENCSG
@@ -125,10 +135,13 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const
}
glEnd();
}
+ glPopMatrix();
}
void PolySet::render_edges(colormode_e colormode) const
{
+ glPushMatrix();
+ glMultMatrixd(m);
if (colormode == COLOR_MATERIAL)
glColor3ub(255, 236, 94);
if (colormode == COLOR_CUTOUT)
@@ -142,6 +155,7 @@ void PolySet::render_edges(colormode_e colormode) const
}
glEnd();
}
+ glPopMatrix();
}
#ifdef ENABLE_CGAL
@@ -235,6 +249,7 @@ CGAL_Nef_polyhedron AbstractPolyNode::render_cgal_nef_polyhedron() const
CSGTerm *AbstractPolyNode::render_csg_term(double m[16]) const
{
PolySet *ps = render_polyset(RENDER_OPENCSG);
- return new CSGTerm(ps, QString("n%1").arg(idx), m);
+ ps->setmatrix(m);
+ return new CSGTerm(ps, QString("n%1").arg(idx));
}
contact: Jan Huwald // Impressum