def getUnitCone(): global UnitCone if not UnitCone: segs = LineSegs('unitCone') dist = 1 points = [ Vec3(-dist, 1, 0), Vec3(0, 1, dist), Vec3(0, 1, -dist), Vec3(dist, 1, 0) ] for point in points: segs.moveTo(Vec3(0)) segs.drawTo(point) vertices = LEUtils.circle(0, 0, dist, 64) for i in range(len(vertices)): x1, y1 = vertices[i] x2, y2 = vertices[(i + 1) % len(vertices)] pFrom = Vec3(x1, 1, y1) pTo = Vec3(x2, 1, y2) segs.moveTo(pFrom) segs.drawTo(pTo) UnitCone = NodePath(segs.create()) UnitCone.setAntialias(AntialiasAttrib.MLine) UnitCone.setLightOff(1) UnitCone.setFogOff(1) UnitCone.hide(DirectRender.ShadowCameraBitmask | DirectRender.ReflectionCameraBitmask) return UnitCone
def __init__(self, widget, axis): TransformWidgetAxis.__init__(self, widget, axis) segs = LineSegs() segs.setThickness(2) vertices = LEUtils.circle(0, 0, 1, 64) for i in range(len(vertices)): x1, y1 = vertices[i] x2, y2 = vertices[(i + 1) % len(vertices)] segs.moveTo(x1, 0, y1) segs.drawTo(x2, 0, y2) self.axisCircle = self.attachNewNode(segs.create()) self.axisCircle.setAntialias(AntialiasAttrib.MLine)
def getUnitCircle(): global UnitCircle if not UnitCircle: segs = LineSegs('unitCircle') vertices = LEUtils.circle(0, 0, 1, 64) angles = [Vec3(0, 0, 0), Vec3(90, 0, 0), Vec3(0, 90, 0)] for angle in angles: quat = Quat() quat.setHpr(angle) for i in range(len(vertices)): x1, y1 = vertices[i] x2, y2 = vertices[(i + 1) % len(vertices)] pFrom = quat.xform(Vec3(x1, 0, y1)) pTo = quat.xform(Vec3(x2, 0, y2)) segs.moveTo(pFrom) segs.drawTo(pTo) UnitCircle = NodePath(segs.create()) UnitCircle.setAntialias(AntialiasAttrib.MLine) UnitCircle.setLightOff(1) UnitCircle.setFogOff(1) UnitCircle.hide(DirectRender.ShadowCameraBitmask | DirectRender.ReflectionCameraBitmask) return UnitCircle