Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/python/vismach.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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
Comment on lines +515 to +519

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this save and restore the material, like Color does? As it is, the last arrow colour (now green, before this PR blue) carries over to any sibling drawn after it without a Color wrapper.

Suggested change
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
glPushAttrib(GL_LIGHTING_BIT)
self.draw_vector([0,0,1,1]) # Z axis
glRotate(90,0,1,0)
self.draw_vector([1,0,0,1]) # X axis
glRotate(-90,1,0,0)
self.draw_vector([0,1,0,1]) # Y axis
glPopAttrib()

glPopAttrib()

def unapply(self):
glPopMatrix()
Expand Down
Loading