def gui(self): # the function to draw the screen BGL.glClearColor(0, 0, 0.5, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1, 1, 1) BGL.glRasterPos2i(20, 200) Draw.Text("Select the object to export:", "normal") self.objMenu = Draw.Menu(self.sObjSelection, 1, 20, 170, 200, 20, self.objSel, "Select the animated object.") BGL.glRasterPos2i(20, 150) Draw.Text("Select the armature to export:", "normal") self.armMenu = Draw.Menu(self.sArmSelection, 2, 20, 120, 200, 20, self.armSel, "Select the matching armature.") BGL.glRasterPos2i(20, 100) Draw.Text("Select the root bone of the armature:", "normal") self.boneMenu = Draw.Menu(self.sBoneSelection, 3, 20, 70, 200, 20, self.boneSel, "Select the Root Bone of the armature.") Draw.PushButton("Export", 4, 250, 150, 50, 20, "Export File") Draw.PushButton("Cancel", 5, 250, 110, 50, 20, "Cancel") BGL.glRasterPos2i(72, 16) string = "Selections: " + ("%s" % self.objSel) + " / " + ( "%s" % self.armSel) + " / " + ("%s" % self.boneSel) Draw.Text(string, "small")
def drawGUI(): """ Create and draw the GUI. """ HEIGHT = 382 CONTROL_WIDTH = 400 BGL.glClearColor(0.6, 0.6, 0.6, 1.0) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(0.75, 0.75, 0.75) BGL.glRecti(3,45,CONTROL_WIDTH,3) stitchOffset = 22 HEIGHT += stitchOffset * num_motions_button.val Display_Title_Bar(HEIGHT,25, CONTROL_WIDTH) Display_File_Bar(HEIGHT - 25, 71 + stitchOffset * num_motions_button.val, CONTROL_WIDTH) Display_Mesh_Bar(HEIGHT - 96 - stitchOffset * num_motions_button.val, 48, CONTROL_WIDTH) Display_Camera_Bar(HEIGHT - 144 - stitchOffset * num_motions_button.val, 112, CONTROL_WIDTH) Display_Render_Bar(HEIGHT - 256 - stitchOffset * num_motions_button.val, 48, CONTROL_WIDTH) Display_Output_Bar(HEIGHT - 304 - stitchOffset * num_motions_button.val, 48, CONTROL_WIDTH) Draw.PushButton('Load simulation', SimulationButton, 9, 8, (CONTROL_WIDTH / 2) - 9, 18, 'Load simulation') if hasLoaded: Draw.PushButton('Render scene', RenderButton, (CONTROL_WIDTH / 2) + 3, 8, (CONTROL_WIDTH / 2) - 9, 18, 'Render scene')
def gui_draw(): from Blender import BGL, Draw (width, height) = Blender.Window.GetAreaSize() BGL.glClearColor(0.4, 0.4, 0.45, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1, 1, 1) BGL.glRasterPos2f(5, 55) Draw.Text("FlightGear YASim Import: '%s'" % Global.path) Draw.PushButton("Reload", RELOAD_BUTTON, 5, 5, 80, 32, "reload YASim config file") Global.mirror_button = Draw.Toggle("Mirror", MIRROR_BUTTON, 100, 5, 50, 16, Global.mirror_button.val, \ "show symmetric surfaces on both sides (reloads config)") Draw.PushButton("Update Cursor", CURSOR_BUTTON, width - 650, 5, 100, 32, "update cursor display (in YASim coordinate system)") BGL.glRasterPos2f( width - 530 + Blender.Draw.GetStringWidth("Vector from last") - Blender.Draw.GetStringWidth("Current"), 24) Draw.Text("Current cursor pos: x = %+.3f y = %+.3f z = %+.3f" % tuple(Global.cursor)) c = Global.cursor - Global.last_cursor BGL.glRasterPos2f(width - 530, 7) Draw.Text( "Vector from last cursor pos: x = %+.3f y = %+.3f z = %+.3f length = %.3f m" % (c[0], c[1], c[2], c.length))
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 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 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(): Draw.PushButton("ADD LINE?", 1, 50, 40, 200, 20, "Add point for line") global yes if (yes == 1): glClearColor(0, 0, 0, 1) glClear(GL_COLOR_BUFFER_BIT) glLineWidth(2) glColor3f(1.0, 0, 0) glBegin(GL_LINE_LOOP) glVertex2f(*point0) glVertex2f(*point1) glEnd() #points glPointSize(10) glColor3f(0, 1.0, 0) glBegin(GL_POINTS) glVertex2f(*xy0) glVertex2f(*xy1) glEnd() glColor3f(0, 0, 1.0) glBegin(GL_LINE_LOOP) changeXY1() getCenter() glEnd()
def gui(): global x2, y2, r1, i Draw.PushButton("Add point", 1, 1, 10, 100, 70, "Add point to polygon") if (x2 > 0 and y2 > 0): maincircle(x2, y2, r1) LittlecircleOne(x2, y2, r1, i) LittlecircleTwo(x2, y2, r1, i) changeI()
def Display_Camera_Bar(Y_POS, CONTROL_HEIGHT, CONTROL_WIDTH): """ Create the Camera setup box. """ Create_Tab(3, Y_POS, CONTROL_WIDTH, Y_POS - CONTROL_HEIGHT, "Camera setup", Camera_Setup_Selection) global select_all_cameras_button select_all_cameras_button = Draw.PushButton('Select all cameras', no_action, ((CONTROL_WIDTH / 2) + 3), (Y_POS - 22), (CONTROL_WIDTH / 2) - 9, 16, 'Selects all cameras in the scene', Select_All_Cameras) if Camera_Setup_Selection['Automatic setup'][0].val: global camera_number_button camera_number_button = Draw.Number("Number of cameras:", CameraNumberButton, 9, (Y_POS - 63), (CONTROL_WIDTH / 2) - 9, 18, camera_number_button_value, camera_number_button_minimum, camera_number_button_maximum, 'Number of cameras to be set up in the scene', camButtonClicked, camera_number_button_step) global camera_latitude_button camera_latitude_button = Draw.Number("Latitude:", CameraLatitudeButton, ((CONTROL_WIDTH / 2) + 3), (Y_POS - 63), (CONTROL_WIDTH / 2) - 9, 18, camera_latitude_button.val, 0, math.pi/2, 'General latitude of the cameras') global camera_ontop_button camera_ontop_button = Draw.Number("Ceiling cameras:", CameraOntopButton, 9, (Y_POS - 84), (CONTROL_WIDTH / 2) - 9, 18, camera_ontop_button.val, 0, 4, 'Number of cameras to be positioned in the ceiling', lambda x,y:None, 10) if camera_ontop_button.val: global camera_ontop_latitude_button camera_ontop_latitude_button = Draw.Number("Ceiling latitude:", CameraOntopLatitudeButton, ((CONTROL_WIDTH / 2) + 3), (Y_POS - 84), (CONTROL_WIDTH / 2) - 9, 18, camera_ontop_latitude_button.val, 0, math.pi/2, 'Latitude of the cameras in the ceiling') global camera_radius_button camera_radius_button = Draw.Number("Radius:", CameraRadiusButton, ((CONTROL_WIDTH / 2) + 3), (Y_POS - CONTROL_HEIGHT) + 6, (CONTROL_WIDTH / 2) - 9, 18, camera_radius_button.val, 1, 40, 'The radius of the circle the cameras are placed in, in meters', lambda x,y:None, 10) if Camera_Setup_Selection['Pre-saved setup'][0].val: global camera_import_button camera_import_button = Draw.PushButton('Select camera setup (.xml)', CameraImportButton, 9, (Y_POS - 63), (CONTROL_WIDTH / 2) - 9, 18, 'Select camera setup (.xml)') BGL.glRasterPos2i(11, (Y_POS - 80)) if CAMString: RIGHT_LIMIT = 6 tempString = CAMString if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(CAMString) else: Draw.Text('Please select a file...') global camera_export_button camera_export_button = Draw.PushButton('Export current setup', CameraExportButton, 9, (Y_POS - CONTROL_HEIGHT) + 6, (CONTROL_WIDTH / 2) - 9, 18, 'Press this button to save your camera setup')
def gui(): global evtExport, evtPathChanged, evtBrows global exportPath global guiExport, guiBrows, guiExportSelection, guiExportNormals, guiExportTriangulated, guiAddObjExtension, guiAddMatExtension, guiLogo guiAddObjExtension = Draw.PushButton( "add obj script link", evtAddObjExtension, 10, 155, 150, 25, "add a text file for more i3d object properties and link it to the active object via script links" ) guiAddMatExtension = Draw.PushButton( "add mat script link", evtAddMatExtension, 175, 155, 155, 25, "add a text file for more i3d material properties and link it to the active material via script links" ) guiExportSelection = Draw.Toggle("only selected", evtExportSelection, 10, 120, 100, 25, exportSelection, "only export selected objects") guiExportTriangulated = Draw.Toggle( "triangulate", evtExportTriangulated, 120, 120, 100, 25, exportTriangulated, "convert quads to triangles (shortest edge)") guiExportNormals = Draw.Toggle("normals", evtExportNormals, 230, 120, 100, 25, exportNormals, "export vertex normals") exportPath = Draw.String("export to: ", evtPathChanged, 10, 85, 260, 25, exportPath.val, 256, "export to %s" % exportPath.val) guiBrows = Draw.PushButton("Brows", evtBrows, 280, 85, 50, 25, "open file browser to chose export location") if exportSelection: guiExport = Draw.PushButton("Export Selection", evtExport, 70, 10, 260, 50, "write i3d to selected file") else: guiExport = Draw.PushButton("Export Scene", evtExport, 70, 10, 260, 50, "write i3d to selected file") if logo: BGL.glEnable( BGL.GL_BLEND ) # Only needed for alpha blending images with background. BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) guiLogo = Draw.Image(logo, 12, 13) BGL.glDisable(BGL.GL_BLEND)
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 Display_Output_Bar(Y_POS, CONTROL_HEIGHT, CONTROL_WIDTH): """ Create the Display output box.""" Create_Tab(3, Y_POS, CONTROL_WIDTH, Y_POS - CONTROL_HEIGHT, "Output setup", 0) Draw.PushButton('Select output location', OutputButton, 9, (Y_POS - 41), 130, 18, 'Select output location') BGL.glRasterPos2i(143, (Y_POS - 36)) if OUTPUTString: RIGHT_LIMIT = 144 tempString = OUTPUTString if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(OUTPUTString) else: Draw.Text('Please select a folder...')
def draw_gui(): global host,port,Shapepreset,Geompreset,mesh,molname,stringName mols=self.Mols.full_name().split(',') tmp="Mols %t|" for i in range(len(mols)) : tmp+=mols[i]+'%x'+str(i)+'|' name = tmp[:-1] #print name #Draw.Toggle("Armature", EV_TG_ARMATURE, 5, line[1], 60, 25,ARMATURE, "Armature") BGL.glRasterPos2i(5,line[8]) Draw.Text("Options:") Draw.Toggle("Join geometry", EV_TG_JOIN, 5, line[7], 60, 25,JOIN, "Join") Draw.PushButton("Delete Mol", EV_TG_DEL, 5, line[6], 90, 25, "DeleteMol") Shapepreset=Draw.Menu(name,EV_ME_MOL, 100, line[6], 90, 25, Shapepreset.val,'ON') Draw.PushButton("Add Armature", EV_TG_ARMATURE, 5, line[5], 90, 25, "Armature") Shapepreset=Draw.Menu(name,EV_ME_MOL, 100, line[5], 90, 25, Shapepreset.val,'ON') #gname = "Geoms %t|none %x1|MSMS-MOL %x2 |cpk %x3|sticks %x4|secstruc %x5|coarseSurf %x6" #Geompreset=Draw.Menu(gname,EV_ME_GEO, 195, line[5], 90, 25, Geompreset.val,'ON') stringName = Draw.String("sel:", EV_ST_PDBNAME, 220, line[5], 235, 25,stringName.val, 100,"selection level") BGL.glRasterPos2i(5,line[4]) Draw.Text("Send Mesh to Server:") mesh = Draw.String("Mesh: ", EV_TX_SEND1, 5, line[3], 90, 25,mesh.val, 32, "Mesh") #molname= Draw.String("Mol: ", EV_TX_SEND2, 100, line[3], 90, 25,molname.val, 32, "Mol") Shapepreset=Draw.Menu(name,EV_ME_MOL, 100, line[3], 90, 25, Shapepreset.val,'ON') Draw.PushButton("SendToServer", EV_BT_SEND, 195, line[3], 90, 25, "SendGeom") BGL.glRasterPos2i(5,line[2]) Draw.Text("Server:") host = Draw.String("Host: ", EV_BT_HOST1, 5, line[1], 90, 25,host.val, 32, "Name") port = Draw.String("Port: ", EV_BT_HOST2, 100, line[1], 90, 25,port.val, 32, "Portid") Draw.PushButton("StartCom", EV_BT_OK, 5, line[0], 90, 25, "StartThread") Draw.PushButton("StopCom", EV_BT_CANCEL, 100, line[0], 90, 25, "StopThread") Draw.PushButton("Refresh", EV_BT_REFRESH, 195, line[0], 90, 25, "Refresh")
def gui(): # drawing the screen global SCREEN, START_SCREEN, CONFIG_SCREEN, KEYMENUS, LABELS global BEVT_KEYMENU, BUT_KEYMENU, CFGKEY global BUT_TYPES, SCROLL_DOWN, VARS_NUM WIDTH, HEIGHT = Window.GetAreaSize() theme = Theme.Get()[0] tui = theme.get('ui') ttxt = theme.get('text') COL_BG = float_colors(ttxt.back) COL_TXT = ttxt.text COL_TXTHI = ttxt.text_hi BGL.glClearColor(COL_BG[0], COL_BG[1], COL_BG[2], COL_BG[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) if SCREEN == START_SCREEN: x = 10 y = 10 h = 20 w = 90 BGL.glRasterPos2i(x, y) Draw.Text( 'Select a configuration key to access it. Press Q or ESC to leave.' ) km_len = len(KEYMENUS) km_columns = (WIDTH - x) / w if km_columns == 0: km_rows = km_len else: km_rows = km_len / km_columns if (km_len % km_columns): km_rows += 1 if km_rows == 0: km_rows = 1 ystart = y + 2 * h * km_rows if ystart > (HEIGHT - 70): ystart = HEIGHT - 70 y = ystart column = 1 for i, km in enumerate(KEYMENUS): column += 1 BGL.glRasterPos2i(x + 2, y + h + 5) Draw.Text(LABELS[i]) BUT_KEYMENU[i] = Draw.Menu( km, BEVT_KEYMENU[i], x, y, w - 10, h, 0, 'Choose a key to access its configuration data') if column > km_columns: column = 1 y -= 2 * h if y < 35: break x = 10 else: x += w x = 10 y = 50 + ystart BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Configuration Editor') Draw.PushButton('help', BEVT_HELP, x, 22, 45, 16, 'View help information about this script (hotkey: H)') elif SCREEN == CONFIG_SCREEN: x = y = 10 h = 18 data = CFGKEY.sorteddata tips = CFGKEY.tips fromdisk = CFGKEY.fromdisk limits = CFGKEY.limits VARS_NUM = 0 for k in data.keys(): VARS_NUM += len(data[k]) lines = VARS_NUM + 5 # to account for header and footer y = lines * h if y > HEIGHT - 20: y = HEIGHT - 20 BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Configuration Editor') y -= 20 BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) txtsize = 10 if HEIGHT < lines * h: BGL.glRasterPos2i(10, 5) txtsize += Draw.Text('Arrow keys or mouse wheel to scroll, ') BGL.glRasterPos2i(txtsize, 5) Draw.Text('Q or ESC to return.') BGL.glRasterPos2i(x, y) Draw.Text('Key: "%s"' % CFGKEY.name) bh = 16 bw = 45 by = 16 i = -1 if CFGKEY.scriptname: i = 0 Draw.PushButton( 'help', BEVT_HELP, x, by, bw, bh, 'Show documentation for the script that owns this key (hotkey: H)' ) Draw.PushButton('back', BEVT_BACK, x + (1 + i) * bw, by, bw, bh, 'Back to config keys selection screen (hotkey: ESC)') Draw.PushButton('exit', BEVT_EXIT, x + (2 + i) * bw, by, bw, bh, 'Exit from Scripts Config Editor (hotkey: Q)') Draw.PushButton('revert', BEVT_CANCEL, x + (3 + i) * bw, by, bw, bh, 'Revert data to original values (hotkey: U)') Draw.PushButton('apply', BEVT_APPLY, x + (4 + i) * bw, by, bw, bh, 'Apply changes, if any (hotkey: ENTER)') delmsg = 'Delete this data key from memory' if fromdisk: delmsg = "%s and from disk" % delmsg Draw.PushButton('delete', BEVT_DEL, x + (5 + i) * bw, by, bw, bh, '%s (hotkey: DELETE)' % delmsg) if fromdisk: Draw.Toggle( "file", BEVT_DISK, x + 3 + (6 + i) * bw, by, bw, bh, DISK_UPDATE, 'Update also the file where this config key is stored') i = -1 top = -1 y -= 20 yend = 30 if data.has_key(bool) and y > 0: lst = data[bool] for l in lst: top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break w = 20 tog = data[bool][i][1] if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click to toggle" BUT_TYPES[bool][i] = Draw.Toggle("", BEVT_BOOL + i, x, y, w, h, tog, tooltip) BGL.glRasterPos2i(x + w + 3, y + 5) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(int) and y > 0: lst = data[int] for l in lst: w = 70 top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break val = data[int][i][1] if limits: min, max = limits[l[0]] else: min, max = 0, 10 if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click / drag to change" BUT_TYPES[int][i] = Draw.Number("", BEVT_INT + i, x, y, w, h, val, min, max, tooltip) BGL.glRasterPos2i(x + w + 3, y + 3) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(float) and y > 0: lst = data[float] for l in lst: w = 70 top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break val = data[float][i][1] if limits: min, max = limits[l[0]] else: min, max = 0.0, 1.0 if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click and drag to change" BUT_TYPES[float][i] = Draw.Number("", BEVT_FLOAT + i, x, y, w, h, val, min, max, tooltip) BGL.glRasterPos2i(x + w + 3, y + 3) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(str) and y > 0: lst = data[str] for l in lst: top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break name = l[0].lower() is_dir = is_file = False if name.find('_dir', -4) > 0: is_dir = True elif name.find('_file', -5) > 0: is_file = True w = WIDTH - 20 wbrowse = 50 if is_dir and w > wbrowse: w -= wbrowse if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click to write a new string" name = name.replace('_', ' ') + ': ' if len(l[1]) > MAX_STR_LEN: l[1] = l[1][:MAX_STR_LEN] BUT_TYPES[str][i] = Draw.String(name, BEVT_STR + i, x, y, w, h, l[1], MAX_STR_LEN, tooltip) if is_dir: Draw.PushButton( 'browse', BEVT_BROWSEDIR + i, x + w + 1, y, wbrowse, h, 'click to open a file selector (pick any file in the desired dir)' ) elif is_file: Draw.PushButton('browse', BEVT_BROWSEFILE + i, x + w + 1, y, 50, h, 'click to open a file selector')
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 render(self): Draw.PushButton(self.label, self.event, self.x, self.y, self.width, self.height, self.tooltip)
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 Display_File_Bar(Y_POS, CONTROL_HEIGHT, CONTROL_WIDTH): """ Create the File setup box.""" global num_motions_button Create_Tab(3, Y_POS, CONTROL_WIDTH, Y_POS - CONTROL_HEIGHT, "File setup", 0) RIGHT_LIMIT = 90 global ASF_button ASF_button = Draw.PushButton('ASF-file', ASFBUTTON, 9, (Y_POS - 41), 65, 18, 'ASF-file') BGL.glRasterPos2i(80, (Y_POS - 37)) if ASFString: tempString = ASFString if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(ASFString) else: Draw.Text('Please select a file...') global AMC_button AMC_button = Draw.PushButton('AMC-file', AMCBUTTON, 9, (Y_POS - 63), 65, 18, 'AMC-file') BGL.glRasterPos2i(80, (Y_POS - 58)) if AMCString: tempString = AMCString if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(AMCString) else: Draw.Text('Please select a file...') if num_motions_button.val > 1: global AMC2_button AMC2_button = Draw.PushButton('AMC2-file', AMC2BUTTON, 9, (Y_POS - 85), 65, 18, 'AMC-file') BGL.glRasterPos2i(80, (Y_POS - 80)) if stitch and AMC2String: tempString = AMC2String if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(AMC2String) else: Draw.Text('Please select a file...') if num_motions_button.val > 2: global AMC3_button AMC3_button = Draw.PushButton('AMC3-file', AMC3BUTTON, 9, (Y_POS - 107), 65, 18, 'AMC-file') BGL.glRasterPos2i(80, (Y_POS - 101)) if AMC3String: tempString = AMC3String if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(AMC3String) else: Draw.Text('Please select a file...') if num_motions_button.val > 3: global AMC4_button AMC4_button = Draw.PushButton('AMC4-file', AMC4BUTTON, 9, (Y_POS - 129), 65, 18, 'AMC-file') BGL.glRasterPos2i(80, (Y_POS - 123)) if AMC4String: tempString = AMC4String if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(AMC4String) else: Draw.Text('Please select a file...') if num_motions_button.val > 4: global AMC5_button AMC5_button = Draw.PushButton('AMC5-file', AMC5BUTTON, 9, (Y_POS - 151), 65, 18, 'AMC-file') BGL.glRasterPos2i(80, (Y_POS - 145)) if AMC5String: tempString = AMC5String if (Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT)): while Draw.GetStringWidth('...' + tempString) > (CONTROL_WIDTH - RIGHT_LIMIT): tempString = tempString[2:] Draw.Text('...' + tempString) else: Draw.Text(AMC5String) else: Draw.Text('Please select a file...') num_motions_button = Draw.Number("Number of motions:", STITCHBUTTON, 9, (Y_POS - 63 - (22*num_motions_button.val)), (CONTROL_WIDTH / 2) - 9, 18, num_motions_button.val, 1, 5, 'The number of motions to be imported') if num_motions_button.val > 1: global motion_transition_button motion_transition_button = Draw.Number("Transition time (frames):", no_action, ((CONTROL_WIDTH / 2) + 3), (Y_POS - 63 - (22*num_motions_button.val)), (CONTROL_WIDTH / 2) - 9, 18, motion_transition_button.val, 1, 1000, 'The number of frames between each motion')
def gui(): # drawing the screen global SCREEN, START_SCREEN, SCRIPT_SCREEN global SCRIPT_INFO, AllGroups, GROUP_MENUS global BEVT_EMAIL, BEVT_LINK global BEVT_VIEWSOURCE, BEVT_EXIT, BEVT_BACK, BEVT_GMENU, BUT_GMENU, BEVT_EXEC global PADDING, WIN_W, WIN_H, SCROLL_DOWN, COLUMNS, FMODE theme = Theme.Get()[0] tui = theme.get('ui') ttxt = theme.get('text') COL_BG = float_colors(ttxt.back) COL_TXT = ttxt.text COL_TXTHI = ttxt.text_hi BGL.glClearColor(COL_BG[0], COL_BG[1], COL_BG[2], COL_BG[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) resize = screen_was_resized() if resize: fit_on_screen() if SCREEN == START_SCREEN: x = PADDING bw = 85 bh = 25 hincr = 50 butcolumns = (WIN_W - 2 * x) / bw if butcolumns < 2: butcolumns = 2 elif butcolumns > 7: butcolumns = 7 len_gm = len(GROUP_MENUS) butlines = len_gm / butcolumns if len_gm % butcolumns: butlines += 1 h = hincr * butlines + 20 y = h + bh BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Help Browser') y -= bh BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) i = 0 j = 0 for group_menu in GROUP_MENUS: BGL.glRasterPos2i(x, y) Draw.Text(group_menu[0] + ':') BUT_GMENU[j] = Draw.Menu( group_menu[1], BEVT_GMENU[j], x, y - bh - 5, bw, bh, 0, 'Choose a script to read its help information') if i == butcolumns - 1: x = PADDING i = 0 y -= hincr else: i += 1 x += bw + 3 j += 1 x = PADDING y = 10 BGL.glRasterPos2i(x, y) Draw.Text('Select script for its help. Press Q or ESC to leave.') elif SCREEN == SCRIPT_SCREEN: if SCRIPT_INFO: if resize: SCRIPT_INFO.wrap_lines(1) SCROLL_DOWN = 0 h = 18 * SCRIPT_INFO.len_content + 12 * SCRIPT_INFO.spaces x = PADDING y = WIN_H bw = 38 bh = 16 BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) for line in SCRIPT_INFO.header: y -= 18 BGL.glRasterPos2i(x, y) size = Draw.Text(line) for line in text_wrap('Tooltip: %s' % SCRIPT_INFO.script.tip): y -= 18 BGL.glRasterPos2i(x, y) size = Draw.Text(line) i = 0 y -= 28 for data in SCRIPT_INFO.d['__url__']: Draw.PushButton('link %d' % (i + 1), BEVT_LINK[i], x + i * bw, y, bw, bh, data[0]) i += 1 y -= bh + 1 i = 0 for data in SCRIPT_INFO.d['__email__']: Draw.PushButton('email', BEVT_EMAIL[i], x + i * bw, y, bw, bh, data[0]) i += 1 y -= 18 y0 = y BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) for line in SCRIPT_INFO.content[SCROLL_DOWN:]: if line: line = line.replace('<br>', '') BGL.glRasterPos2i(x, y) Draw.Text(line) y -= 18 else: y -= 12 if y < PADDING + 20: # reached end, either stop or go to 2nd column if COLUMNS == 1: break elif x == PADDING: # make sure we're still in column 1 x = 6 * TEXT_WRAP + PADDING / 2 y = y0 x = PADDING Draw.PushButton( 'source', BEVT_VIEWSOURCE, x, 17, 45, bh, 'View this script\'s source code in the Text Editor (hotkey: S)' ) Draw.PushButton('exit', BEVT_EXIT, x + 45, 17, 45, bh, 'Exit from Scripts Help Browser (hotkey: Q)') if not FMODE: Draw.PushButton( 'back', BEVT_BACK, x + 2 * 45, 17, 45, bh, 'Back to scripts selection screen (hotkey: ESC)') Draw.PushButton('run script', BEVT_EXEC, x + 3 * 45, 17, 60, bh, 'Run this script') BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, 5) Draw.Text('use the arrow keys or the mouse wheel to scroll text', 'small')
def gui(): # Draw.PushButton("Add point", 1, 1, 10, 65, 20, "Add point to polygon")
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(): global n2mat, bl_mats_menu, n2_shader_menu, shader_params_menu, texture_param_list win_size = Window.GetAreaSize() left = 0 top = win_size[1] button_width = 100 button_height = 17 pen_x = left + padding pen_y = win_size[1] - (button_height + padding) # TODO: get material for selected object if any if (n2mat): # Draw Label BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text('Blender Material') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 # menu = buildMenu(bl_mats) bl_mats_menu = Draw.Menu(menu, BL_MAT_CHANGED, pen_x, pen_y, button_width, button_height, bl_mat_index, 'Blender Material') # Move Pen Point pen_x = pen_x + button_width + (padding * 2) pen_y = pen_y + 5 BGL.glRasterPos2i(pen_x, pen_y) # Draw Label text_width = Draw.Text('Nebula Shader') # Move Pen Point pen_x = pen_x + text_width + (padding) pen_y = pen_y - 5 button_width = 180 # menu = buildMenu(n2_shaders) n2_shader_menu = Draw.Menu(menu, NEBULA_SHADER_CHANGED, pen_x, pen_y, button_width, button_height, n2_shader_index, 'Nebula Shader') # Draw Params for current nebula shader shader = n2mat.GetShader() # Move Pen params_start_y = pen_y pen_x = left + padding params = shader.m_params label_width = 130 label_max_chars = 25 button_width_max = 80 name_max_chars = 10 column_size = label_width + (padding * 2) + button_width_max # Get Mesh object holding the shaders name and params texture_param_list = [] button_width = 120 #params = [] for key in params: param = params[key] if (not n2exporter.texture_param_types.has_key(param.m_type)): if ((pen_y - button_height - padding) < button_height): pen_x = pen_x + column_size #(win_size[0] / 2) pen_y = params_start_y pen_y = pen_y - button_height - padding BGL.glRasterPos2i(pen_x, pen_y) label = param.m_label name = param.m_name stored_value = n2mat.GetParamValue(param.m_name) if (len(label) > label_max_chars): label = label[0:label_max_chars] if (len(name) > name_max_chars): name = name[0:name_max_chars] Draw.Text(str(label)) if (param.m_type == "Int"): button_width = 50 pen_x = pen_x + label_width + padding pen_y = pen_y - 5 shader_params_menu[param.m_name] = Draw.Number( "", SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, int(stored_value), int(param.m_min), int(param.m_max), str(param.m_label)) pen_x = pen_x - label_width - padding pen_y = pen_y + 5 elif (param.m_type == "Bool"): button_width = 55 pen_x = pen_x + label_width + padding pen_y = pen_y - 5 menu = buildMenu(["False", "True"]) shader_params_menu[param.m_name] = Draw.Menu( menu, SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, int(stored_value), str(param.m_label)) pen_x = pen_x - label_width - padding pen_y = pen_y + 5 elif (param.m_type == "Float"): button_width = 60 pen_x = pen_x + label_width + padding pen_y = pen_y - 5 shader_params_menu[param.m_name] = Draw.Number( "", SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, float(stored_value), float(param.m_min), float(param.m_max), str(param.m_label)) pen_x = pen_x - label_width - padding pen_y = pen_y + 5 elif (param.m_type == "Enum"): button_width = 80 pen_x = pen_x + label_width + padding pen_y = pen_y - 5 menu = buildMenu(param.m_enum, param.m_default_enum) shader_params_menu[param.m_name] = Draw.Menu( menu, SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, int(stored_value), str(param.m_label)) pen_x = pen_x - label_width - padding pen_y = pen_y + 5 elif (param.m_type == "Vector"): button_width = 50 pen_y = pen_y - button_height - 5 v = n2exporter.StringToVector(stored_value) shader_params_menu[param.m_name + "_x"] = Draw.Number( "", SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, v.x, 0.0, 100.0, "x Component") pen_x = pen_x + button_width shader_params_menu[param.m_name + "_y"] = Draw.Number( "", SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, v.y, 0.0, 100.0, "y Component") pen_x = pen_x + button_width shader_params_menu[param.m_name + "_z"] = Draw.Number( "", SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, v.z, 0.0, 100.0, "z Component") pen_x = pen_x + button_width shader_params_menu[param.m_name + "_w"] = Draw.Number( "", SHADER_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, v.w, 0.0, 100.0, "w Component") pen_x = pen_x - ((button_width) * 3) elif (n2exporter.texture_param_types.has_key(param.m_type)): texture_param_list.append(param.m_name) # Build textures menu if (len(texture_param_list) > 0): if ((pen_y - button_height - padding) < button_height): pen_x = pen_x = pen_x + column_size pen_y = params_start_y button_width = 80 pen_y = pen_y - button_height - padding - 5 # texture_param_name = texture_param_list[texture_param_index] menu = buildMenu(texture_param_list) shader_params_menu["TextureParams"] = Draw.Menu( menu, TEXTURE_PARAM_CHANGED, pen_x, pen_y, button_width, button_height, texture_param_index, "Shader Textures") # Move Pen pen_x = pen_x + button_width + padding button_width = 160 default = n2mat.GetParamValue(texture_param_name) shader_params_menu[texture_param_name] = Draw.String( "", TEXTURE_PARAM_CLICKED, pen_x, pen_y, button_width, button_height, default, 255, "Texture Params") #Draw Browse button pen_x = pen_x + button_width button_width = 20 Draw.PushButton("...", TEXTURE_SELECT_CLICKED, pen_x, pen_y, button_width, button_height, "Select Texture") else: Draw.PupMenu("Error%t|You must have a blender material in the scene") Draw.Exit() return
def renderGUI(): """ Renders the GUI for the script. """ global G # find the selection set and update some selection # related flags haveEmpty = False haveCamera = False emptyName = "" G.selection = Object.GetSelected() G.curempty = None if G.selection is not None and len(G.selection) > 0: mso = G.selection[0] msotype = mso.getType() if msotype == 'Empty': haveEmpty = True G.curempty = mso emptyName = G.curempty.getName() elif msotype == 'Camera': haveCamera = True emptyHasCoords = G.coordmap.has_key(emptyName) removeUnknownsFromCoords() # clear any buttons that need to have set states G.buttons.add = G.buttons.delete = None # clear the window c = COLOR_BACKGROUND BGL.glClearColor(c[0], c[1], c[2], c[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # paint the image in the background if G.image is not None: #drawImage(G.image, G.imgpos, G.iw, G.ih, G.zoom) Draw.Image(G.image, G.imgpos[0], G.imgpos[1], G.zoom, G.zoom) # paint 2D vertices in the image BGL.glPushAttrib(BGL.GL_POINT_BIT | BGL.GL_CURRENT_BIT) BGL.glPointSize(POINT_SIZE) x0 = int(G.imgpos[0] / G.zoom) y0 = int(G.imgpos[1] / G.zoom) def drawvc(ec): emptyname, coord = ec if Object.Get(emptyname) in G.selection: c = COLOR_VERTSEL else: c = COLOR_VERTUNSEL BGL.glColor4f(c[0], c[1], c[2], c[3]) BGL.glVertex2f(G.zoom * (coord[0] + x0), G.zoom * (coord[1] + y0)) BGL.glBegin(BGL.GL_POINTS) map(drawvc, G.coordmap.items()) BGL.glEnd() BGL.glPopAttrib() # if we're in add mode then draw some extra stuff if G.mode == MODE_ADD: xm, ym = map(int, getWMCoords()) xm -= 10 ym += 10 (xw, yw, ww, hw) = getWinRect() # draw crosshairs c = COLOR_CROSSHAIRS BGL.glColor4f(c[0], c[1], c[2], c[3]) verts = [(xm, 0), (xm, hw), (0, ym), (ww, ym)] BGL.glBegin(BGL.GL_LINES) map(lambda x: BGL.glVertex2d(x[0], x[1]), verts) BGL.glEnd() ############################################# # UNCOMMENT THIS SECTION FOR A COOL MINIMAP # EFFECT - NOT VERY USEFUL THOUGH # ## draw "minimap" background #c = COLOR_MINIMAP #BGL.glColor4f(c[0], c[1], c[2], c[3]) #verts = [ (119,10), (221,10), (221,111), (119,111) ] #BGL.glBegin(BGL.GL_QUADS) #map(lambda x: BGL.glVertex2i(x[0],x[1]), verts) #BGL.glEnd() # ## paint the image into the minimap #ix,iy = wc2ic((xm,ym)) #ix,iy = map(int, [ix, iy]) #drawImage(G.ibuf, (120,10), G.iw, G.ih, 10.0, (ix-5,iy-5,10,10)) # # END OF MINIMAP SECTION ############################################# # paint the current empty name if haveEmpty: c = COLOR_TEXT BGL.glColor4d(c[0], c[1], c[2], c[3]) BGL.glRasterPos2i(220, 10) Draw.Text(emptyName, 'small') # paint the normal GUI buttons G.buttons.quit = Draw.PushButton('Quit', BUTTON_QUIT, 5, 5, 100, 20, 'Exits the script.') G.buttons.load = Draw.PushButton('Load Image', BUTTON_LOAD, 5, 25, 100, 20, 'Loads an image.') G.buttons.zoom = Draw.Number('Zoom', BUTTON_ZOOM, 5, 45, 100, 20, G.zoom, ZOOM_MIN, ZOOM_MAX, 'Adjusts image zoom.') # paint camera-specific stuff if haveCamera: G.buttons.fullopt = Draw.Toggle('Full Optimization', BUTTON_FULLOPT, 110, 5, 120, 20, G.fullopt, 'Full or partial optimization.') G.buttons.coplanar = Draw.Toggle('Coplanar', BUTTON_COPLANAR, 110, 25, 120, 20, G.coplanar, 'Coplanar or non-coplanar target.') # Origin offset is not currently working in the Tsai module. # It should be brought back here when it is. #G.buttons.ofsz = Draw.Number('OfsZ', BUTTON_OFSZ, 110, 50, 100, 20, G.ofsz, OFS_MIN, OFS_MAX, 'Z origin offset.') #G.buttons.ofsy = Draw.Number('OfsY', BUTTON_OFSY, 110, 70, 100, 20, G.ofsy, OFS_MIN, OFS_MAX, 'Y origin offset.') #G.buttons.ofsx = Draw.Number('OfsX', BUTTON_OFSX, 110, 90, 100, 20, G.ofsx, OFS_MIN, OFS_MAX, 'X origin offset.') G.buttons.calibrate = Draw.PushButton( 'Calibrate', BUTTON_CALIBRATE, 235, 5, 100, 20, 'Calibrates the selected camera.') # paint empty-specific stuff elif haveEmpty and (G.mode == MODE_NORMAL): if emptyHasCoords: G.buttons.delete = Draw.PushButton( 'Delete', BUTTON_DELETE, 110, 5, 100, 20, 'Adds an image calibration coordinate.') else: G.buttons.add = Draw.PushButton( 'Add', BUTTON_ADD, 110, 5, 100, 20, 'Removes an image calibration coordinate.')
def GUI(): global GUIPARAMS, PARAMS BGL.glClearColor(*(ScreenColor + [1.0])) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) minx = 5 maxx = 500 miny = 5 maxy = 450 lineheight = 24 buPad = 5 # Generic Button Padding, most buttons should have 24-19 (or 5) px space around them lP = 5 # Left Padding rP = 5 # Right Padding # Draw Background Box BGL.glColor3f(*BackgroundColor) BGL.glRecti(minx, miny, maxx, maxy) # Draw Title BGL.glColor3f(*TitleBG) BGL.glRecti(minx, maxy - (lineheight), maxx, maxy) BGL.glColor3f(*TitleCol) title = "2D Cutout Image Importer v" + VERSIONSTRING BGL.glRasterPos2i(minx + lP, maxy - 15) Draw.Text(title, 'large') Draw.PushButton('Exit', EXIT, maxx-50-rP, maxy - lineheight + 2, 50, 19, "Exit Script") # Path Buttons if GUIPARAMS['Path'].val == '': Draw.PushButton('Single Image', SINGLE_IMG, minx + lP, maxy - (2*lineheight), 150, 19, "Select a Single Image to Import") Draw.PushButton('Directory', DIRECTORY_IMG, minx + lP + 150, maxy - (2*lineheight), 150, 19, "Select a Directory of Images to Import") else: Draw.PushButton('Clear', CLR_PATH, minx+lP, maxy - (2*lineheight), 50, 19, "Clear Path and Change Import Options") GUIPARAMS['Path'] = Draw.String('Path: ', NO_EVT, minx + lP, maxy - (3*lineheight), (maxx-minx-lP-rP), 19, GUIPARAMS['Path'].val, 399, 'Path to Import From') if PARAMS['ImportType'] == DIR: GUIPARAMS['ImageExt'] = Draw.String('Image Ext: ', CHG_EXT, minx + lP, maxy - (4*lineheight), 110, 19, GUIPARAMS['ImageExt'].val, 6, 'Image extension for batch directory importing (case insensitive)') GUIPARAMS['PackImage'] = Draw.Toggle('Pack', NO_EVT, maxx - rP - 50, maxy - (4*lineheight), 50, 19, GUIPARAMS['PackImage'].val, 'Pack Image(s) into .Blend File') # Geometry and Viewport Options BGL.glColor3f(*TextCol) BGL.glRecti(minx+lP, maxy - (5*lineheight), maxx-rP, maxy - (5*lineheight) + 1) BGL.glRasterPos2i(minx + lP, maxy-(5*lineheight) + 3) Draw.Text('Geometry and Display Options', 'small') GUIPARAMS['PPU'] = Draw.Slider('Pixels Per Unit: ', NO_EVT, minx + lP, maxy - (6*lineheight), (maxx-minx)/2 - lP, 19, GUIPARAMS['PPU'].val, 1, 5000, 0, 'Set the Number of Pixels Per Blender Unit to preserve Image Size Relations') GUIPARAMS['VPTransp'] = Draw.Toggle('Viewport Transparency', NO_EVT, minx + lP, maxy - (8*lineheight), (maxx-minx)/2 - lP, 2*lineheight - buPad, GUIPARAMS['VPTransp'].val, 'Display Alpha Transparency in the Viewport') GUIPARAMS['XOff'] = Draw.Slider('Offs X: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (6*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['XOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the X-Direction if Importing Multiple Images') GUIPARAMS['YOff'] = Draw.Slider('Offs Y: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (7*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['YOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the Y-Direction if Importing Multiple Images') GUIPARAMS['ZOff'] = Draw.Slider('Offs Z: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (8*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['ZOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the Z-Direction if Importing Multiple Images') # Material and Texture Options BGL.glColor3f(*TextCol) BGL.glRecti(minx+lP, maxy - (9*lineheight), maxx-rP, maxy - (9*lineheight) + 1) BGL.glRasterPos2i(minx + lP, maxy-(9*lineheight) + 3) Draw.Text('Material and Texture Options', 'small') half = (maxx-minx-lP-rP)/2 GUIPARAMS['CopyMat'] = Draw.Toggle('Copy Existing Material', NO_EVT, minx + lP, maxy-(10*lineheight), half, 19, GUIPARAMS['CopyMat'].val, 'Copy an Existing Material') if GUIPARAMS['CopyMat'].val: menStr = compileMaterialList() GUIPARAMS['MatId'] = Draw.Menu(menStr, NO_EVT, minx + lP, maxy - (11*lineheight), half, 19, GUIPARAMS['MatId'].val, 'Material to Copy Settings From') else: GUIPARAMS['MatCol'] = Draw.ColorPicker(NO_EVT, minx+lP, maxy - (13*lineheight), 40, (3*lineheight) - buPad, GUIPARAMS['MatCol'].val, 'Color of Newly Created Material') GUIPARAMS['Ref'] = Draw.Slider('Ref: ', NO_EVT, minx +lP+45, maxy - (11*lineheight), half-45, 19, GUIPARAMS['Ref'].val, 0.0, 1.0, 0, 'Set the Ref Value for Created Materials') GUIPARAMS['Spec'] = Draw.Slider('Spec: ', NO_EVT, minx +lP+45, maxy - (12*lineheight), half-45, 19, GUIPARAMS['Spec'].val, 0.0, 2.0, 0, 'Set the Spec Value for Created Materials') GUIPARAMS['Hard'] = Draw.Slider('Hard: ', NO_EVT, minx +lP+45, maxy - (13*lineheight), half-45, 19, GUIPARAMS['Hard'].val, 1, 500, 0, 'Set the Hardness Value for Created Materials') GUIPARAMS['Alpha'] = Draw.Slider('A: ', NO_EVT, minx +lP, maxy - (14*lineheight), half, 19, GUIPARAMS['Alpha'].val, 0.0, 1.0, 0, 'Set the Alpha Value for Created Materials') GUIPARAMS['ZTransp'] = Draw.Toggle('ZTransparency', NO_EVT, minx + lP, maxy - (15*lineheight), half, 19, GUIPARAMS['ZTransp'].val, 'Enable ZTransparency') GUIPARAMS['Shadeless'] = Draw.Toggle('Shadeless', NO_EVT, minx + lP, maxy - (16*lineheight), half, 19, GUIPARAMS['Shadeless'].val, 'Enable Shadeless') GUIPARAMS['TexChan'] = Draw.Number('Texture Channel: ', NO_EVT, minx + lP+ half + buPad, maxy - (10*lineheight), half-rP, 19, GUIPARAMS['TexChan'].val, 1, 10, 'Texture Channel for Image Texture') GUIPARAMS['MPTCol'] = Draw.Toggle('Color', NO_EVT, minx + lP + half + buPad, maxy - (11*lineheight), half/2, 19, GUIPARAMS['MPTCol'].val, 'Map To Color Channel') GUIPARAMS['MPTAlpha'] = Draw.Toggle('Alpha', NO_EVT, minx + lP + int((1.5)*half) + buPad, maxy - (11*lineheight), half/2 - rP, 19, GUIPARAMS['MPTAlpha'].val, 'Map To Alpha Channel') third = int((maxx-minx-lP-rP)/6) GUIPARAMS['UseAlpha'] = Draw.Toggle('Use Alpha', NO_EVT, minx + lP + half + buPad, maxy - (12*lineheight), third, 19, GUIPARAMS['UseAlpha'].val, "Use the Images' Alpha Values") GUIPARAMS['CalcAlpha'] = Draw.Toggle('Calc Alpha', NO_EVT, minx + lP + half + third + buPad, maxy - (12*lineheight), third, 19, GUIPARAMS['CalcAlpha'].val, "Calculate Images' Alpha Values") GUIPARAMS['ExtendMode'] = Draw.Toggle('Extend', NO_EVT, minx+lP+half+third+third+buPad, maxy - (12*lineheight), third-3, 19, GUIPARAMS['ExtendMode'].val, "Use Extend texture mode. If deselected, Repeat is used") GUIPARAMS['Seq'] = Draw.Toggle('Sequence', NO_EVT, minx + lP + half + buPad, maxy - (13*lineheight), half-rP, 19, GUIPARAMS['Seq'].val, 'Set the Image(s) to use a Sequence instead of a Still') if GUIPARAMS['Seq'].val and not PARAMS['ImportType'] == DIR: GUIPARAMS['AutoRefresh'] = Draw.Toggle('Auto Refresh', NO_EVT, minx + lP + half + buPad, maxy - (14*lineheight), half/2, 19, GUIPARAMS['AutoRefresh'].val, 'Use Auto Refresh') GUIPARAMS['Cyclic'] = Draw.Toggle('Cyclic', NO_EVT, minx + lP + half + buPad + half/2, maxy - (14*lineheight), half/2 - rP, 19, GUIPARAMS['Cyclic'].val, 'Repeat Frames Cyclically`') GUIPARAMS['Frames'] = Draw.Number('Frames: ', NO_EVT, minx +lP + half + buPad, maxy - (15*lineheight), half - rP, 19, GUIPARAMS['Frames'].val, 1, 30000, 'Sets the Number of Images of a Movie to Use') GUIPARAMS['Offs'] = Draw.Number('Offs: ', NO_EVT, minx +lP + half + buPad, maxy - (16*lineheight), half/2, 19, GUIPARAMS['Offs'].val, -30000, 30000, 'Offsets the Number of the Frame to use in the Animation') GUIPARAMS['StartFr'] = Draw.Number('StartFr: ', NO_EVT, minx +lP + half + buPad + half/2, maxy - (16*lineheight), half/2 - rP, 19, GUIPARAMS['StartFr'].val, 1, 30000, 'Sets the Global Starting Frame of the Movie') elif GUIPARAMS['Seq'].val and PARAMS['ImportType'] == DIR: BGL.glColor3f(*ErrCol) BGL.glRasterPos2i(minx + lP + half + buPad + 7, maxy-(14 * lineheight) + 5) Draw.Text('Sequence only available for Single Image Import', 'small') # Import Options BGL.glColor3f(*TextCol) BGL.glRecti(minx+lP, maxy - (17*lineheight), maxx-rP, maxy - (17*lineheight) + 1) BGL.glRasterPos2i(minx + lP, maxy-(17*lineheight) + 3) Draw.Text('Import', 'small') if GUIPARAMS['Path'].val and GUIPARAMS['ImageExt'].val or GUIPARAMS['Path'].val and PARAMS['ImportType'] == SINGLE: Draw.PushButton('Import', DO_SCRIPT, minx + lP, maxy - (18*lineheight), 75, 19, "Import Image(s)") else: BGL.glColor3f(*ErrCol) BGL.glRasterPos2i(minx+lP, maxy - (18*lineheight) + 5) Draw.Text('A path and image type must be specified to import images') GUIPARAMS['RedrawImp'] = Draw.Toggle('Redraw During Import', NO_EVT, maxx - rP - 150, maxy - (18*lineheight), 150, 19, GUIPARAMS['RedrawImp'].val, 'Redraw the View as Images Import')
def draw(): win_size = Window.GetAreaSize() left = 0 top = win_size[1] button_width = 180 button_height = 20 label_width = 105 pen_x = left + padding pen_y = win_size[1] - (button_height + padding) # Draw Label BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text('Nebula Home Dir') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 # Draw String Button home_dir_input = Draw.String("", HOME_DIR_CHANGED, pen_x, pen_y, button_width, button_height, config_data["home"], 255, "Nebula's Home Directory") pen_x = pen_x + button_width button_width = 20 Draw.PushButton("...", BROWSE_HOME_CLICKED, pen_x, pen_y, button_width, button_height, "Browse for Nebula Home Directory") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 180 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) Draw.Text('Project Dir') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 # Draw String Button proj_dir_input = Draw.String("", PROJ_DIR_CHANGED, pen_x, pen_y, button_width, button_height, config_data["proj"], 255, "Projetct Directory") pen_x = pen_x + button_width button_width = 20 Draw.PushButton("...", BROWSE_PROJ_CLICKED, pen_x, pen_y, button_width, button_height, "Browse for Project Directory") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 150 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) Draw.Text('Export Dir') # Draw String Button pen_x = pen_x + label_width pen_y = pen_y - 5 dir_assigns["export"] = Draw.String("", ASSIGN_DIR_CHANGED, pen_x, pen_y, button_width, button_height, config_data["export"], 255, "Export Directory") pen_y = pen_y + 5 for data in config_data: if (data != "home" and data != "export" and data != "texture_dir" and data != "proj"): # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 # Draw Label BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text(data) # Draw Button pen_x = pen_x + label_width pen_y = pen_y - 5 dir_assigns[data] = Draw.String("", ASSIGN_DIR_CHANGED, pen_x, pen_y, button_width, button_height, config_data[data], 255, "Assign") pen_y = pen_y + 5 # Draw OK Cancel Buttons button_width = 100 pen_x = left + padding pen_y = pen_y - button_height - 5 - padding Draw.PushButton("Cancel", CANCEL_CLICKED, pen_x, pen_y, button_width, button_height, "Cancel Configuration") pen_x = pen_x + button_width + padding Draw.PushButton("OK", OK_CLICKED, pen_x, pen_y, button_width, button_height, "Save Configuration")
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()
def gui(): # основна¤ функци¤ Draw.PushButton("Push",2,50,10,55,20,"Our push") # создание кнопки с
def draw(): global mnu_persist_servers, mnu_mesh_formats, mnu_width, mnu_height, mnu_fullscreen, mnu_renderpath, mnu_group, mnu_filename, mnu_aa win_size = Window.GetAreaSize() left = 0 top = win_size[1] button_width = 130 button_height = 20 label_width = 105 pen_x = left + padding pen_y = win_size[1] - (button_height + padding) # Draw Label BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text('Persist Server') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 # Draw Persist Server Menu mnu_persist_servers = Draw.Menu(buildMenu(persist_servers), PERSIST_SERVER_CHANGED, pen_x, pen_y, button_width, button_height, persist_server, "Persist Server to use") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 180 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) Draw.Text('Mesh Format') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 button_width = 80 # Draw Mesh Format Menu mnu_mesh_formats = Draw.Menu(buildMenu(mesh_formats), MESH_FORMAT_CHANGED, pen_x, pen_y, button_width, button_height, mesh_format, "Mesh Format to use(ASCII/Binary)") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 180 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text('Preview Window') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 button_width = 100 mnu_width = Draw.Number("Width", WIDTH_CHANGED, pen_x, pen_y, button_width, button_height, window_width, 32, 2048, "Preview Window Width") # Move Pen Point pen_x = pen_x + button_width + padding mnu_height = Draw.Number("Height", HEIGHT_CHANGED, pen_x, pen_y, button_width, button_height, window_height, 32, 2048, "Preview Window Height") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text('Preview Fullscreen') button_width = 20 # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 mnu_fullscreen = Draw.Toggle("X", FULLSCREEN_CHANGED, pen_x, pen_y, button_width, button_height, fullscreen, "Preview Fullscreen") # Move Pen Point pen_x = pen_x + button_width + padding pen_y = pen_y + 5 button_width = 180 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) Draw.Text('Antialias Samples') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 button_width = 40 # Draw Mesh Format Menu mnu_aa = Draw.Menu(buildMenu(aasamples), AA_CHANGED, pen_x, pen_y, button_width, button_height, aa, "Antialias Samples") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 180 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) text_width = Draw.Text('Export Group / filename') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 button_width = 80 mnu_group = Draw.String("", GROUP_CHANGED, pen_x, pen_y, button_width, button_height, group, 255, "Export Group") # Move Pen Point pen_x = pen_x + button_width + padding mnu_filename = Draw.String("", FILENAME_CHANGED, pen_x, pen_y, button_width, button_height, filename, 255, "Export Filename") # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 button_width = 100 # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(pen_x, pen_y) Draw.Text('Preview Renderpath') # Move Pen Point pen_x = pen_x + text_width + padding pen_y = pen_y - 5 button_width = 60 mnu_renderpath = Draw.Menu(buildMenu(renderpaths), RENDERPATH_CHANGED, pen_x, pen_y, button_width, button_height, renderpath, "Renderpath to use for preview") # Move Pen Point pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 80 Draw.PushButton("Close", CANCEL_CLICKED, pen_x, pen_y, button_width, button_height, "Close Exporter") pen_x = pen_x + button_width + padding Draw.PushButton("Export", OK_CLICKED, pen_x, pen_y, button_width, button_height, "Export Scene")