MCPcopy Create free account
hub / github.com/csaez/mscreen / PointPrim

Class PointPrim

mscreen.py:438–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436
437# === Point Primitive ===
438class PointPrim(Primitive):
439
440 def __init__(self, position=None, color=None, size=2):
441 super(PointPrim, self).__init__()
442
443 position = om2.MVector() if position is None else om2.MVector(position)
444 self.transform.setTranslation(position, om2.MSpace.kWorld)
445 # `color` as a tuple of floats representing RGB values (normalized).
446 self.color = color or COLOR_BLACK
447 self.size = size
448
449 # `size` in pixels.
450 @property
451 def size(self):
452 return self._size
453
454 @size.setter
455 def size(self, value):
456 self._size = max(int(value), 1)
457
458 def draw(self, view, renderer):
459 super(PointPrim, self).draw(view, renderer)
460
461 view.beginGL()
462 glFT = renderer.glFunctionTable()
463 glFT.glPushAttrib(omr.MGL_POINT_BIT)
464 glFT.glPointSize(self.size)
465 glFT.glBegin(omr.MGL_POINTS)
466
467 r, g, b = [float(x) for x in self.color]
468 glFT.glColor3f(r, g, b)
469
470 point = self.transform.translation(om2.MSpace.kWorld)
471 glFT.glVertex3f(point.x, point.y, point.z)
472
473 glFT.glEnd()
474 glFT.glPopAttrib()
475 view.endGL()
476
477
478# === Triangle Primitive ===

Callers 1

drawPointMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected