def import_gui(): global filename, fileinput, impstatus # Clear drawing area. BGL.glClearColor(0.9,0.9,0.9,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # Status. BGL.glRasterPos2i(10,8) if impstatus == 0: BGL.glColor3f(0.0,0.0,0.0) Draw.Text('Importer ready.','tiny') elif impstatus == 1: BGL.glColor3f(0.0,0.75,0.0) Draw.Text('Importing...','tiny') elif impstatus == 2: BGL.glColor3f(0.75,0.0,0.0) Draw.Text('File not found!','tiny') # Filename input box. BGL.glRasterPos2i(10,20) w = Draw.Text('File to import:') Draw.Button(filename, 3, w+15, 15, 200,20) #fileinput = Draw.String('',3, w+15,15, 200,20, filename, 512, # 'Filename to import.') Draw.Button('Import', 1, w+15+210,15, 40,20) Draw.Button('Quit', 2, w+15+210+50,15, 40,20)
def draw(): global as_package_name global fileButton, expFileName global engine_menu, engine_name global EVENT_NOEVENT, EVENT_DRAW, EVENT_EXIT, EVENT_EXPORT global export_all expFileName = "" ########## Titles glClear(GL_COLOR_BUFFER_BIT) glRasterPos2i(40, 240) logoImage = Image.Load(Get('scriptsdir') + sys.sep + 'AS3Export.png') Draw.Image(logoImage, 40, 155) as_package_name = Draw.String("Package name: ", EVENT_NOEVENT, 40, 130, 250, 20, as_package_name.val, 300) engine_name = "Away3D%x1|Away3D 2.1.0%x5|Away3D 2.2.0%x6|Papervision3D%x2|Papervision3D 2.0%x3|Sandy 3.0%x4" engine_menu = Draw.Menu(engine_name, EVENT_NOEVENT, 40, 100, 200, 20, engine_menu.val, "Choose your engine") fileButton = Draw.String('File location: ', EVENT_NOEVENT, 40, 70, 250, 20, fileButton.val, 255) Draw.PushButton('...', EVENT_BROWSEFILE, 300, 70, 30, 20, 'browse file') export_all = Draw.Toggle('Export ALL scene objects', EVENT_NOEVENT, 40, 45, 200, 20, 0) ######### Draw and Exit Buttons Draw.Button("Export", EVENT_EXPORT, 40, 20, 80, 18) Draw.Button("Exit", EVENT_EXIT, 140, 20, 80, 18)
def gui(): global buttons, offsets, rows, cols size = BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size = size.list xoff = PANELPAD yoff = int(size[3]) # 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] # Actual theme if Blender.Get('version') >= 235: theme = Blender.Window.Theme.Get() if theme: theme = theme[0] text = theme.get('ui').text space = theme.get('buts') 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 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) BGL.glColor4ub(*header) BGL.glRectd(xoff, yoff - PANELTOP, xoff - PANELINDENT + PANELWIDTH, yoff - PANELTOP - PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff, yoff - PANELTOP - PANELHEAD, xoff - PANELINDENT + PANELWIDTH, yoff - 60 - PANELINDENT - rows * CONTROLSIZE) BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff + PANELINDENT, yoff - 23) Draw.Text("Fixup UV mapping") BGL.glColor4ub(*text) BGL.glRasterPos2d(xoff + PANELINDENT, yoff - 48) Draw.Text("Select where the old image is located in the new:") buttons = [] for i in range(rows): for j in range(cols): buttons.append( Draw.Button('', len(buttons) + CANCEL + 1, xoff + PANELINDENT + j * CONTROLSIZE, yoff - 80 - i * CONTROLSIZE, CONTROLSIZE, CONTROLSIZE)) buttons.append( Draw.Button("Cancel", CANCEL, xoff - PANELINDENT * 2 + PANELWIDTH - 4 * CONTROLSIZE, yoff - 60 - rows * CONTROLSIZE, 4 * CONTROLSIZE, CONTROLSIZE))
def drawButtons(): Draw.Button("Export", EXPORT_EVT, 20, 10, 90, 20) Draw.Button("AA", CHANGE_AA, 20, 40, 90, 20) Draw.Button("Camera", CHANGE_CAM, 115, 40, 90, 20) Draw.Button("Light", CHANGE_LIGHT, 210, 40, 90, 20) Draw.Button("AO Override", CHANGE_AO, 305, 40, 90, 20)
def draw(): global animsg, flipmsg, swapmsg, anim_tick global flip_z, swap_yz, flip_norm, anim, ticks, speed, recalc_norm, Bl_norm, no_light glClearColor(0.55, 0.6, 0.6, 1) glClear(BGL.GL_COLOR_BUFFER_BIT) #external box glColor3f(0.2, 0.3, 0.3) rect(10, 402, 300, 382) #-- #glColor3f(0.3,0.4,0.4) #rect(11,399,298,398) #-- glColor3f(0.5, 0.75, 0.65) rect(14, 398, 292, 30) #-- glColor3f(0.5, 0.75, 0.65) rect(14, 366, 292, 160) #-- glColor3f(0.5, 0.75, 0.65) rect(14, 202, 292, 60) #-- glColor3f(0.5, 0.75, 0.65) rect(14, 138, 292, 40) #-- glColor3f(0.5, 0.75, 0.65) rect(14, 94, 292, 70) glColor3f(0.8, .8, 0.6) glRasterPos2i(20, 380) Draw.Text("DirectX Exporter ", 'large') Draw.Text("(for Blender 2.41)", 'small') #-------Aniamtion toggle--------------------------------------------- Draw.Toggle("Anim", 1, 20, 330, 55, 20, toggle_val, "export animations") if toggle_val: anim = 1 animsg = "animation will be exported" else: anim = 0 animsg = "animation will be not exported" glRasterPos2i(100, 335) Draw.Text(animsg) #---Flip normals toggle----------------------------------------------- Draw.Toggle("Flip norm", 2, 20, 300, 55, 20, toggle1_val, "invert normals") if toggle1_val: flip_norm = 1 flipmsg = "flipped normals" else: flip_norm = 0 flipmsg = "not flipped normals" glRasterPos2i(100, 305) Draw.Text(flipmsg) #------Swap yz toggle---------------------------------------------------------------- Draw.Toggle("Swap zy", 3, 20, 270, 55, 20, toggle2_val, "swap z,y axis(y up)") if toggle2_val: swap_yz = 1 swapmsg = "Y-axis up" else: swap_yz = 0 swapmsg = "Z-axis up" glRasterPos2i(100, 275) Draw.Text(swapmsg) #------Flip z toggle---------------------------------------------------------------- Draw.Toggle("Flip z", 4, 20, 240, 55, 20, toggle3_val, "flip z axis") if toggle3_val: flip_z = 1 zmsg = "left handed system" else: flip_z = 0 zmsg = "right handed system" glRasterPos2i(100, 245) Draw.Text(zmsg) #------Speed toggle---------------------------------------------------------------- Draw.Toggle("Speed", 5, 20, 210, 55, 20, toggle4_val, "Animation speed") if toggle4_val: speed = 1 spedmsg = "set speed" anim_tick = Draw.Number("", 6, 200, 210, 85, 20, anim_tick.val, 1, 100000, "ticks per second") else: speed = 0 spedmsg = "" glRasterPos2i(100, 215) Draw.Text(spedmsg) #------Blender Normals toggle---------------------------------------------------------------- Draw.Toggle("Bl.normals", 10, 20, 105, 75, 25, toggle5_val, "export normals as in Blender") if toggle5_val: Bl_norm = 1 #------Recalculute Normals toggle---------------------------------------------------------------- Draw.Toggle("recalc.no", 11, 120, 105, 75, 25, toggle6_val, "export recalculated normals") if toggle6_val: recalc_norm = 1 #------Recalculute Normals toggle---------------------------------------------------------------- Draw.Toggle("no smooth", 12, 220, 105, 75, 25, toggle7_val, "every vertex has the face normal,no smoothing") if toggle7_val: no_light = 1 #------Draw Button export---------------------------------------------------------------- exp_butt = Draw.Button("Export All", 7, 20, 155, 75, 30, "export all the scene objects") sel_butt = Draw.Button("Export Sel", 8, 120, 155, 75, 30, "export the selected object") exit_butt = Draw.Button("Exit", 9, 220, 155, 75, 30, "exit") glRasterPos2i(20, 75) Draw.Text("(C) 2006 Arben OMARI ") glRasterPos2i(20, 55) Draw.Text("http://www.omariben.too.it") glRasterPos2i(20, 35) Draw.Text("*****@*****.**")
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 draw(): """ This function draws the morph target on the screen and adds buttons to enable utility functions to be called to process the target. **Parameters:** This method has no parameters. """ global message, regulFactor global targetPath, morphFactor, rotVal, rotSum, currentTarget, selAxis, rotationMode global saveOnlySelectedVerts, loadedTraslTarget, loadedRotTarget, loadedPoseTarget global fitVert1, fitVert2, fitVert3 if GUIswitch == 1: glClearColor(0.5, 0.5, 0.5, 0.0) glClear(GL_COLOR_BUFFER_BIT) glColor3f(0.0, 0.0, 0.0) glRasterPos2i(10, 300) Draw.Text("MakeTargets v3.2") glColor3f(0.5, 0.0, 0.0) glRasterPos2i(10, 250) Draw.Text("Msg: %s" % (message)) glColor3f(0.0, 0.0, 0.0) glRasterPos2i(10, 230) fileText = "" if loadedTraslTarget: fileText = os.path.basename(loadedTraslTarget) elif loadedRotTarget: fileText = os.path.basename(loadedRotTarget) elif loadedPoseTarget: fileText = os.path.basename(loadedPoseTarget) Draw.Text("Target: %s" % (fileText)) Draw.Button("Load", 1, 10, 200, 50, 20, "Load target") Draw.Button("Morph", 2, 60, 200, 50, 20, "Morph ") Draw.Button("<=", 3, 110, 200, 30, 20, "Make left side symetrical to right side") Draw.Button("Reset", 4, 140, 200, 40, 20, "Return base object to its original state") Draw.Button("=>", 5, 180, 200, 30, 20, "Make right side symetrical to left side") morphFactor = Draw.Number("Value: ", 0, 10, 180, 100, 20, morphFactor.val, -2, 2, "Insert the value to apply the target") Draw.Button("Save", 6, 110, 180, 100, 20, "Save target") saveOnlySelectedVerts = Draw.Toggle( "Save only selected verts", 0, 10, 160, 200, 20, saveOnlySelectedVerts.val, "The target will affect only the selected verts") rotationMode = Draw.Toggle("Rotations", 0, 10, 140, 200, 20, rotationMode.val, "Work with rotation targets") if GUIswitch == 2: glClearColor(0.5, 0.5, 0.5, 0.0) glClear(GL_COLOR_BUFFER_BIT) glColor3f(0.0, 0.0, 0.0) glRasterPos2i(10, 300) Draw.Text("ScanToMH vers. 1") glColor3f(0.5, 0.0, 0.0) glRasterPos2i(10, 250) Draw.Text("Msg: %s" % (message)) glColor3f(0.0, 0.0, 0.0) glRasterPos2i(10, 230) Draw.Button("Load ob", 30, 10, 200, 80, 20, "Load wavefront obj") Draw.Button("Fit", 32, 90, 200, 80, 20, "Morph ") Draw.Button("Build", 31, 170, 200, 80, 20, "Build targets db") Draw.Button("Save verts", 33, 10, 180, 80, 20, "Save selected verts") regulFactor = Draw.Number("Regul: ", 0, 90, 180, 100, 20, regulFactor.val, 0, 1, "0 mean fine fitting, but less constrain") fitVert1 = Draw.String("verts to compute: ", 34, 10, 150, 240, 20, fitVert1.val, 300, "None") fitVert2 = Draw.String("verts to fit: ", 35, 10, 130, 240, 20, fitVert2.val, 300, "None") if GUIswitch == 3: glClearColor(0.5, 0.5, 0.5, 0.0) glClear(GL_COLOR_BUFFER_BIT) glColor3f(0.0, 0.0, 0.0) glRasterPos2i(10, 300) Draw.Text("Regulariser vers. 1") glColor3f(0.5, 0.0, 0.0) glRasterPos2i(10, 250) Draw.Text("Msg: %s" % (message)) glColor3f(0.0, 0.0, 0.0) glRasterPos2i(10, 230) Draw.Button("Load db data", 40, 10, 200, 80, 20, "Load targets db") Draw.Button("Regularise", 41, 90, 200, 80, 20, "Regularise the mesh ") Draw.Button("Build", 42, 170, 200, 80, 20, "Build targets db") fitVert3 = Draw.String("verts to fit: ", 35, 10, 130, 240, 20, fitVert3.val, 300, "None")