def tgl(): return pgl.TriangleSet( pgl.Point3Array([ pgl.Vector3(1, 0, 0), pgl.Vector3(-0.2, 1, 0), pgl.Vector3(-0.2, -1, 0) ]), pgl.Index3Array([pgl.Index3(0, 1, 2)]))
def _common_init(self, **keys): """ """ if len(keys["points"]) != 3: raise Exception( "ATriangle: triangle must be described by 3 points..") self._indexes = [] self._points = pgl.Point3Array(keys["points"]) for i in xrange(1, len(keys["points"])): self._indexes.append(pgl.Index3(0, 1, 2)) self._indexes = pgl.Index3Array(self._indexes)
def pgl_surface_mesh(self, grid_size=128, grid_resolution=1, potential_value=0.5, color=[190, 205, 205], transparency=0): points, triangles = self.surface_mesh(grid_size, grid_resolution, potential_value) import openalea.plantgl.all as pgl if color is None: color = [np.random.randint(0, 255) for i in xrange(3)] mat = pgl.Material(tuple(color), diffuse=0.25, transparency=transparency) s = pgl.Scene() s += pgl.Shape( pgl.FaceSet( pgl.Point3Array(points), pgl.Index3Array([[int(i) for i in tr] for tr in triangles])), mat) return s