| 342 | `CurvePrim` draw an arrow representing a vector in 3D space. |
| 343 | """ |
| 344 | def __init__(self, vector, size=1.0, color=None): |
| 345 | super(VectorPrim, self).__init__() |
| 346 | self._size = size |
| 347 | self.color = color or COLOR_BLACK |
| 348 | |
| 349 | # body line |
| 350 | _points = ((0, 0, 0), vector) |
| 351 | self.body = CurvePrim(_points, color=self.color) |
| 352 | self.body.scale(self.size, self.size, self.size) |
| 353 | |
| 354 | # head line |
| 355 | m_vector = om2.MVector(*vector) |
| 356 | length = m_vector.length() |
| 357 | headSize = 0.1 * length |
| 358 | points = ((length - headSize, headSize, 0.0), |
| 359 | (length, 0.0, 0.0), |
| 360 | (length-headSize, -headSize, 0.0)) |
| 361 | self.head = CurvePrim(points, color=self.color) |
| 362 | self.isDirty = True # force to re-orient header |
| 363 | |
| 364 | # `size` represents the scale in which the vector is drawed on the screen |
| 365 | @property |