X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=blender_export.py;h=6fadae28decb6428fee5dc197795724c75884b17;hb=0945c6c301e38138b6ac54a02d5b3aea602de526;hp=e52757b16d6edbbb1b12e3ca3456376c59ae3463;hpb=d57b7661518800479c00300ce57407378696eec9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/blender_export.py b/blender_export.py index e52757b..6fadae2 100644 --- a/blender_export.py +++ b/blender_export.py @@ -113,7 +113,8 @@ class classtype_route_node(Structure): class classtype_route(Structure): _pack_ = 1 _fields_ = [("pstr_name",c_uint32), - ("id_start",c_uint32)] + ("id_start",c_uint32), + ("colour",c_float*3)] # Exporter # ============================================================================== @@ -311,8 +312,12 @@ def write_model(name): entdata_length += sizeof( classtype_route ) r = classtype_route() r.pstr_name = emplace_string("not-implemented") + r.colour[0] = obj.cv_data.colour[0] + r.colour[1] = obj.cv_data.colour[1] + r.colour[2] = obj.cv_data.colour[2] + if obj.cv_data.target != None: - r.target = obj.cv_data.target.cv_data.uid + r.id_start = obj.cv_data.target.cv_data.uid entdata_buffer += [r] @@ -574,29 +579,14 @@ def cv_draw(): def drawbpath(o0,o1,c0,c1): drawsbpath(o0,o1,c0,c1,1.0,1.0) - def drawbline(o0,o1,c0,c1): + def drawbline(p0,p1,c0,c1): nonlocal verts, colours - verts += [o0.location] - verts += [o1.location] + verts += [p0,p1] colours += [c0,c1] - - for obj in bpy.context.collection.objects: - if obj.cv_data.classtype == 'k_classtype_gate' and False: - if obj.cv_data.target != None: - p0 = obj.location - p1 = obj.cv_data.target.location - for i in range(20): - t = i/20.0 - t1 = (i+0.5)/20.0 - - pa = p0*t+p1*(1.0-t) - pb = p0*t1+p1*(1.0-t1) - - verts += [(pa[0],pa[1],pa[2])] - verts += [(pb[0],pb[1],pb[2])] - colours += [(0,1,0,1.0),(1,0,0,1.0)] + for obj in bpy.context.collection.objects: + if obj.cv_data.classtype == 'k_classtype_gate': if obj.type == 'MESH': dims = obj.data.cv_data.v0 else: @@ -624,6 +614,26 @@ def cv_draw(): verts += [(v1[0],v1[1],v1[2])] colours += [(1,1,0,1),(1,1,0,1)] + sw = (0.4,0.4,0.4,0.2) + if obj.cv_data.target != None: + drawbline( obj.location, obj.cv_data.target.location, sw,sw ) + + elif obj.cv_data.classtype == 'k_classtype_route_node': + sw = Vector((0.4,0.4,0.4,0.2)) + sw2 = Vector((1.5,0.2,0.2,0.0)) + if obj.cv_data.target != None: + drawbpath( obj, obj.cv_data.target, sw, sw ) + if obj.cv_data.target1 != None: + drawbpath( obj, obj.cv_data.target1, sw, sw ) + + drawbhandle( obj, 1.0, (0.8,0.8,0.8,1.0) ) + drawbhandle( obj, -1.0, (0.4,0.4,0.4,1.0) ) + + p1 = obj.location+ \ + obj.matrix_world.to_quaternion() @ Vector((0,0,-6+1.5)) + drawbline( obj.location, p1, sw,sw2 ) + + elif obj.cv_data.classtype == 'k_classtype_block': a = obj.data.cv_data.v0 b = obj.data.cv_data.v1 @@ -686,7 +696,7 @@ def cv_draw(): verts += [(v0[0],v0[1],v0[2])] verts += [(v1[0],v1[1],v1[2])] colours += [(0,1,1,1),(0,1,1,1)] - + elif obj.cv_data.classtype == 'k_classtype_route': vs = [None]*2 vs[0] = obj.location @@ -706,6 +716,13 @@ def cv_draw(): loop_complete = False while si > 0: + if stack_i[si-1] == 2: + si -= 1 + continue + + if si == 0: # Loop failed to complete + break + node = stack[si-1] targets = [None,None] @@ -713,7 +730,7 @@ def cv_draw(): if node.cv_data.classtype == 'k_classtype_route_node': targets[1] = node.cv_data.target1 - + nextnode = targets[stack_i[si-1]] stack_i[si-1] += 1 @@ -734,12 +751,6 @@ def cv_draw(): si += 1 continue - if stack_i[si-1] == 2: - si -= 1 - - if si == 0: # Loop failed to complete - break - if loop_complete: course_colours = [Vector((0,0.8,0.2,1.0)), \ Vector((0,0.3,0.9,1.0)), \ @@ -809,6 +820,9 @@ class CV_OBJ_SETTINGS(bpy.types.PropertyGroup): target1: bpy.props.PointerProperty( type=bpy.types.Object, name="target1", \ poll=cv_poll_target ) + colour: bpy.props.FloatVectorProperty(name="colour",subtype='COLOR',\ + min=0.0,max=1.0) + classtype: bpy.props.EnumProperty( name="Format", items = [ @@ -849,6 +863,7 @@ class CV_OBJ_PANEL(bpy.types.Panel): elif active_object.cv_data.classtype == 'k_classtype_route': _.layout.prop( active_object.cv_data, "target" ) + _.layout.prop( active_object.cv_data, "colour" ) elif active_object.cv_data.classtype == 'k_classtype_block': mesh = active_object.data