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

Class TransformPrim

mscreen.py:399–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397
398# === Transformation Matrix Primitive ===
399class TransformPrim(Primitive):
400 X_COLOR = COLOR_RED
401 Y_COLOR = COLOR_GREEN
402 Z_COLOR = COLOR_BLUE
403
404 def __init__(self, transform=None, size=1.0):
405 super(TransformPrim, self).__init__(transform)
406 # Notice how 3 vectors can be used to compose the matrix (depending on
407 # your use case, composition can provide a more convenient/clean way to
408 # extend classes than inheritance).
409 self._xAxis = VectorPrim((1, 0, 0), color=TransformPrim.X_COLOR)
410 self._yAxis = VectorPrim((0, 1, 0), color=TransformPrim.Y_COLOR)
411 self._zAxis = VectorPrim((0, 0, 1), color=TransformPrim.Z_COLOR)
412 self.size = size
413
414 @property
415 def size(self):
416 return self._size
417
418 @size.setter
419 def size(self, value):
420 self._size = value
421 self.isDirty = True
422
423 def update(self):
424 super(TransformPrim, self).update()
425 for each in (self._xAxis, self._yAxis, self._zAxis):
426 if each.size != self.size:
427 each.size = self.size
428 if each.transform != self.transform:
429 each.transform = self.transform
430
431 def draw(self, view, renderer):
432 super(TransformPrim, self).draw(view, renderer)
433 for each in (self._xAxis, self._yAxis, self._zAxis):
434 each.draw(view, renderer)
435
436
437# === Point Primitive ===

Callers 1

drawTransformMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected