def revalidate_bounding_box(self): GLReferentBase.revalidate_bounding_box(self) self.update_normal() self.bounding_box.extend_with_point(self.l_l) self.bounding_box.extend_with_point(self.l_h) self.bounding_box.extend_with_point(self.h_l) self.bounding_box.extend_with_point(self.h_h)
def draw(self): GLReferentBase.draw(self) ColorMixin.draw(self) vb = context.application.vis_backend p0,p1,p2,p3 = [target.get_frame_relative_to(self.parent).t for target in self.get_targets()] def get_normal(a,b,c,d): result = numpy.cross(a-b,c-b) norm = numpy.linalg.norm(result) if norm < 1e-8: return numpy.zeros(3,float) else: result /= norm if numpy.dot(result,d-b) > 0: result *= -1 return result vb.draw_triangles(( get_normal(p0,p1,p2,p3), [p0,p1,p2], ), ( get_normal(p1,p2,p3,p0), [p1,p2,p3], ), ( get_normal(p2,p3,p0,p1), [p2,p3,p0], ), ( get_normal(p3,p0,p1,p2), [p3,p0,p1], ))
def initnonstate(self): GLReferentBase.initnonstate(self) self.orientation = Complete() self.set_children([ SpatialReference(prefix="Begin"), SpatialReference(prefix="End") ])
def initnonstate(self): GLReferentBase.initnonstate(self) self.set_children([ SpatialReference(prefix="Corner1"), SpatialReference(prefix="Corner2"), SpatialReference(prefix="Corner3"), SpatialReference(prefix="Corner4"), ])
def draw(self): GLReferentBase.draw(self) ColorMixin.draw(self) self.update_normal() vb = context.application.vis_backend vb.draw_quads(( self.normal, [ self.l_l + 0.001*self.normal, self.l_h + 0.001*self.normal, self.h_h + 0.001*self.normal, self.h_l + 0.001*self.normal, ], ), ( - self.normal, [ self.h_l - 0.001*self.normal, self.h_h - 0.001*self.normal, self.l_h - 0.001*self.normal, self.l_l - 0.001*self.normal, ], ))
def draw(self): GLReferentBase.draw(self) ColorMixin.draw(self) self.update_normal() vb = context.application.vis_backend vb.draw_quads(( self.normal, [ self.l_l + 0.001 * self.normal, self.l_h + 0.001 * self.normal, self.h_h + 0.001 * self.normal, self.h_l + 0.001 * self.normal, ], ), ( -self.normal, [ self.h_l - 0.001 * self.normal, self.h_h - 0.001 * self.normal, self.l_h - 0.001 * self.normal, self.l_l - 0.001 * self.normal, ], ))
def revalidate_bounding_box(self): GLReferentBase.revalidate_bounding_box(self) for target in self.get_targets(): self.bounding_box.extend_with_point(target.get_frame_relative_to(self.parent).t)
def define_target(self, reference, new_target): GLReferentBase.define_target(self, reference, new_target) self.invalidate_boundingbox_list() self.invalidate_draw_list()
def target_moved(self, reference, target): GLReferentBase.target_moved(self, reference, target) self.invalidate_boundingbox_list() self.invalidate_draw_list()
def set_targets(self, targets, init=False): self.set_children([SpatialReference("Point") for target in targets]) GLReferentBase.set_targets(self, targets, init)
def revalidate_draw_list(self): if self.gl_active: GLReferentBase.revalidate_draw_list(self)
def initnonstate(self): GLReferentBase.initnonstate(self) self.orientation = Complete.identity() self.set_children( [SpatialReference(prefix="Begin"), SpatialReference(prefix="End")])