def terain_clamp_ui(): # Only to center the UI x, y = GLOBALS['MOUSE'] x -= 40 y -= 70 Draw.Label('Drop Axis', x - 70, y + 120, 60, 20) Draw.BeginAlign() GLOBALS['DROP_AXIS'][0] = Draw.Toggle('Z', EVENT_REDRAW, x + 20, y + 120, 30, 20, GLOBALS['DROP_AXIS'][0].val, 'Drop down on the global Z axis', do_axis_z) GLOBALS['DROP_AXIS'][1] = Draw.Toggle('View Z', EVENT_REDRAW, x + 50, y + 120, 70, 20, GLOBALS['DROP_AXIS'][1].val, 'Drop allong the view vector', do_axis_view) Draw.EndAlign() # Source Draw.Label('Drop on to...', x - 70, y + 90, 120, 20) Draw.BeginAlign() GLOBALS['GROUND_SOURCE'][0] = Draw.Toggle('Active Object', EVENT_REDRAW, x - 70, y + 70, 110, 20, GLOBALS['GROUND_SOURCE'][0].val, '', do_ground_source_act) GLOBALS['GROUND_SOURCE'][1] = Draw.Toggle('Group', EVENT_REDRAW, x + 40, y + 70, 80, 20, GLOBALS['GROUND_SOURCE'][1].val, '', do_ground_source_group) if GLOBALS['GROUND_SOURCE'][1].val: GLOBALS['GROUND_GROUP_NAME'] = Draw.String( 'GR:', EVENT_REDRAW + 1001, x - 70, y + 50, 190, 20, GLOBALS['GROUND_GROUP_NAME'].val, 21, '', do_ground_group_name) Draw.EndAlign() GLOBALS['DROP_OVERLAP_CHECK'] = Draw.Toggle( 'Overlapping Terrain', EVENT_NONE, x - 70, y + 20, 190, 20, GLOBALS['DROP_OVERLAP_CHECK'].val, "Check all terrain triangles and use the top most (slow)") Draw.BeginAlign() GLOBALS['DROP_ORIENT'] = Draw.Toggle('Orient Normal', EVENT_REDRAW, x - 70, y - 10, 110, 20, GLOBALS['DROP_ORIENT'].val, "Rotate objects to the face normal", do_dummy) if GLOBALS['DROP_ORIENT'].val: GLOBALS['DROP_ORIENT_VALUE'] = Draw.Number( '', EVENT_NONE, x + 40, y - 10, 80, 20, GLOBALS['DROP_ORIENT_VALUE'].val, 0.0, 100.0, "Percentage to orient 0.0 - 100.0") Draw.EndAlign() Draw.PushButton('Drop Objects', EVENT_EXIT, x + 20, y - 40, 100, 20, 'Drop the selected objects', terrain_clamp) # So moving the mouse outside the popup exits the while loop GLOBALS['EVENT'] = EVENT_EXIT
def drawmanipulator(manipulators, indices, eventbase, boneno, x, y): # See Blender Python Docs # http://www.blender.org/documentation/248PythonDoc/Draw-module.html manipulator = manipulators[boneno] cursor = cursors[boneno] valid = True Draw.Menu('|'.join(manipulatorList), DONTCARE + eventbase, x + 4, y, CONTROLSIZE, CONTROLSIZE, -1, 'Pick the manipulator from a list', manipulatormenucallback) Draw.String('', DATAREF_B + eventbase, x + 4 + CONTROLSIZE, y, PANELWIDTH - 2 * PANELINDENT - CONTROLSIZE, CONTROLSIZE, manipulator, 100, 'Full name of the manipulator used to control this animation') y -= 30 event_id = 1000 sub_dict = sorted(manipulator_dict[manipulator].keys()) for field_id in sub_dict: field_name = field_id.split('@')[1] field_val = manipulator_dict[manipulator][field_id] if field_name == 'cursor': Draw.Label("Cursor Type:", x, y, 100, CONTROLSIZE) Draw.Menu('|'.join(cursorList), DONTCARE + eventbase, x + 4, y, CONTROLSIZE, CONTROLSIZE, -1, 'Pick the cursor type from a list', cursormenucallback) Draw.String( '', DATAREF_B + eventbase, x + 4 + CONTROLSIZE, y, PANELWIDTH - 2 * PANELINDENT - CONTROLSIZE, CONTROLSIZE, cursor, 100, 'Full name of the manipulator used to control this animation') y -= 30 event_id += 1 elif field_name != 'NULL': Draw.Label(field_name + ':', x, y, 120, CONTROLSIZE) if type(field_val).__name__ == 'str': Draw.String('', event_id, x + 100, y, 180, CONTROLSIZE, field_val, 100, '', manipulatordatacallback) if type(field_val).__name__ == 'float': Draw.Number('', event_id, x + 100, y, 80, CONTROLSIZE, field_val, -50000.0, 50000.0, '', manipulatordatacallback) if type(field_val).__name__ == 'int': Draw.Number('', event_id, x + 100, y, 80, CONTROLSIZE, int(field_val), -50000, 50000, '', manipulatordatacallback) y -= 20 event_id += 1 return valid
def drawdataref(datarefs, indices, eventbase, boneno, x, y): dataref = datarefs[boneno] valid = True mbutton = Draw.Menu('sim/%t|' + '/...|'.join(firstlevel) + '/...', DONTCARE + eventbase, x + 4, y, CONTROLSIZE, CONTROLSIZE, -1, 'Pick the dataref from a list', datarefmenucallback) bbutton = Draw.String( '', DATAREF_B + eventbase, x + 4 + CONTROLSIZE, y, PANELWIDTH - 2 * PANELINDENT - CONTROLSIZE, CONTROLSIZE, dataref, 100, 'Full name of the dataref used to animate this object') ibutton = None tbutton = None ref = dataref.split('/') if len(ref) <= 1 or ref[0] == 'sim': if len(ref) == 1 and ref[0] in lookup and not lookup[ref[0]]: BGL.glRasterPos2d(x + 4, y - 21) Draw.Text('This dataref name is ambiguous') valid = False else: try: thing = hierarchy for i in range(len(ref)): thing = thing[ref[i]] n = thing + 0 # check is a leaf - ie numeric if not n: BGL.glRasterPos2d(x + 4, y - 21) Draw.Text("This dataref can't be used for animation") valid = False elif n == 1: indices[boneno] = None else: if indices[boneno] == None or indices[boneno] >= n: indices[boneno] = 0 Draw.Label("Part number:", x, y - 26, 120, CONTROLSIZE) ibutton = Draw.Number('', INDICES_B + eventbase, x + 108, y - 26, 50, CONTROLSIZE, indices[boneno], 0, n - 1, 'The part number / array index') except: BGL.glRasterPos2d(x + 4, y - 21) Draw.Text("This is not a valid dataref") valid = False else: if indices[boneno] != None: val = 1 else: val = 0 tbutton = Draw.Toggle('Part number', INDICES_T + eventbase, x + 4, y - 26, 104, CONTROLSIZE, val, 'Whether this is an array dataref') if val: ibutton = Draw.Number('', INDICES_B + eventbase, x + 108, y - 26, 50, CONTROLSIZE, indices[boneno], 0, 729, 'The part number / array index') return (valid, mbutton, bbutton, ibutton, tbutton)
def draw(): # Define the GUI drawing function global GUIX global GUIY global GUIW global GUIH global BW global BH # Clearing the window and drawing background layout glClearColor(0.8, 0.8, 1.0, 1) glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) # This clears the window glColor3f(0.5, 0.6, 0.5) glBegin(GL_LINE_LOOP) glVertex2i(GUIX, GUIY + GUIH) glVertex2i(GUIX + GUIW, GUIY + GUIH) glVertex2i(GUIX + GUIW, GUIY) glVertex2i(GUIX, GUIY) glEnd() #glBegin(GL_POLYGON) #glVertex2i(GUIX, GUIY+GUIH-GUIH/3+5) #glVertex2i(GUIX+GUIW, GUIY+GUIH-GUIH/3+5) #glVertex2i(GUIX+GUIW, GUIY+GUIH-GUIH/3) #glVertex2i(GUIX, GUIY+GUIH-GUIH/3) #glEnd() glBegin(GL_LINE) glVertex2i(GUIX, GUIY + 50) glVertex2i(GUIX + GUIW, GUIY + 50) glEnd() # Buttons Layout Draw.PushButton("DTM File", 1, (GUIX + 10), (GUIY + GUIH - BH - 10), BW, BH, "Loads a DTM from an ascii file.") Draw.PushButton("Roads ShapeFile", 2, (GUIX + 10), (GUIY + GUIH - BH - 60), BW, BH, "Loads Shapefiles with Road Data.") Draw.PushButton("Buildings ShapeFile", 3, (GUIX + 10), (GUIY + GUIH - BH - 110), BW, BH, "Loads Shapefiles with Buildings Data.") Draw.PushButton("Vegetation ShapeFile", 4, (GUIX + 10), (GUIY + GUIH - BH - 160), BW, BH, "Loads Shapefiles with Vegetation Data.") Draw.PushButton("Load Scene", 5, (GUIX + GUIW / 2 - BW / 2), (GUIY + BH / 2), BW, BH, "Build the scene.") # Status Labels Draw.Label(statusDTM, (GUIX + 1), (GUIY + GUIH - BH - 30), 15, BH) Draw.Label(statusRoads, (GUIX + 1), (GUIY + GUIH - BH - 80), 15, BH) Draw.Label(statusBuildings, (GUIX + 1), (GUIY + GUIH - BH - 130), 15, BH) Draw.Label(statusVegetation, (GUIX + 1), (GUIY + GUIH - BH - 180), 15, BH) # File Labels Draw.Label(fileDTMShort, (GUIX + 10), (GUIY + GUIH - BH - 30), 250, BH) Draw.Label(fileRoadsShort, (GUIX + 10), (GUIY + GUIH - BH - 80), 250, BH) Draw.Label(fileBuildingsShort, (GUIX + 10), (GUIY + GUIH - BH - 130), 250, BH) Draw.Label(fileVegetationShort, (GUIX + 10), (GUIY + GUIH - BH - 180), 250, BH)
def obj_ui(): ui_x, ui_y = GLOBALS['MOUSE'] # Center based on overall pup size ui_x -= 165 ui_y -= 90 global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER, ROTATE_X90 Draw.Label('Import...', ui_x+9, ui_y+159, 220, 21) Draw.BeginAlign() CREATE_SMOOTH_GROUPS = Draw.Toggle('Smooth Groups', EVENT_NONE, ui_x+9, ui_y+139, 110, 20, CREATE_SMOOTH_GROUPS.val, 'Surround smooth groups by sharp edges') CREATE_FGONS = Draw.Toggle('NGons as FGons', EVENT_NONE, ui_x+119, ui_y+139, 110, 20, CREATE_FGONS.val, 'Import faces with more then 4 verts as fgons') CREATE_EDGES = Draw.Toggle('Lines as Edges', EVENT_NONE, ui_x+229, ui_y+139, 110, 20, CREATE_EDGES.val, 'Import lines and faces with 2 verts as edges') Draw.EndAlign() Draw.Label('Separate objects by OBJ...', ui_x+9, ui_y+110, 220, 20) Draw.BeginAlign() SPLIT_OBJECTS = Draw.Toggle('Object', EVENT_REDRAW, ui_x+9, ui_y+89, 55, 21, SPLIT_OBJECTS.val, 'Import OBJ Objects into Blender Objects', do_split) SPLIT_GROUPS = Draw.Toggle('Group', EVENT_REDRAW, ui_x+64, ui_y+89, 55, 21, SPLIT_GROUPS.val, 'Import OBJ Groups into Blender Objects', do_split) SPLIT_MATERIALS = Draw.Toggle('Material', EVENT_REDRAW, ui_x+119, ui_y+89, 60, 21, SPLIT_MATERIALS.val, 'Import each material into a seperate mesh (Avoids > 16 per mesh error)', do_split) Draw.EndAlign() # Only used for user feedback KEEP_VERT_ORDER = Draw.Toggle('Keep Vert Order', EVENT_REDRAW, ui_x+184, ui_y+89, 113, 21, KEEP_VERT_ORDER.val, 'Keep vert and face order, disables split options, enable for morph targets', do_vertorder) ROTATE_X90 = Draw.Toggle('-X90', EVENT_REDRAW, ui_x+302, ui_y+89, 38, 21, ROTATE_X90.val, 'Rotate X 90.') Draw.Label('Options...', ui_x+9, ui_y+60, 211, 20) CLAMP_SIZE = Draw.Number('Clamp Scale: ', EVENT_NONE, ui_x+9, ui_y+39, 130, 21, CLAMP_SIZE.val, 0.0, 1000.0, 'Clamp the size to this maximum (Zero to Disable)') POLYGROUPS = Draw.Toggle('Poly Groups', EVENT_REDRAW, ui_x+144, ui_y+39, 90, 21, POLYGROUPS.val, 'Import OBJ groups as vertex groups.', do_polygroups) IMAGE_SEARCH = Draw.Toggle('Image Search', EVENT_NONE, ui_x+239, ui_y+39, 100, 21, IMAGE_SEARCH.val, 'Search subdirs for any assosiated images (Warning, may be slow)') Draw.BeginAlign() Draw.PushButton('Online Help', EVENT_REDRAW, ui_x+9, ui_y+9, 110, 21, 'Load the wiki page for this script', do_help) Draw.PushButton('Cancel', EVENT_EXIT, ui_x+119, ui_y+9, 110, 21, '', obj_ui_set_event) Draw.PushButton('Import', EVENT_IMPORT, ui_x+229, ui_y+9, 110, 21, 'Import with these settings', obj_ui_set_event) Draw.EndAlign()
def gui(): global dataref_m, dataref_b, indices_b, indices_t, vals_b, clear_b, loops_b global hideshow_m, from_b, to_b, up_b, down_b, delete_b, addhs_b global cancel_b, apply_b global manipulator_m, manipulator_b, cursor_m, cursor_b dataref_m = [] dataref_b = [] indices_b = [] indices_t = [] vals_b = [] clear_b = None loops_b = [] hideshow_m = [] from_b = [] to_b = [] up_b = [] down_b = [] delete_b = [] addhs_b = None cancel_b = None apply_b = None # Default theme text = [0, 0, 0, 255] text_hi = [255, 255, 255, 255] header = [165, 165, 165, 255] panel = [255, 255, 255, 40] back = [180, 180, 180, 255] error = [255, 80, 80, 255] # where's the theme value for this? # Actual theme if Blender.Get('version') >= 235: theme = Blender.Window.Theme.Get() if theme: theme = theme[0] space = theme.get('buts') text = theme.get('ui').text text_hi = space.text_hi header = space.header header = [ max(header[0] - 30, 0), # 30 appears to be hard coded max(header[1] - 30, 0), max(header[2] - 30, 0), header[3] ] panel = space.panel back = space.back size = BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size = size.list x = int(size[2]) y = int(size[3]) BGL.glEnable(BGL.GL_BLEND) BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) BGL.glClearColor( float(back[0]) / 255, float(back[1]) / 255, float(back[2]) / 255, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) yoff = y - offset[1] if vertical: xoff = PANELPAD + PANELINDENT - offset[0] for boneno in range(bonecount): eventbase = boneno * EVENTMAX framecount = len(vals[boneno]) if not vertical: xoff = PANELPAD + boneno * (PANELWIDTH + PANELPAD) + PANELINDENT - offset[0] BGL.glColor4ub(*header) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP, xoff - PANELINDENT + PANELWIDTH, yoff - PANELTOP - PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP - PANELHEAD, xoff - PANELINDENT + PANELWIDTH, yoff - 170 - (CONTROLSIZE - 1) * framecount) txt = 'parent bone' if boneno: txt = 'grand' + txt txt = 'great-' * (boneno - 1) + txt txt = txt[0].upper() + txt[1:] BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff, yoff - 23) Draw.Text(txt) Draw.Label("Dataref:", xoff - 4, yoff - 54, 100, CONTROLSIZE) BGL.glColor4ub(*error) # For errors (valid, mbutton, bbutton, ibutton, tbutton) = drawdataref(datarefs, indices, eventbase, boneno, xoff - 4, yoff - 80) dataref_m.append(mbutton) dataref_b.append(bbutton) indices_b.append(ibutton) indices_t.append(tbutton) vals_b.append([]) if valid: # is a valid or custom dataref Draw.Label("Dataref values:", xoff - 4, yoff - 132, 150, CONTROLSIZE) for i in range(framecount): Draw.Label("Frame #%d:" % (i + 1), xoff - 4 + CONTROLSIZE, yoff - 152 - (CONTROLSIZE - 1) * i, 100, CONTROLSIZE) if i > 1: v9 = 'v9: ' else: v9 = '' vals_b[-1].append( Draw.Number( '', i + VALS_B + eventbase, xoff + 104, yoff - 152 - (CONTROLSIZE - 1) * i, 80, CONTROLSIZE, vals[boneno][i], -NUMBERMAX, NUMBERMAX, v9 + 'The dataref value that corresponds to the pose in frame %d' % (i + 1))) if framecount > 2: clear_b = Draw.Button( 'Delete', DELETE_B + eventbase, xoff + 208, yoff - 152 - (CONTROLSIZE - 1) * (framecount - 1), 80, CONTROLSIZE, 'Clear animation keys from this frame') Draw.Label("Loop:", xoff - 4 + CONTROLSIZE, yoff - 160 - (CONTROLSIZE - 1) * framecount, 100, CONTROLSIZE) loops_b.append( Draw.Number( '', LOOPS_B + eventbase, xoff + 104, yoff - 160 - (CONTROLSIZE - 1) * framecount, 80, CONTROLSIZE, loops[boneno], -NUMBERMAX, NUMBERMAX, 'v9: The animation will loop back to frame 1 when the dataref value exceeds this number. Enter 0 for no loop.' )) else: loops_b.append(None) if vertical: yoff -= (170 + (CONTROLSIZE - 1) * framecount) #Draw Manipulator GUI #This is broken #if valid: # Draw.Label("Manipulator:", xoff-4, yoff-220-(CONTROLSIZE-1)*i, 100, CONTROLSIZE) # drawmanipulator(manipulators, indices, eventbase, boneno, xoff-4, yoff-250-(CONTROLSIZE-1)*i) if not vertical: xoff = PANELPAD + bonecount * (PANELWIDTH + PANELPAD) + PANELINDENT - offset[0] BGL.glColor4ub(*header) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP, xoff - PANELINDENT + PANELWIDTH, yoff - PANELTOP - PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP - PANELHEAD, xoff - PANELINDENT + PANELWIDTH, yoff - 64 - len(hideshow) * 82) BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff, yoff - 23) Draw.Text("Hide/Show for all children of %s" % armature.name) for hs in range(len(hideshow)): eventbase = (bonecount + hs) * EVENTMAX BGL.glColor4ub(*panel) BGL.glRectd(xoff - 4, yoff - PANELTOP - PANELHEAD - 4 - hs * 82, xoff - 13 + PANELWIDTH, yoff - PANELTOP - 101 - hs * 82) BGL.glColor4ub(*error) # For errors (valid, mbutton, bbutton, ibutton, tbutton) = drawdataref(hideshow, hideshowindices, eventbase, hs, xoff - 4, yoff - 54 - hs * 82) dataref_m.append(mbutton) dataref_b.append(bbutton) indices_b.append(ibutton) indices_t.append(tbutton) if hs: up_b.append( Draw.Button('^', UP_B + eventbase, xoff + 217, yoff - 80 - hs * 82, CONTROLSIZE, CONTROLSIZE, 'Move this entry up')) else: up_b.append(None) if hs != len(hideshow) - 1: down_b.append( Draw.Button('v', DOWN_B + eventbase, xoff + 237, yoff - 80 - hs * 82, CONTROLSIZE, CONTROLSIZE, 'Move this entry down')) else: down_b.append(None) delete_b.append( Draw.Button('X', DELETE_B + eventbase, xoff + 267, yoff - 80 - hs * 82, CONTROLSIZE, CONTROLSIZE, 'Delete this entry')) if valid: # is a valid or custom dataref hideshow_m.append( Draw.Menu('Hide%x0|Show%x1', HIDEORSHOW_M + eventbase, xoff, yoff - 106 - hs * 82, 62, CONTROLSIZE, hideorshow[hs], 'Choose Hide or Show')) Draw.Label("when", xoff + 63, yoff - 106 - hs * 82, 60, CONTROLSIZE) from_b.append( Draw.Number( '', FROM_B + eventbase, xoff + 104, yoff - 106 - hs * 82, 80, CONTROLSIZE, hideshowfrom[hs], -NUMBERMAX, NUMBERMAX, 'The dataref value above which the animation will be hidden or shown' )) Draw.Label("to", xoff + 187, yoff - 106 - hs * 82, 60, CONTROLSIZE) to_b.append( Draw.Number( '', TO_B + eventbase, xoff + 207, yoff - 106 - hs * 82, 80, CONTROLSIZE, hideshowto[hs], -NUMBERMAX, NUMBERMAX, 'The dataref value below which the animation will be hidden or shown' )) else: hideshow_m.append(None) from_b.append(None) to_b.append(None) addhs_b = Draw.Button('Add New', ADD_B + bonecount * EVENTMAX, xoff + 217, yoff - 54 - len(hideshow) * 82, 70, CONTROLSIZE, 'Add a new Hide or Show entry') if vertical: xoff = PANELPAD - offset[0] yoff -= (64 + len(hideshow) * 82) else: xoff = PANELPAD + (bonecount + 1) * (PANELWIDTH + PANELPAD) - offset[0] apply_b = Draw.Button('Apply', APPLY_B + bonecount * EVENTMAX, xoff, yoff - PANELTOP - CONTROLSIZE * 2, 80, CONTROLSIZE * 2, 'Apply these settings', doapply) if vertical: cancel_b = Draw.Button('Cancel', CANCEL_B + bonecount * EVENTMAX, xoff + 80 + PANELPAD, yoff - PANELTOP - CONTROLSIZE * 2, 80, CONTROLSIZE * 2, 'Retain existing settings') else: cancel_b = Draw.Button('Cancel', CANCEL_B + bonecount * EVENTMAX, xoff, yoff - PANELTOP - CONTROLSIZE * 4 - PANELPAD, 80, CONTROLSIZE * 2, 'Retain existing settings')
def obj_ui(): ui_x, ui_y = GLOBALS['MOUSE'] # Center based on overall pup size ui_x -= 165 ui_y -= 140 global EXPORT_APPLY_MODIFIERS, EXPORT_ROTX90, EXPORT_TRI, EXPORT_EDGES,\ EXPORT_NORMALS, EXPORT_NORMALS_HQ, EXPORT_UV,\ EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\ EXPORT_ANIMATION, EXPORT_COPY_IMAGES, EXPORT_BLEN_OBS,\ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\ EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS Draw.Label('Context...', ui_x+9, ui_y+239, 220, 20) Draw.BeginAlign() EXPORT_SEL_ONLY = Draw.Toggle('Selection Only', EVENT_NONE, ui_x+9, ui_y+219, 110, 20, EXPORT_SEL_ONLY.val, 'Only export objects in visible selection. Else export whole scene.') EXPORT_ALL_SCENES = Draw.Toggle('All Scenes', EVENT_NONE, ui_x+119, ui_y+219, 110, 20, EXPORT_ALL_SCENES.val, 'Each scene as a separate OBJ file.') EXPORT_ANIMATION = Draw.Toggle('Animation', EVENT_NONE, ui_x+229, ui_y+219, 110, 20, EXPORT_ANIMATION.val, 'Each frame as a numbered OBJ file.') Draw.EndAlign() Draw.Label('Output Options...', ui_x+9, ui_y+189, 220, 20) Draw.BeginAlign() EXPORT_APPLY_MODIFIERS = Draw.Toggle('Apply Modifiers', EVENT_REDRAW, ui_x+9, ui_y+170, 110, 20, EXPORT_APPLY_MODIFIERS.val, 'Use transformed mesh data from each object. May break vert order for morph targets.', do_split) EXPORT_ROTX90 = Draw.Toggle('Rotate X90', EVENT_NONE, ui_x+119, ui_y+170, 110, 20, EXPORT_ROTX90.val, 'Rotate on export so Blenders UP is translated into OBJs UP') EXPORT_COPY_IMAGES = Draw.Toggle('Copy Images', EVENT_NONE, ui_x+229, ui_y+170, 110, 20, EXPORT_COPY_IMAGES.val, 'Copy image files to the export directory, never overwrite.') Draw.EndAlign() Draw.Label('Export...', ui_x+9, ui_y+139, 220, 20) Draw.BeginAlign() EXPORT_EDGES = Draw.Toggle('Edges', EVENT_NONE, ui_x+9, ui_y+120, 50, 20, EXPORT_EDGES.val, 'Edges not connected to faces.') EXPORT_TRI = Draw.Toggle('Triangulate', EVENT_NONE, ui_x+59, ui_y+120, 70, 20, EXPORT_TRI.val, 'Triangulate quads.') Draw.EndAlign() Draw.BeginAlign() EXPORT_MTL = Draw.Toggle('Materials', EVENT_NONE, ui_x+139, ui_y+120, 70, 20, EXPORT_MTL.val, 'Write a separate MTL file with the OBJ.') EXPORT_UV = Draw.Toggle('UVs', EVENT_NONE, ui_x+209, ui_y+120, 31, 20, EXPORT_UV.val, 'Export texface UV coords.') Draw.EndAlign() Draw.BeginAlign() EXPORT_NORMALS = Draw.Toggle('Normals', EVENT_NONE, ui_x+250, ui_y+120, 59, 20, EXPORT_NORMALS.val, 'Export vertex normal data (Ignored on import).') EXPORT_NORMALS_HQ = Draw.Toggle('HQ', EVENT_NONE, ui_x+309, ui_y+120, 31, 20, EXPORT_NORMALS_HQ.val, 'Calculate high quality normals for rendering.') Draw.EndAlign() EXPORT_POLYGROUPS = Draw.Toggle('Polygroups', EVENT_REDRAW, ui_x+9, ui_y+95, 120, 20, EXPORT_POLYGROUPS.val, 'Export vertex groups as OBJ groups (one group per face approximation).') EXPORT_CURVE_AS_NURBS = Draw.Toggle('Nurbs', EVENT_NONE, ui_x+139, ui_y+95, 100, 20, EXPORT_CURVE_AS_NURBS.val, 'Export 3D nurbs curves and polylines as OBJ curves, (bezier not supported).') Draw.Label('Blender Objects as OBJ:', ui_x+9, ui_y+59, 220, 20) Draw.BeginAlign() EXPORT_BLEN_OBS = Draw.Toggle('Objects', EVENT_REDRAW, ui_x+9, ui_y+39, 60, 20, EXPORT_BLEN_OBS.val, 'Export blender objects as "OBJ objects".', do_split) EXPORT_GROUP_BY_OB = Draw.Toggle('Groups', EVENT_REDRAW, ui_x+69, ui_y+39, 60, 20, EXPORT_GROUP_BY_OB.val, 'Export blender objects as "OBJ Groups".', do_split) EXPORT_GROUP_BY_MAT = Draw.Toggle('Material Groups', EVENT_REDRAW, ui_x+129, ui_y+39, 100, 20, EXPORT_GROUP_BY_MAT.val, 'Group by materials.', do_split) Draw.EndAlign() EXPORT_KEEP_VERT_ORDER = Draw.Toggle('Keep Vert Order', EVENT_REDRAW, ui_x+239, ui_y+39, 100, 20, EXPORT_KEEP_VERT_ORDER.val, 'Keep vert and face order, disables some other options. Use for morph targets.', do_vertorder) Draw.BeginAlign() Draw.PushButton('Online Help', EVENT_REDRAW, ui_x+9, ui_y+9, 110, 20, 'Load the wiki page for this script', do_help) Draw.PushButton('Cancel', EVENT_EXIT, ui_x+119, ui_y+9, 110, 20, '', obj_ui_set_event) Draw.PushButton('Export', EVENT_EXPORT, ui_x+229, ui_y+9, 110, 20, 'Export with these settings', obj_ui_set_event) Draw.EndAlign()
def render(self): Draw.Label(self.label, self.x, self.y, self.width, self.height)
def edl_draw(): MARGIN = 4 rect = BPyWindow.spaceRect() but_width = int((rect[2] - MARGIN * 2) / 4.0) # 72 # Clamp if but_width > 100: but_width = 100 but_height = 17 x = MARGIN y = rect[3] - but_height - MARGIN xtmp = x # ---------- ---------- ---------- ---------- Blender.Draw.BeginAlign() PREF['filename'] = Draw.String('edl path: ', B_EVENT_RELOAD, xtmp, y, (but_width * 3) - 20, but_height, PREF['filename'].val, 256, 'EDL Path') xtmp += (but_width * 3) - 20 Draw.PushButton('..', B_EVENT_FILESEL_EDL, xtmp, y, 20, but_height, 'Select an EDL file') xtmp += 20 Blender.Draw.EndAlign() Draw.PushButton( 'Reload', B_EVENT_RELOAD, xtmp + MARGIN, y, but_width - MARGIN, but_height, 'Read the ID Property settings from the active curve object') xtmp += but_width y -= but_height + MARGIN xtmp = x # ---------- ---------- ---------- ---------- reel_keys = edl_reel_keys() if reel_keys: text = 'Reel file list...' elif PREF['filename'].val == '': text = 'No EDL loaded.' else: text = 'No reels found!' Draw.Label(text, xtmp + MARGIN, y, but_width * 4, but_height) xtmp += but_width * 4 y -= but_height + MARGIN xtmp = x # ---------- ---------- ---------- ---------- for i, reel_key in enumerate(reel_keys): reel_item = REEL_UI[reel_key] Blender.Draw.BeginAlign() REEL_UI[reel_key].filename_but = Draw.String( reel_item.ui_text, B_EVENT_NOP, xtmp, y, (but_width * 3) - 20, but_height, REEL_UI[reel_key].filename_but.val, 256, 'Select the reel path') xtmp += (but_width * 3) - 20 Draw.PushButton('..', B_EVENT_FILESEL + i, xtmp, y, 20, but_height, 'Media path to use for this reel') xtmp += 20 Blender.Draw.EndAlign() reel_item.offset_but = Draw.Number( 'ofs:', B_EVENT_NOP, xtmp + MARGIN, y, but_width - MARGIN, but_height, reel_item.offset_but.val, -100000, 100000, 'Start offset in frames when applying timecode') xtmp += but_width - MARGIN y -= but_height + MARGIN xtmp = x # ---------- ---------- ---------- ---------- Draw.PushButton('Import CMX-EDL Sequencer Strips', B_EVENT_IMPORT, xtmp + MARGIN, MARGIN, but_width * 4 - MARGIN, but_height, 'Load the EDL file into the sequencer') xtmp += but_width * 4 y -= but_height + MARGIN xtmp = x
def draw_gui(): global str_gmdc_filename, str_cres_filename, str_resource_name, btn_name_suffix, \ btn_export_tangents, btn_export_rigging, btn_export_bmesh, btn_save_log, \ menu_export_morphs, btn_use_obj_props, str_bmesh_name pos_y = 340 ; MAX_PATH = 200 # frame Blender.BGL.glColor3f(0.75, 0.75, 0.75) Blender.BGL.glRecti(10, 10, 430, pos_y) pos_y-= 30 # plugin's header s = "GMDC Exporter (TS2)" Blender.BGL.glColor3f(0.8, 0.8, 0.8) Blender.BGL.glRecti(10, pos_y, 430, pos_y+30) Draw.Label(s, 20, pos_y, 400, 30) pos_y-= 30 # GMDC file selector Draw.Label("GMDC file (output)", 20, pos_y, 200, 20) pos_y-= 20 Draw.BeginAlign() str_gmdc_filename = Draw.String("", 0x10, 20, pos_y, 300, 20, str_gmdc_filename.val, MAX_PATH, "Path to GMDC file") Draw.PushButton("Select file", 0x11, 320, pos_y, 100, 20, "Open file browser") Draw.EndAlign() pos_y-= 35 # geometry name Blender.BGL.glColor3f(0.7, 0.7, 0.7) Blender.BGL.glRecti(20, pos_y-60, 420, pos_y+20) Draw.Label("SGResource name (optional)", 25, pos_y, 400, 20) ; pos_y-= 20 Draw.Label("If not provided then GMDC filename is used", 25, pos_y, 400, 20) ; pos_y-= 30 Draw.BeginAlign() str_resource_name = Draw.String("", 0x50, 70, pos_y, 180, 20, str_resource_name.val, 50, "SGResource name of this geometry") btn_name_suffix = Draw.Toggle("_tslocator_gmdc", 0x51, 250, pos_y, 120, 20, btn_name_suffix.val, "Add default suffix") Draw.EndAlign() pos_y-= 45 # options Draw.BeginAlign() btn_export_rigging = Draw.Toggle("Rigging", 0x31, 20, pos_y, 100, 20, btn_export_rigging.val, "Export rigging data (bone indices, weights)") btn_export_tangents = Draw.Toggle("Tangents", 0x32, 120, pos_y, 100, 20, btn_export_tangents.val, "Export tangents (required for bump mapping)") btn_export_bmesh = Draw.Toggle("Bound. mesh", 0x33, 220, pos_y, 100, 20, btn_export_bmesh.val, "Export bounding geometry") btn_save_log = Draw.Toggle("Save log", 0x34, 320, pos_y, 100, 20, btn_save_log.val, "Write script's log data into file *.export_log.txt") Draw.EndAlign() pos_y-= 30 Draw.BeginAlign() menu_export_morphs = Draw.Menu("Export morphs %t|Do not export morphs %x0|Diff. in v.coords only %x1|Diff. in v.coords and normals %x2", 0x35, 20, pos_y, 200, 20, menu_export_morphs.val) btn_use_obj_props = Draw.Toggle("Use object properties", 0x36, 220, pos_y, 200, 20, btn_use_obj_props.val, "Properties can be assigned in logic panel") Draw.EndAlign() pos_y-= 30 # bounding mesh name Draw.Label("Bounding mesh:", 20, pos_y, 100, 20) str_bmesh_name = Draw.String("", 0x40, 120, pos_y, 200, 20, str_bmesh_name.val, 50, "Name of mesh object that will be exported as bounding mesh") pos_y-= 50 # buttons Draw.BeginAlign() Draw.PushButton("Export", 1, 120, pos_y, 100, 30, "Export geometry (Ctrl + Enter)") Draw.PushButton("Exit", 0, 220, pos_y, 100, 30, "Terminate the script (Esc)") Draw.EndAlign()
def draw_gui(): global str_gmdc_filename, str_cres_filename, btn_import_bmesh, btn_all_bones, btn_remove_doubles, btn_save_log pos_y = 230 MAX_PATH = 200 # frame Blender.BGL.glColor3f(0.75, 0.75, 0.75) Blender.BGL.glRecti(10, 10, 430, pos_y) pos_y -= 30 # plugin's header s = "GMDC Importer (TS2)" Blender.BGL.glColor3f(0.8, 0.8, 0.8) Blender.BGL.glRecti(10, pos_y, 430, pos_y + 30) Draw.Label(s, 20, pos_y, 400, 30) pos_y -= 30 # GMDC file selector Draw.Label("GMDC file", 20, pos_y, 200, 20) pos_y -= 20 Draw.BeginAlign() str_gmdc_filename = Draw.String("", 0x10, 20, pos_y, 300, 20, str_gmdc_filename.val, MAX_PATH, "Path to GMDC file") Draw.PushButton("Select file", 0x11, 320, pos_y, 100, 20, "Open file browser") Draw.EndAlign() pos_y -= 30 # resource node file selector Draw.Label("Resource node file (optional)", 20, pos_y, 200, 20) pos_y -= 20 Draw.BeginAlign() str_cres_filename = Draw.String( "", 0x20, 20, pos_y, 300, 20, str_cres_filename.val, MAX_PATH, "Path to resource node file (CRES; optional, but recommended)") Draw.PushButton("Select file", 0x21, 320, pos_y, 100, 20, "Open file browser") Draw.EndAlign() pos_y -= 35 # options Draw.BeginAlign() btn_import_bmesh = Draw.Toggle("Bound. mesh", 0x31, 20, pos_y, 100, 20, btn_import_bmesh.val, "Import bounding geometry") btn_remove_doubles = Draw.Toggle( "Rm. doubles", 0x32, 120, pos_y, 100, 20, btn_remove_doubles.val, "If some vertices differ only in texture coordinates, then they are merged together (removes seams)" ) btn_all_bones = Draw.Toggle( "All bones", 0x33, 220, pos_y, 100, 20, btn_all_bones.val, "Import all bones/transforms; otherwise, used bones only") btn_save_log = Draw.Toggle( "Save log", 0x34, 320, pos_y, 100, 20, btn_save_log.val, "Write script's log data into file *.import_log.txt") Draw.EndAlign() pos_y -= 45 # buttons Draw.BeginAlign() Draw.PushButton("Import", 1, 120, pos_y, 100, 30, "Import geometry (Ctrl + Enter)") Draw.PushButton("Exit", 0, 220, pos_y, 100, 30, "Terminate the script (Esc)") Draw.EndAlign()