From 5e7b03f009e63a376892ea0f870fd428205fd44f Mon Sep 17 00:00:00 2001 From: David Date: Sat, 28 Nov 2026 13:49:03 +0100 Subject: [PATCH] Vismach: Fix axes colors in class HalCoordsFromNormalAndDirection() The Z axis indicator should be blue but gets the previous color applied in the model. This is caused by glMaterialfv() being called AFTER gluCylinder() inside draw_vector(). This moves glMaterialfv() BEFORE gluCylinder() and fixes the axes colors and wraps the three draw_vector calls with glPushAttrib(GL_LIGHTING_BIT) and glPopAttrib() to avoid leaking into other primitives. --- lib/python/vismach.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/python/vismach.py b/lib/python/vismach.py index 95648aefab6..096db72c89d 100644 --- a/lib/python/vismach.py +++ b/lib/python/vismach.py @@ -480,8 +480,8 @@ def __init__(self, comp, ox, oy, oz, xx, xy, xz, zx, zy, zz, stretch, r=5): def draw_vector(self, color): - gluCylinder(self.q, self.r, self.r, 50*self.stretch, 32, 1) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color) + gluCylinder(self.q, self.r, self.r, 50*self.stretch, 32, 1) def cross(self, a, b): return [a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]] @@ -511,11 +511,13 @@ def draw(self): glPushMatrix() glMultMatrixf(m_t) - self.draw_vector([1,0,0,1]) + glPushAttrib(GL_LIGHTING_BIT) + self.draw_vector([0,0,1,1]) # Z axis glRotate(90,0,1,0) - self.draw_vector([0,1,0,1]) + self.draw_vector([1,0,0,1]) # X axis glRotate(-90,1,0,0) - self.draw_vector([0,0,1,1]) + self.draw_vector([0,1,0,1]) # Y axis + glPopAttrib() def unapply(self): glPopMatrix()