Esempio n. 1
0
 def renderizarTexto(self,
                     x,
                     y,
                     text,
                     z=0,
                     tamanho=0.002,
                     color={
                         'r': 1,
                         'g': 1,
                         'b': 1
                     }):
     gl.glPushMatrix()
     gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT,
                     [color['r'], color['g'], color['b'], 1.0])
     gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE,
                     [color['r'], color['g'], color['b'], 1.0])
     gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR,
                     [color['r'], color['g'], color['b'], 1.0])
     gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, 100.0)
     gl.glTranslatef(x, y, z)
     gl.glScalef(tamanho, tamanho, tamanho)
     for ch in text:
         glut.glutStrokeCharacter(glut.GLUT_STROKE_MONO_ROMAN,
                                  glut.ctypes.c_int(ord(ch)))
     gl.glPopMatrix()
 def label(x, y, s):
     'takes string input and outputs it to OpenGl Environment'
     GL.glPushMatrix()
     GL.glTranslatef(x, y, 0.0)
     GL.glScalef(0.1, 0.1, 0.1)
     for c in s:
         GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(c))
         GL.glTranslatef(20, 0.0, 0.0)
     GL.glPopMatrix()
Esempio n. 3
0
	def paint(self):
		glMatrixMode(GL_MODELVIEW)
		glPushMatrix()
		glTranslatef(self.__x, self.__y, 0)
		glScale(self.__s, self.__s, self.__s)
		
		for i in range(0, len(self.__text)):
			GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_MONO_ROMAN, ord(self.__text[i]))
		
		glPopMatrix()
Esempio n. 4
0
    def paint(self, paintHidden=False):
        if self.getVisibility() or paintHidden:
            glMatrixMode(GL_MODELVIEW)
            glPushMatrix()
            glTranslatef(self.__x, self.__y, 0)

            for i in range(0, len(self.__text)):
                GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_MONO_ROMAN,
                                         ord(self.__text[i]))

            glPopMatrix()
Esempio n. 5
0
def drawWord(pos, string, color, size=1):
   #print pos,string,color
   #print string
   GL.glDisable(GL.GL_TEXTURE_2D)
   GL.glLineWidth(1.5)
   r, g, b = color
   GL.glPushMatrix()
   GL.glColor4f(r, g, b, .5)
   GL.glTranslatef(*pos)
   s = size*0.001
   GL.glScalef(s, -s, s)
   for char in string:
      GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(char))
   GL.glPopMatrix()
   GL.glEnable(GL.GL_TEXTURE_2D)
Esempio n. 6
0
def draw_string(x, y, z, p, s, scale=0.01):
    GL.glPushMatrix()
    GL.glTranslatef(x, y, z)
    if p == "xy":
        GL.glRotatef(90, 1, 0, 0)
    elif p == "yz":
        GL.glRotatef(90, 0, 1, 0)
        GL.glRotatef(90, 0, 0, 1)
    elif p == "xz":
        GL.glRotatef(90, 0, 1, 0)
        GL.glRotatef(90, 0, 0, 1)
        GL.glRotatef(45, 0, 1, 0)
    GL.glScalef(scale, scale, scale)
    for c in str(s):
        GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(c))
    GL.glPopMatrix()
Esempio n. 7
0
def draw_string(x, y, z, p, s, scale=.01):
    GL.glPushMatrix()
    GL.glTranslatef(x, y, z)
    if p == 'xy':
        GL.glRotatef(90, 1, 0, 0)
    elif p == 'yz':
        GL.glRotatef(90, 0, 1, 0)
        GL.glRotatef(90, 0, 0, 1)
    elif p == 'xz':
        GL.glRotatef(90, 0, 1, 0)
        GL.glRotatef(90, 0, 0, 1)
        GL.glRotatef(45, 0, 1, 0)
    GL.glScalef(scale, scale, scale)
    for c in str(s):
        GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(c))
    GL.glPopMatrix()
def glText(s, space=80):
    'takes string input and outputs it to OpenGl Environment'
    for c in s:
        GL.glPushMatrix()
        if c == "1":
            GL.glTranslatef(16.0, 0.0, 0.0)
        elif c == "I":
            GL.glTranslatef(30.0, 0.0, 0.0)
        elif c == "(":
            GL.glTranslatef(25.0, 0.0, 0.0)
        if c == ".":
            s = 35
        else:
            s = space
        GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(c))
        GL.glPopMatrix()
        GL.glTranslatef(s, 0.0, 0.0)
Esempio n. 9
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],
                               self.parameters.lowerleft[1], 0.0)
                gl.glRotate(self.parameters.orientation, 0.0, 0.0, 1.0)

                c = self.parameters.color
                if len(c) == 3:
                    gl.glColor3f(*c)
                elif len(c) == 4:
                    gl.glColor4f(*c)

                gl.glLineWidth(self.parameters.linewidth)

                if self.parameters.anti_aliasing:
                    gl.glEnable(gl.GL_BLEND)
                    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
                    gl.glEnable(gl.GL_LINE_SMOOTH)
                else:
                    gl.glDisable(gl.GL_BLEND)

    ##            # This code successfully draws a box...
    ##            gl.glBegin(gl.GL_QUADS)
    ##            gl.glVertex2f(0.0,0.0)
    ##            gl.glVertex2f(0.0,0.1)
    ##            gl.glVertex2f(0.1,0.1)
    ##            gl.glVertex2f(0.1,0.0)
    ##            gl.glEnd()

    # But this code does not draw the string!?!
                for char in self.parameters.text:
                    glut.glutStrokeCharacter(self.parameters.font, ord(char))
                gl.glPopMatrix()
Esempio n. 10
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],self.parameters.lowerleft[1],0.0)
                gl.glRotate(self.parameters.orientation,0.0,0.0,1.0)

                c = self.parameters.color
                if len(c)==3:
                    gl.glColor3f(*c)
                elif len(c)==4:
                    gl.glColor4f(*c)

                gl.glLineWidth(self.parameters.linewidth)

                if self.parameters.anti_aliasing:
                    gl.glEnable(gl.GL_BLEND)
                    gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA)
                    gl.glEnable(gl.GL_LINE_SMOOTH)
                else:
                    gl.glDisable(gl.GL_BLEND)

    ##            # This code successfully draws a box...
    ##            gl.glBegin(gl.GL_QUADS)
    ##            gl.glVertex2f(0.0,0.0)
    ##            gl.glVertex2f(0.0,0.1)
    ##            gl.glVertex2f(0.1,0.1)
    ##            gl.glVertex2f(0.1,0.0)
    ##            gl.glEnd()

                # But this code does not draw the string!?!
                for char in self.parameters.text:
                    glut.glutStrokeCharacter(self.parameters.font,ord(char))
                gl.glPopMatrix()
Esempio n. 11
0
 def to_opengl(self, color=None, show_directions=False):
     if not GL_enabled:
         return
     if color is not None:
         GL.glColor4f(*color)
     GL.glBegin(GL.GL_TRIANGLES)
     # use normals to improve lighting (contributed by imyrek)
     normal_t = self.normal
     GL.glNormal3f(normal_t[0], normal_t[1], normal_t[2])
     # The triangle's points are in clockwise order, but GL expects
     # counter-clockwise sorting.
     GL.glVertex3f(self.p1[0], self.p1[1], self.p1[2])
     GL.glVertex3f(self.p3[0], self.p3[1], self.p3[2])
     GL.glVertex3f(self.p2[0], self.p2[1], self.p2[2])
     GL.glEnd()
     if show_directions:
         # display surface normals
         n = self.normal
         c = self.center
         d = 0.5
         GL.glBegin(GL.GL_LINES)
         GL.glVertex3f(c[0], c[1], c[2])
         GL.glVertex3f(c[0] + n[0] * d, c[1] + n[1] * d, c[2] + n[2] * d)
         GL.glEnd()
     if False:
         # display bounding sphere
         GL.glPushMatrix()
         middle = self.middle
         GL.glTranslate(middle[0], middle[1], middle[2])
         if not hasattr(self, "_sphere"):
             self._sphere = GLU.gluNewQuadric()
         GLU.gluSphere(self._sphere, self.radius, 10, 10)
         GL.glPopMatrix()
     if pycam.Utils.log.is_debug():
         # draw triangle id on triangle face
         GL.glPushMatrix()
         c = self.center
         GL.glTranslate(c[0], c[1], c[2])
         p12 = pmul(padd(self.p1, self.p2), 0.5)
         p3_12 = pnormalized(psub(self.p3, p12))
         p2_1 = pnormalized(psub(self.p1, self.p2))
         pn = pcross(p2_1, p3_12)
         GL.glMultMatrixf((p2_1[0], p2_1[1], p2_1[2], 0, p3_12[0], p3_12[1],
                           p3_12[2], 0, pn[0], pn[1], pn[2], 0, 0, 0, 0, 1))
         n = pmul(self.normal, 0.01)
         GL.glTranslatef(n[0], n[1], n[2])
         maxdim = max((self.maxx - self.minx), (self.maxy - self.miny),
                      (self.maxz - self.minz))
         factor = 0.001
         GL.glScalef(factor * maxdim, factor * maxdim, factor * maxdim)
         w = 0
         id_string = "%s." % str(self.id)
         for ch in id_string:
             w += GLUT.glutStrokeWidth(GLUT_STROKE_ROMAN, ord(ch))
         GL.glTranslate(-w / 2, 0, 0)
         for ch in id_string:
             GLUT.glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(ch))
         GL.glPopMatrix()
     if False:
         # draw point id on triangle face
         c = self.center
         p12 = pmul(padd(self.p1, self.p2), 0.5)
         p3_12 = pnormalized(psub(self.p3, p12))
         p2_1 = pnormalized(psub(self.p1, self.p2))
         pn = pcross(p2_1, p3_12)
         n = pmul(self.normal, 0.01)
         for p in (self.p1, self.p2, self.p3):
             GL.glPushMatrix()
             pp = psub(p, pmul(psub(p, c), 0.3))
             GL.glTranslate(pp[0], pp[1], pp[2])
             GL.glMultMatrixf(
                 (p2_1[0], p2_1[1], p2_1[2], 0, p3_12[0], p3_12[1],
                  p3_12[2], 0, pn[0], pn[1], pn[2], 0, 0, 0, 0, 1))
             GL.glTranslatef(n[0], n[1], n[2])
             GL.glScalef(0.001, 0.001, 0.001)
             w = 0
             for ch in str(p.id):
                 w += GLUT.glutStrokeWidth(GLUT_STROKE_ROMAN, ord(ch))
                 GL.glTranslate(-w / 2, 0, 0)
             for ch in str(p.id):
                 GLUT.glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(ch))
             GL.glPopMatrix()
Esempio n. 12
0
def text2D(text,
           pos,
           fontSize,
           displaySize,
           angle=None,
           fixedWidth=False,
           calcSize=False):
    """Renders a 2D string using ``glutStrokeCharacter``.

    :arg text:        The text to render. Only ASCII characters 32-127 (and
                      newlines) are supported.

    :arg pos:         2D text position in pixels.

    :arg fontSize:    Font size in pixels

    :arg displaySize: ``(width, height)`` of the canvas in pixels.

    :arg angle:       Angle (in degrees) by which to rotate the text.

    :arg fixedWidth:  If ``True``, a fixed-width font is used. Otherwise a
                      variable-width font is used.

    :arg calcSize:    If ``True``, the text is not rendered. Instead, the
                      size of the text, in pixels, is calculated and returned
                      (before any rotation by the ``angle``).
    """

    if fixedWidth: font = glut.GLUT_STROKE_MONO_ROMAN
    else: font = glut.GLUT_STROKE_ROMAN

    pos = list(pos)
    width, height = displaySize

    # The glut characters have a default
    # height (in display coordinates) of
    # 152.38. Scale this to the requested
    # pixel font size.
    scale = fontSize / 152.38

    # Get the current matrix mode,
    # and restore it when we're done
    mm = gl.glGetInteger(gl.GL_MATRIX_MODE)

    # Set up an ortho view where the
    # display coordinates correspond
    # to the canvas pixel coordinates.
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glPushMatrix()
    gl.glLoadIdentity()
    gl.glOrtho(0, width, 0, height, -1, 1)

    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glPushMatrix()
    gl.glLoadIdentity()

    gl.glEnable(gl.GL_LINE_SMOOTH)

    # Draw each line one at a time
    width = 0
    height = 0
    lines = text.split('\n')

    for i, line in enumerate(lines):

        height += scale * 152.38
        pos[1] -= scale * 152.38 * i

        gl.glPushMatrix()
        gl.glTranslatef(pos[0], pos[1], 0)
        gl.glScalef(scale, scale, scale)

        lineWidth = 0
        for char in line:

            # We either calculate the
            # character size, or draw
            # the character, but not
            # both
            if calcSize:
                charWidth = glut.glutStrokeWidth(font, ord(char))
                lineWidth += charWidth * (fontSize / 152.38)

            else:
                glut.glutStrokeCharacter(font, ord(char))

        if lineWidth > width:
            width = lineWidth

        gl.glPopMatrix()

    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.glPopMatrix()

    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glPopMatrix()

    gl.glMatrixMode(mm)

    if calcSize: return width, height
    else: return 0, 0
Esempio n. 13
0
 def to_OpenGL(self, color=None, show_directions=False):
     if not GL_enabled:
         return
     if not color is None:
         GL.glColor4f(*color)
     GL.glBegin(GL.GL_TRIANGLES)
     # use normals to improve lighting (contributed by imyrek)
     normal_t = self.normal
     GL.glNormal3f(normal_t.x, normal_t.y, normal_t.z)
     # The triangle's points are in clockwise order, but GL expects
     # counter-clockwise sorting.
     GL.glVertex3f(self.p1.x, self.p1.y, self.p1.z)
     GL.glVertex3f(self.p3.x, self.p3.y, self.p3.z)
     GL.glVertex3f(self.p2.x, self.p2.y, self.p2.z)
     GL.glEnd()
     if show_directions:  # display surface normals
         n = self.normal
         c = self.center
         d = 0.5
         GL.glBegin(GL.GL_LINES)
         GL.glVertex3f(c.x, c.y, c.z)
         GL.glVertex3f(c.x + n.x * d, c.y + n.y * d, c.z + n.z * d)
         GL.glEnd()
     if False:  # display bounding sphere
         GL.glPushMatrix()
         middle = self.middle
         GL.glTranslate(middle.x, middle.y, middle.z)
         if not hasattr(self, "_sphere"):
             self._sphere = GLU.gluNewQuadric()
         GLU.gluSphere(self._sphere, self.radius, 10, 10)
         GL.glPopMatrix()
     if pycam.Utils.log.is_debug():  # draw triangle id on triangle face
         GL.glPushMatrix()
         c = self.center
         GL.glTranslate(c.x, c.y, c.z)
         p12 = self.p1.add(self.p2).mul(0.5)
         p3_12 = self.p3.sub(p12).normalized()
         p2_1 = self.p1.sub(self.p2).normalized()
         pn = p2_1.cross(p3_12)
         GL.glMultMatrixf((p2_1.x, p2_1.y, p2_1.z, 0, p3_12.x, p3_12.y,
                           p3_12.z, 0, pn.x, pn.y, pn.z, 0, 0, 0, 0, 1))
         n = self.normal.mul(0.01)
         GL.glTranslatef(n.x, n.y, n.z)
         maxdim = max((self.maxx - self.minx), (self.maxy - self.miny),
                      (self.maxz - self.minz))
         factor = 0.001
         GL.glScalef(factor * maxdim, factor * maxdim, factor * maxdim)
         w = 0
         id_string = "%s." % str(self.id)
         for ch in id_string:
             w += GLUT.glutStrokeWidth(GLUT.GLUT_STROKE_ROMAN, ord(ch))
         GL.glTranslate(-w / 2, 0, 0)
         for ch in id_string:
             GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(ch))
         GL.glPopMatrix()
     if False:  # draw point id on triangle face
         c = self.center
         p12 = self.p1.add(self.p2).mul(0.5)
         p3_12 = self.p3.sub(p12).normalized()
         p2_1 = self.p1.sub(self.p2).normalized()
         pn = p2_1.cross(p3_12)
         n = self.normal.mul(0.01)
         for p in (self.p1, self.p2, self.p3):
             GL.glPushMatrix()
             pp = p.sub(p.sub(c).mul(0.3))
             GL.glTranslate(pp.x, pp.y, pp.z)
             GL.glMultMatrixf((p2_1.x, p2_1.y, p2_1.z, 0, p3_12.x, p3_12.y,
                               p3_12.z, 0, pn.x, pn.y, pn.z, 0, 0, 0, 0, 1))
             GL.glTranslatef(n.x, n.y, n.z)
             GL.glScalef(0.001, 0.001, 0.001)
             w = 0
             for ch in str(p.id):
                 w += GLUT.glutStrokeWidth(GLUT.GLUT_STROKE_ROMAN, ord(ch))
                 GL.glTranslate(-w / 2, 0, 0)
             for ch in str(p.id):
                 GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(ch))
             GL.glPopMatrix()
Esempio n. 14
0
 def to_OpenGL(self, color=None, show_directions=False):
     if not GL_enabled:
         return
     if not color is None:
         GL.glColor4f(*color)
     GL.glBegin(GL.GL_TRIANGLES)
     # use normals to improve lighting (contributed by imyrek)
     normal_t = self.normal
     GL.glNormal3f(normal_t.x, normal_t.y, normal_t.z)
     # The triangle's points are in clockwise order, but GL expects
     # counter-clockwise sorting.
     GL.glVertex3f(self.p1.x, self.p1.y, self.p1.z)
     GL.glVertex3f(self.p3.x, self.p3.y, self.p3.z)
     GL.glVertex3f(self.p2.x, self.p2.y, self.p2.z)
     GL.glEnd()
     if show_directions: # display surface normals
         n = self.normal
         c = self.center
         d = 0.5
         GL.glBegin(GL.GL_LINES)
         GL.glVertex3f(c.x, c.y, c.z)
         GL.glVertex3f(c.x+n.x*d, c.y+n.y*d, c.z+n.z*d)
         GL.glEnd()
     if False: # display bounding sphere
         GL.glPushMatrix()
         middle = self.middle
         GL.glTranslate(middle.x, middle.y, middle.z)
         if not hasattr(self, "_sphere"):
             self._sphere = GLU.gluNewQuadric()
         GLU.gluSphere(self._sphere, self.radius, 10, 10)
         GL.glPopMatrix()
     if pycam.Utils.log.is_debug(): # draw triangle id on triangle face
         GL.glPushMatrix()
         c = self.center
         GL.glTranslate(c.x, c.y, c.z)
         p12 = self.p1.add(self.p2).mul(0.5)
         p3_12 = self.p3.sub(p12).normalized()
         p2_1 = self.p1.sub(self.p2).normalized()
         pn = p2_1.cross(p3_12)
         GL.glMultMatrixf((p2_1.x, p2_1.y, p2_1.z, 0, p3_12.x, p3_12.y,
                 p3_12.z, 0, pn.x, pn.y, pn.z, 0, 0, 0, 0, 1))
         n = self.normal.mul(0.01)
         GL.glTranslatef(n.x, n.y, n.z)
         maxdim = max((self.maxx - self.minx), (self.maxy - self.miny),
                 (self.maxz - self.minz))
         factor = 0.001
         GL.glScalef(factor * maxdim, factor * maxdim, factor * maxdim)
         w = 0
         id_string = "%s." % str(self.id)
         for ch in id_string:
             w += GLUT.glutStrokeWidth(GLUT.GLUT_STROKE_ROMAN, ord(ch))
         GL.glTranslate(-w/2, 0, 0)
         for ch in id_string:
             GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(ch))
         GL.glPopMatrix()
     if False: # draw point id on triangle face
         c = self.center
         p12 = self.p1.add(self.p2).mul(0.5)
         p3_12 = self.p3.sub(p12).normalized()
         p2_1 = self.p1.sub(self.p2).normalized()
         pn = p2_1.cross(p3_12)
         n = self.normal.mul(0.01)
         for p in (self.p1, self.p2, self.p3):
             GL.glPushMatrix()
             pp = p.sub(p.sub(c).mul(0.3))
             GL.glTranslate(pp.x, pp.y, pp.z)
             GL.glMultMatrixf((p2_1.x, p2_1.y, p2_1.z, 0, p3_12.x, p3_12.y,
                     p3_12.z, 0, pn.x, pn.y, pn.z, 0, 0, 0, 0, 1))
             GL.glTranslatef(n.x, n.y, n.z)
             GL.glScalef(0.001, 0.001, 0.001)
             w = 0
             for ch in str(p.id):
                 w += GLUT.glutStrokeWidth(GLUT.GLUT_STROKE_ROMAN, ord(ch))
                 GL.glTranslate(-w/2, 0, 0)
             for ch in str(p.id):
                 GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(ch))
             GL.glPopMatrix()
Esempio n. 15
0
 def to_OpenGL(self, color=None, show_directions=False):
     if not GL_enabled:
         return
     if not color is None:
         GL.glColor4f(*color)
     GL.glBegin(GL.GL_TRIANGLES)
     # use normals to improve lighting (contributed by imyrek)
     normal_t = self.normal
     GL.glNormal3f(normal_t[0], normal_t[1], normal_t[2])
     # The triangle's points are in clockwise order, but GL expects
     # counter-clockwise sorting.
     GL.glVertex3f(self.p1[0], self.p1[1], self.p1[2])
     GL.glVertex3f(self.p3[0], self.p3[1], self.p3[2])
     GL.glVertex3f(self.p2[0], self.p2[1], self.p2[2])
     GL.glEnd()
     if show_directions: # display surface normals
         n = self.normal
         c = self.center
         d = 0.5
         GL.glBegin(GL.GL_LINES)
         GL.glVertex3f(c[0], c[1], c[2])
         GL.glVertex3f(c[0]+n[0]*d, c[1]+n[1]*d, c[2]+n[2]*d)
         GL.glEnd()
     if False: # display bounding sphere
         GL.glPushMatrix()
         middle = self.middle
         GL.glTranslate(middle[0], middle[1], middle[2])
         if not hasattr(self, "_sphere"):
             self._sphere = GLU.gluNewQuadric()
         GLU.gluSphere(self._sphere, self.radius, 10, 10)
         GL.glPopMatrix()
     if pycam.Utils.log.is_debug(): # draw triangle id on triangle face
         GL.glPushMatrix()
         c = self.center
         GL.glTranslate(c[0], c[1], c[2])
         p12 = pmul(padd(self.p1, self.p2), 0.5)
         p3_12 = pnormalized(psub(self.p3, p12))
         p2_1 = pnormalized(psub(self.p1, self.p2))
         pn = pcross(p2_1, p3_12)
         GL.glMultMatrixf((p2_1[0], p2_1[1], p2_1[2], 0, p3_12[0], p3_12[1],
                 p3_12[2], 0, pn[0], pn[1], pn[2], 0, 0, 0, 0, 1))
         n = pmul(self.normal, 0.01)
         GL.glTranslatef(n[0], n[1], n[2])
         maxdim = max((self.maxx - self.minx), (self.maxy - self.miny),
                 (self.maxz - self.minz))
         factor = 0.001
         GL.glScalef(factor * maxdim, factor * maxdim, factor * maxdim)
         w = 0
         id_string = "%s." % str(self.id)
         for ch in id_string:
             w += GLUT.glutStrokeWidth(GLUT.GLUT_STROKE_ROMAN, ord(ch))
         GL.glTranslate(-w/2, 0, 0)
         for ch in id_string:
             GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(ch))
         GL.glPopMatrix()
     if False: # draw point id on triangle face
         c = self.center
         p12 = pmul(padd(self.p1, self.p2), 0.5)
         p3_12 = pnormalized(psub(self.p3, p12))
         p2_1 = pnormalized(psub(self.p1, self.p2))
         pn = pcross(p2_1, p3_12)
         n = pmul(self.normal, 0.01)
         for p in (self.p1, self.p2, self.p3):
             GL.glPushMatrix()
             pp = psub(p, pmul(psub(p, c), 0.3))
             GL.glTranslate(pp[0], pp[1], pp[2])
             GL.glMultMatrixf((p2_1[0], p2_1[1], p2_1[2], 0, p3_12[0], p3_12[1],
                     p3_12[2], 0, pn[0], pn[1], pn[2], 0, 0, 0, 0, 1))
             GL.glTranslatef(n[0], n[1], n[2])
             GL.glScalef(0.001, 0.001, 0.001)
             w = 0
             for ch in str(p.id):
                 w += GLUT.glutStrokeWidth(GLUT.GLUT_STROKE_ROMAN, ord(ch))
                 GL.glTranslate(-w/2, 0, 0)
             for ch in str(p.id):
                 GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(ch))
             GL.glPopMatrix()