- largest = -1.0
-
- for i in range(3):
- #{
- if abs(v0[i]) > largest:
- #{
- largest = abs(v0[i])
- major_axis = i
- #}
- #}
-
- v1 = Vector((0,0,0))
- v1[major_axis] = 1.0
-
- tx = Vector((0,0,0))
- ty = Vector((0,0,0))
-
- cv_tangent_basis( v1, tx, ty )
- r = (abs(tx.dot( v0 )) + abs(ty.dot( v0 ))) * 0.25
- l = v0[ major_axis ] - r*2
-
- p0 = obj.matrix_world@Vector( c + (a+b)*0.5 + v1*l*-0.5 )
- p1 = obj.matrix_world@Vector( c + (a+b)*0.5 + v1*l* 0.5 )
-
- colour = [0.2,0.2,0.2,1.0]
- colour[major_axis] = 0.5
-
- cv_draw_halfsphere( p0, -v1, ty, tx, r, colour )
- cv_draw_halfsphere( p1, v1, ty, tx, r, colour )
- cv_draw_line( p0+tx* r, p1+tx* r, colour )
- cv_draw_line( p0+tx*-r, p1+tx*-r, colour )
- cv_draw_line( p0+ty* r, p1+ty* r, colour )
- cv_draw_line( p0+ty*-r, p1+ty*-r, colour )
- #}
- else:
- #{
- continue
- #}
-
- center = obj.matrix_world @ c
- if bone.cv_data.con0:
- #{
- vx = Vector([bone.cv_data.conevx[_] for _ in range(3)])
- vy = Vector([bone.cv_data.conevy[_] for _ in range(3)])
- va = Vector([bone.cv_data.coneva[_] for _ in range(3)])
- draw_cone_twist( center, vx, vy, va )
-
- #draw_limit( obj, c, Vector((0,0,1)),Vector((0,-1,0)), \
- # bone.cv_data.mins[0], bone.cv_data.maxs[0], \
- # (1,0,0,1))
- #draw_limit( obj, c, Vector((0,-1,0)),Vector((1,0,0)), \
- # bone.cv_data.mins[1], bone.cv_data.maxs[1], \
- # (0,1,0,1))
- #draw_limit( obj, c, Vector((1,0,0)),Vector((0,0,1)), \
- # bone.cv_data.mins[2], bone.cv_data.maxs[2], \
- # (0,0,1,1))
- #}
- #}
-#}
-
-def cv_draw():
-#{
- global cv_view_shader
- global cv_view_verts
- global cv_view_colours
- global cv_view_course_i
-
- cv_view_course_i = 0
- cv_view_verts = []
- cv_view_colours = []
-
- cv_view_shader.bind()
- gpu.state.depth_mask_set(False)
- gpu.state.line_width_set(2.0)
- gpu.state.face_culling_set('BACK')
- gpu.state.depth_test_set('LESS')
- gpu.state.blend_set('NONE')
-
- for obj in bpy.context.collection.objects:
- #{
- if obj.type == 'ARMATURE':
- #{
- if obj.data.pose_position == 'REST':
- draw_skeleton_helpers( obj )
- #}
- else:
- #{
- classtype = obj.cv_data.classtype
- if (classtype != 'classtype_none') and (classtype in globals()):
- #{
- cl = globals()[ classtype ]
-
- if getattr( cl, "draw_scene_helpers", None ):
- #{
- cl.draw_scene_helpers( obj )
- #}
- #}
- #}
- #}
-
- cv_draw_lines()
- return
-#}
-
-
-# ---------------------------------------------------------------------------- #
-# #
-# Blender #
-# #
-# ---------------------------------------------------------------------------- #
-
-# Checks whether this object has a classtype assigned. we can only target other
-# classes
-def cv_poll_target(scene, obj):
-#{
- if obj == bpy.context.active_object:
- return False
- if obj.cv_data.classtype == 'classtype_none':
- return False
-
- return True
-#}
-
-class CV_MESH_SETTINGS(bpy.types.PropertyGroup):
-#{
- v0: bpy.props.FloatVectorProperty(name="v0",size=3)
- v1: bpy.props.FloatVectorProperty(name="v1",size=3)
- v2: bpy.props.FloatVectorProperty(name="v2",size=3)
- v3: bpy.props.FloatVectorProperty(name="v3",size=3)
-#}