-import bpy, math, gpu, os
+import bpy, blf, math, gpu, os
import cProfile
from ctypes import *
from mathutils import *
from gpu_extras.batch import batch_for_shader
from bpy_extras import mesh_utils
+from bpy_extras import view3d_utils
bl_info = {
"name":"Skaterift .mdl exporter",
active_object = context.active_object
if not active_object: return
- _.layout.operator( 'skaterift.copy_entity_data', \
- text=F'Copy entity data to {len(context.selected_objects)-1} '+\
- F'other objects' )
+ amount = max( 0, len(context.selected_objects)-1 )
+
+ row = _.layout.row()
+ row.operator( 'skaterift.copy_entity_data', \
+ text=F'Copy entity data to {amount} other objects' )
+ if amount == 0: row.enabled=False
box = _.layout.box()
row = box.row()
row.label( text=active_object.name )
row.scale_y = 1.5
- def _draw_prop_collection( data ): #{
+ def _draw_prop_collection( source, data ): #{
nonlocal box
row = box.row()
row.alignment = 'CENTER'
row.enabled = False
row.scale_y = 1.5
- row.label( text=F'{data[0]}' )
+ row.label( text=F'{source}' )
if hasattr(type(data[0]),'sr_inspector'):#{
type(data[0]).sr_inspector( box, data )
text=F'Mirror attributes to {mb.name}' )
#}
- _draw_prop_collection( [bones.active.SR_data ] )
+ _draw_prop_collection( \
+ F'bpy.types.Bone["{bones.active.name}"].SR_data',\
+ [bones.active.SR_data ] )
#}
else: #{
row = box.row()
#}
#}
elif active_object.type == 'LIGHT': #{
- _draw_prop_collection( [active_object.data.SR_data] )
+ _draw_prop_collection( \
+ F'bpy.types.Light["{active_object.data.name}"].SR_data', \
+ [active_object.data.SR_data] )
#}
elif active_object.type in ['EMPTY','CURVE','MESH']:#{
box.prop( active_object.SR_data, "ent_type" )
ent_type = active_object.SR_data.ent_type
col = getattr( active_object.SR_data, ent_type, None )
- if col != None and len(col)!=0: _draw_prop_collection( col )
+ if col != None and len(col)!=0:
+ _draw_prop_collection( \
+ F'bpy.types.Object["{active_object.name}"].SR_data.{ent_type}[0]', \
+ col )
if active_object.type == 'MESH':#{
col = getattr( active_object.data.SR_data, ent_type, None )
- if col != None and len(col)!=0: _draw_prop_collection( col )
+ if col != None and len(col)!=0:
+ _draw_prop_collection( \
+ F'bpy.types.Mesh["{active_object.data.name}"].SR_data.{ent_type}[0]', \
+ col )
#}
#}
#}
# ---------------------------------------------------------------------------- #
cv_view_draw_handler = None
+cv_view_pixel_handler = None
cv_view_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR')
cv_view_verts = []
cv_view_colours = []
#}
#}
-def cv_draw():
-#{
+def cv_draw():#{
global cv_view_shader
global cv_view_verts
global cv_view_colours
#}
cv_draw_lines()
- return
+#}
+
+def pos3d_to_2d( pos ):#{
+ return view3d_utils.location_3d_to_region_2d( \
+ bpy.context.region, \
+ bpy.context.space_data.region_3d, pos )
+#}
+
+def cv_draw_pixel():#{
+ if not bpy.context.scene.SR_data.gizmos: return
+ blf.size(0,10)
+ blf.color(0, 1.0,1.0,1.0,0.9)
+ blf.enable(0,blf.SHADOW)
+ blf.shadow(0,3,0.0,0.0,0.0,1.0)
+ for obj in bpy.context.collection.objects:#{
+ ent_type = obj_ent_type( obj )
+
+ if ent_type != 'none':#{
+ co = pos3d_to_2d( obj.location )
+
+ if not co: continue
+ blf.position(0,co[0],co[1],0)
+ blf.draw(0,ent_type)
+ #}
+ #}
#}
classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\
bpy.types.Material.SR_data = \
bpy.props.PointerProperty(type=SR_MATERIAL_PROPERTIES)
- global cv_view_draw_handler
+ global cv_view_draw_handler, cv_view_pixel_handler
cv_view_draw_handler = bpy.types.SpaceView3D.draw_handler_add(\
cv_draw,(),'WINDOW','POST_VIEW')
+ cv_view_pixel_handler = bpy.types.SpaceView3D.draw_handler_add(\
+ cv_draw_pixel,(),'WINDOW','POST_PIXEL')
#}
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
- global cv_view_draw_handler
+ global cv_view_draw_handler, cv_view_pixel_handler
bpy.types.SpaceView3D.draw_handler_remove(cv_view_draw_handler,'WINDOW')
+ bpy.types.SpaceView3D.draw_handler_remove(cv_view_pixel_handler,'WINDOW')
#}
# ---------------------------------------------------------------------------- #