--- downloads/blender/scripts/b3d_export.py 2009-01-25 18:57:22.000000000 +0100 +++ .blender/scripts/b3d_export.py 2009-02-06 15:29:22.000000000 +0100 @@ -56,4 +56,11 @@ EVENT_LIG = 6 EVENT_EXP = 7 EVENT_QUI = 8 +EVENT_TEXTURE = 9 +EVENT_BRUSH = 10 +EVENT_MESH = 11 +EVENT_BONE = 12 +EVENT_ANIMATION = 13 +EVENT_TIMELINE = 14 + #Global Stacks @@ -66,4 +73,7 @@ bone_stack = [] keys_stack = [] +# node flags +node_flags = {'textures': 1, 'brushes': 1, 'meshes': 1, 'bones': 1, 'animations': 1, 'timeline': 0} + #Transformation Matrix TRANS_MATRIX = Mathutils.Matrix([-1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]) @@ -109,4 +119,7 @@ def write_texs(): set_wrote = 0 + if node_flags['textures'] == 0: + return texs_buf + if flag_stack[1]: exp_obj = Blender.Object.GetSelected() @@ -188,4 +201,7 @@ def write_brus(): obj_count = 0 + if node_flags['brushes'] == 0: + return brus_buf + if flag_stack[1]: exp_obj = Blender.Object.GetSelected() @@ -308,7 +324,7 @@ def write_node(): exp_con = exp_scn.getRenderingContext() - first_frame = Blender.Draw.Create(exp_con.startFrame()) - last_frame = Blender.Draw.Create(exp_con.endFrame()) - num_frames = last_frame.val - first_frame.val + first_frame = Blender.Draw.Create(exp_con.startFrame()).val + last_frame = Blender.Draw.Create(exp_con.endFrame()).val + num_frames = last_frame - first_frame if flag_stack[1]: @@ -415,4 +431,10 @@ def write_node(): if arm_action: + if node_flags['timeline'] == 0: + frames = arm_action.getFrameNumbers() + first_frame = min(frames) + last_frame = max(frames) + num_frames = (last_frame-first_frame)+1 + Blender.Set("curframe",0) Blender.Window.Redraw() @@ -443,7 +465,7 @@ def write_node(): arm_action.setActive(arm) - frame_count = first_frame.val + frame_count = first_frame - while frame_count <= last_frame.val: + while frame_count <= last_frame: Blender.Set("curframe",int(frame_count)) Blender.Window.Redraw() @@ -467,5 +489,5 @@ def write_node(): bone_rot.normalize() bone_sca = bone_matrix.scalePart() - keys_stack.append([frame_count - first_frame.val,bone_name,bone_loc,bone_sca,bone_rot]) + keys_stack.append([frame_count - first_frame,bone_name,bone_loc,bone_sca,bone_rot]) frame_count += 1 @@ -620,4 +642,7 @@ def write_node_mesh(obj,obj_count,arm_ac temp_buf = "" + if node_flags['meshes'] == 0: + return mesh_buf + temp_buf += write_int(-1) #Brush ID temp_buf += write_node_mesh_vrts(obj,obj_count,arm_action,exp_root) #NODE MESH VRTS @@ -833,4 +858,7 @@ def write_node_anim(num_frames): temp_buf = "" + if node_flags['animations'] == 0: + return anim_buf + temp_buf += write_int(0) #Flags temp_buf += write_int(num_frames) #Frames @@ -887,4 +915,7 @@ def write_node_bone(ibone): temp_buf = "" + if node_flags['bones'] == 0: + return bone_buf + for ivert in xrange(len(mesh_stack)): for iuv in xrange(len(mesh_stack[ivert][4][0])): @@ -904,4 +935,7 @@ def write_node_keys(ibone): temp_buf = "" + if node_flags['animations'] == 0: + return keys_buf + temp_buf += write_int(7) #Flags @@ -938,4 +972,5 @@ def handle_button(event): global EVENT_NOR,EVENT_COL,EVENT_CAM,EVENT_LIG global EVENT_EXP,EVENT_QUI + global EVENT_TEXTURE, EVENT_BRUSH, EVENT_MESH, EVENT_BONE, EVENT_ANIMATION, EVENT_TIMELINE if event == EVENT_ALL: @@ -969,4 +1004,27 @@ def handle_button(event): Blender.Window.FileSelector(savefile_callback,"Export B3D",tmp_filename) + if event == EVENT_TEXTURE: + node_flags['textures'] = 1-node_flags['textures'] + Blender.Draw.Redraw(1) + + if event == EVENT_BRUSH: + node_flags['brushes'] = 1-node_flags['brushes'] + Blender.Draw.Redraw(1) + + if event == EVENT_MESH: + node_flags['meshes'] = 1-node_flags['meshes'] + Blender.Draw.Redraw(1) + + if event == EVENT_BONE: + node_flags['bones'] = 1-node_flags['bones'] + Blender.Draw.Redraw(1) + + if event == EVENT_ANIMATION: + node_flags['animations'] = 1-node_flags['animations'] + Blender.Draw.Redraw(1) + + if event == EVENT_TIMELINE: + node_flags['timeline'] = 1-node_flags['timeline'] + if event == EVENT_QUI: Blender.Draw.Exit() @@ -983,6 +1041,8 @@ def draw_gui(): global EVENT_NOR,EVENT_COL,EVENT_CAM,EVENT_LIG global EVENT_EXP,EVENT_QUI + global EVENT_TEXTURE, EVENT_BRUSH, EVENT_MESH, EVENT_BONE, EVENT_ANIMATION, EVENT_TIMELINE button_width = 222 button_height = 20 + all_button_height = button_height*21 def draw_rect(x,y,width,height): @@ -998,6 +1058,6 @@ def draw_gui(): glColor3f(170.0/255.0,255.0/255.0,255.0/255.0) - draw_rect(20,330,262,310) - draw_rect(22,328,258,306) + draw_rect(20, all_button_height+20,262,all_button_height+2) + draw_rect(22,all_button_height+18,258,all_button_height-2) glColor3f(255.0/255.0,238.0/255.0,0.0/255.0) @@ -1005,6 +1065,13 @@ def draw_gui(): Draw.Text("Blitz3D Exporter 2.05",'large') - Blender.Draw.Toggle("All Objects",EVENT_ALL,40,13*button_height,button_width,button_height,flag_stack[0],"Export All Scene Objects") - Blender.Draw.Toggle("Selected Only",EVENT_SEL,40,12*button_height,button_width,button_height,flag_stack[1],"Export Only Selected Objects") + Blender.Draw.Toggle("All Objects",EVENT_ALL,40,20*button_height,button_width,button_height,flag_stack[0],"Export All Scene Objects") + Blender.Draw.Toggle("Selected Only",EVENT_SEL,40,19*button_height,button_width,button_height,flag_stack[1],"Export Only Selected Objects") + + Blender.Draw.Toggle("Texture Nodes",EVENT_TEXTURE,40,17*button_height,button_width,button_height,node_flags['textures'],"Export texture nodes") + Blender.Draw.Toggle("Brush Nodes",EVENT_BRUSH,40,16*button_height,button_width,button_height,node_flags['brushes'],"Export Brush nodes (materials)") + Blender.Draw.Toggle("Mesh Nodes",EVENT_MESH,40,15*button_height,button_width,button_height,node_flags['meshes'],"Export mesh nodes (vertices, triangles)") + Blender.Draw.Toggle("Bone Nodes",EVENT_BONE,40,14*button_height,button_width,button_height,node_flags['bones'],"Export bone nodes") + Blender.Draw.Toggle("Animation Nodes",EVENT_ANIMATION,40,13*button_height,button_width,button_height,node_flags['animations'],"Export animation and key nodes") + Blender.Draw.Toggle("Use timeline",EVENT_TIMELINE,40,12*button_height,button_width,button_height,node_flags['timeline'],"Enabled: Use animation frames of the timeline. Disabled: Use frames from first to last key.") Blender.Draw.Toggle("Normals",EVENT_NOR,40,10*button_height,button_width,button_height,flag_stack[2],"Export Vertex Normals")