def dotext(self): ## By default this function prints the desired text, in the desired colour centrally in the panel. ## Possibly there will be more options in a leter release. ## Find the vertical centreline of the panel. centreline=self.left+(self.width/2) ## Find the horizontal centreline of the panel and subtract about half the height of the font (roughly). textline=self.base+(self.height/2-5) ## Find the length of the string that was passed in. stringlength=Draw.GetStringWidth(self.text) ## Halve it. offset=stringlength/2 ## Calculate the start point for the text. titlestart=centreline-offset ## Change to the text colour. BGL.glColor3f(self.textcolour[0],self.textcolour[1],self.textcolour[2]) ## Position raster. BGL.glRasterPos2i(titlestart,textline) ## Print it. Draw.Text(self.text)
def bad_draw(): global _gui_edge_length_button, _gui_edge_angle_button, _gui_edge_weld_button try: BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glRasterPos2d(8, 40) Draw.Text('Blender Assisted Design', 'large') _gui_edge_length_button = Draw.Number('Edge length: ', GUI_EDGE_LENGTH, 8, 8, 200, 24, _gui_edge_length, 0.0, 1000.0, bad_set_length.__doc__) Draw.PushButton( 'Set', 0, 214, 8, 40, 24, bad_set_length.__doc__, lambda *a: bad_script_call(bad_script_set_length, float(_gui_edge_length)) ) _gui_edge_angle_button = Draw.Number('Edge angle: ', GUI_EDGE_ANGLE, 270, 8, 200, 24, _gui_edge_angle, 0.0, 180.0, bad_set_angle.__doc__) Draw.PushButton( 'Set', 0, 476, 8, 40, 24, bad_set_angle.__doc__, lambda *a: bad_script_call(bad_script_set_angle, float(_gui_edge_angle)) ) Draw.PushButton( 'Weld', 0, 534, 8, 50, 24, bad_weld_edges.__doc__, lambda *a: bad_script_call(bad_script_weld) ) except Exception, e: print e Draw.Exit()
def gui(): BGL.glClearColor(1,1,1,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # idle Draw.Label("Idle-Animation:", 10,200,180,20) Draw.Number("von ", 1, 10,180,90,20,idleStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 2, 110,180,90,20,idleEndFrame,0,1000, "", button_event, 1,1) # move Draw.Label("Move-Animation:", 10,150,180,20) Draw.Number("von ", 3, 10,130,90,20,moveStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 4, 110,130,90,20,moveEndFrame,0,1000, "", button_event, 1,1) # attack Draw.Label("Attack-Animation:", 10,90,180,20) Draw.Number("von ", 5, 10,70,90,20,attackStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 6, 110,70,90,20,attackEndFrame,0,1000, "", button_event, 1,1) # die Draw.Label("Die-Animation:", 10,40,180,20) Draw.Number("von ", 7, 10,20,90,20,dieStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 8, 110,20,90,20,dieEndFrame,0,1000, "", button_event, 1,1) # RENDER-Button: Draw.Button("RENDER", 9, 230,30,80,20, "RENDER!", renderButtonClicked)
def doDraw(self): # this has black color... # Draw.Label(self.title, # self.pos_x, self.pos_y, self.width, self.height) BGL.glColor3f(*self.color) BGL.glRasterPos2i(self.pos_x, self.pos_y) Draw.Text(self.title + self.button.val)
def gui_masse_volumique(): # Création d'Id pour les évènements nCpt_evt = 1 global EV_BT_OK EV_BT_OK = nCpt_evt; nCpt_evt += 1 global EV_BT_ANNULER EV_BT_ANNULER = nCpt_evt; nCpt_evt += 1 global EV_MASS_VOL EV_MASS_VOL = nCpt_evt; nCpt_evt += 1 pos_x = 5 pos_y = 100; pas_y = 36 BGL.glRasterPos2i( pos_x, pos_y ) Draw.Text("Choisissez la masse volumique du maillage (et validez par \"OK\") :") #[nom bouton] = Draw.Number("[nom]", [numéro d'événement], [position x], [position y], \ # [largeur], [hauteur], \ # [valeur initiale], [valeur minimale],[valeur maximale], "[astuce]") global bt_masse_volumique largeur_mv = 360 hauteur = 25 pos_y -= pas_y bt_masse_volumique = Draw.Number("Masse volumique :", EV_MASS_VOL, pos_x, pos_y, \ largeur_mv, hauteur, \ 1.0, 0.0, 100000.0, "saisissez la masse volumique") largeur_bt = 80 pos_y -= pas_y dx_espacement = int( ( largeur_mv - 2.0 * largeur_bt ) / 3.0 ) dx_espacement = int( dx_espacement + 0.5 ) pos_x_bt_OK = pos_x + dx_espacement pos_x_bt_Annuler = pos_x_bt_OK + largeur_bt + dx_espacement Draw.PushButton("OK", EV_BT_OK, pos_x_bt_OK, pos_y, largeur_bt, hauteur, "Valide") Draw.PushButton("Annuler", EV_BT_ANNULER, pos_x_bt_Annuler, pos_y, largeur_bt, hauteur, "Annule")
def drawAA(): global MINAA, MAXAA, AASAMPLES global IMGFILTERW, IMGFILTERH, IMGFILTER global EXP_ANIM ## aa settings col = 10 line = 200 BGL.glRasterPos2i(col, line) Draw.Text("AA:") col = 100 MINAA = Draw.Number("Min AA ", 2, col, line, 120, 18, MINAA.val, -4, 5) col = 230 MAXAA = Draw.Number("Max AA ", 2, col, line, 120, 18, MAXAA.val, -4, 5) col = 360 AASAMPLES = Draw.Number("Samples", 2, col, line, 120, 18, AASAMPLES.val, 0, 32) col = 10 line = 175 BGL.glRasterPos2i(col, line) Draw.Text("Image Filter:") col = 100 line = 173 IMGFILTER = Draw.Menu( "%tImage Filter|box|gaussian|mitchell|triangle|catmull-rom|blackman-harris|sinc|lanczos", FILTER_EVENT, col, line, 120, 18, IMGFILTER.val) col = 10 line = 120 EXP_ANIM = Draw.Toggle("Export As Animation", 2, col, line, 140, 18, EXP_ANIM.val) drawButtons()
def DrawDialog(self): """Should be passed as the 'draw' argument to Blender.Draw.Register(). Defines how the dialog should be drawn on every redraw.""" BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) #BGL.glEnable(BGL.GL_BLEND) #BGL.glBlendFunc( # BGL.GL_SRC_ALPHA, # BGL.GL_ONE_MINUS_SRC_ALPHA #) BGL.glRasterPos2d(self.column(1), self.line(0)) Draw.Text('PySoy importer', 'large') self.importfile = Draw.String('Import from: ', self.EVENT_IMPORTFROM, self.column(1), self.line(2), self.width(30), self.height(1), self.filepathSTR, 399, 'Import an element from this file') self.importfilebutton = Draw.PushButton('Set import file', self.EVENT_SETIMPORT, self.column(31), self.line(2), self.width(10), self.height(1), 'Set file to import from') if self.fileselected == True: self.importmenu = Draw.Menu('Import element:%t|Mesh|Material|Entity|Node', self.EVENT_IMPORTMENU, self.column(1), self.line(4), self.width(10), self.height(1), 1, 'Select element from file to import')
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))
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))
def gui(self,): quitbutton = Blender.Draw.Button("Exit", 1, 0, 0, 100, 20, "Close Window") y=35 for line in self.msg: BGL.glRasterPos2i(10,y) Blender.Draw.Text(line) y+=15
def drawLights(): global MESHLIGHTPOWER, DSAMPLES ## meshlight power slider col=10; line=200; BGL.glRasterPos2i(col, line); Draw.Text("Meshlight:") col=100; line=195; MESHLIGHTPOWER=Draw.Number("Power", 2, col, line, 120, 18, MESHLIGHTPOWER.val, 1, 15) ## lightserver settings col=10; line=150; BGL.glRasterPos2i(col, line); Draw.Text("Lightserver:") col=100; line=147; DSAMPLES=Draw.Number("Direct Samples ", 2, col, line, 250, 18, DSAMPLES.val, 0, 1024); drawButtons()
def drawCamera(): global DOF, DOFRADIUS, DOFDIST, SPHERICALCAMERA ## camera settings col=10; line=200; BGL.glRasterPos2i(col, line); Draw.Text("Camera:") col=100; line=195; DOF=Draw.Toggle("DOF", DOF_CAMERA, col, line, 120, 18, DOF.val) col=225; DOFDIST=Draw.Number("Distance", 2, col, line, 120, 18, DOFDIST.val, 0.0, 200.00) col=350; DOFRADIUS=Draw.Number("Radius", 2, col, line, 120, 18, DOFRADIUS.val, 0.0, 200.00) col=100; line=170; SPHERICALCAMERA=Draw.Toggle("Spherical", SPHER_CAMERA, col, line, 120, 18, SPHERICALCAMERA.val) drawButtons()
def getWinRect(): """ Returns the rectangle of the current script window in screen coordinates. @return: Script window rectangle: [x, y, w, h] """ winrect = BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, winrect) return winrect.list
def drawAO(): global OCCLUSSION, OCCBRIGHTR, OCCBRIGHTG, OCCBRIGHTB, OCCDARKR, OCCDARKG, OCCDARKB, OCCSAMPLES, OCCDIST col=10; line=200; BGL.glRasterPos2i(col, line); Draw.Text("Ambient Occlusion") col=10; line=175; OCCLUSSION=Draw.Toggle("Amb Occ", 2, col, line, 85, 18, OCCLUSSION.val) col=100; OCCBRIGHTR=Draw.Number("Bright (R)", 2, col, line, 125, 18, OCCBRIGHTR.val, 0.0, 1.0) col=230; OCCBRIGHTG=Draw.Number("Bright (G)", 2, col, line, 125, 18, OCCBRIGHTG.val, 0.0, 1.0) col=360; OCCBRIGHTB=Draw.Number("Bright (B)", 2, col, line, 125, 18, OCCBRIGHTB.val, 0.0, 1.0) col=100; line=150; OCCDARKR=Draw.Number("Dark (R)", 2, col, line, 125, 18, OCCDARKR.val, 0.00, 1.0) col=230; OCCDARKG=Draw.Number("Dark (G)", 2, col, line, 125, 18, OCCDARKG.val, 0.0, 1.0) col=360; OCCDARKB=Draw.Number("Dark (B)", 2, col, line, 125, 18, OCCDARKB.val, 0.0, 1.0) col=100; line=125; OCCSAMPLES=Draw.Number("Samples", 2, col, line, 125, 18, OCCSAMPLES.val, 0, 256) col=230; OCCDIST=Draw.Number("Distance", 2, col, line, 125, 18, OCCDIST.val, -1.0, 150.0) drawButtons()
def drawAA(): global MINAA, MAXAA, AASAMPLES global IMGFILTERW, IMGFILTERH, IMGFILTER global EXP_ANIM ## aa settings col=10; line=200; BGL.glRasterPos2i(col, line); Draw.Text("AA:") col=100; MINAA=Draw.Number("Min AA ", 2, col, line, 120, 18, MINAA.val, -4, 5); col=230; MAXAA=Draw.Number("Max AA ", 2, col, line, 120, 18, MAXAA.val, -4, 5) col=360; AASAMPLES=Draw.Number("Samples", 2, col, line, 120, 18, AASAMPLES.val, 0, 32) col=10; line=175; BGL.glRasterPos2i(col, line); Draw.Text("Image Filter:") col=100; line=173; IMGFILTER=Draw.Menu("%tImage Filter|box|gaussian|mitchell|triangle|catmull-rom|blackman-harris|sinc|lanczos", FILTER_EVENT, col, line, 120, 18, IMGFILTER.val) col=10; line=120; EXP_ANIM=Draw.Toggle("Export As Animation", 2, col, line, 140, 18, EXP_ANIM.val) drawButtons()
def Create_Tab(X1,Y1,X2,Y2,Title,Buttons): # X1,Y1 = Top Left X2,Y2 = Bottom Right """ Create a bordered tab/frame/box with the given top left corner (X1,Y1) and bottom right corner (X2, Y2) with the given Title and Buttons. """ TITLE_HEIGHT = 15 INDENT = 6 BUTTON_GAP = 4 BGL.glColor3f(0.75, 0.75, 0.75) BGL.glRecti(X1,Y1,X2,Y2) Draw_Border(X1,Y1,X2,Y2); BGL.glColor3f(0.0,0.0,0.0) BGL.glRasterPos2d(X1+INDENT,Y1 - TITLE_HEIGHT) Draw.Text(Title) BUTTON_HEIGHT = 18 Button_X = X1 + INDENT Button_Y = Y1 - TITLE_HEIGHT - BUTTON_HEIGHT - 8 if (Buttons != 0): key= Buttons.keys() BUTTON_WIDTH = (X2 - (X1 + INDENT + BUTTON_GAP + INDENT)) / len(key) for k in key: Buttons[k][0]= Draw.Toggle(k,Buttons[k][1],Button_X,Button_Y, BUTTON_WIDTH,BUTTON_HEIGHT,Buttons[k][0].val,Buttons[k][2]) Button_X += BUTTON_WIDTH + BUTTON_GAP
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 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(self): BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) height = 32 y_pos = 10 quit_text = "Quit" Draw.Button(quit_text, self.EVENT_EXIT, 10, y_pos, 2 * Draw.GetStringWidth(quit_text), height, "Quit script") y_pos += int(height * 1.5) render_text = "Render" Draw.Button(render_text, self.EVENT_RENDER, 10, y_pos, 2 * Draw.GetStringWidth(render_text), height, "Render scene to output") y_pos += int(height * 1.5) file_chooser_text = "..." Draw.Button(file_chooser_text, self.EVENT_FILECHOOSER, 10, y_pos, 2 * Draw.GetStringWidth(file_chooser_text), height, "Select file from file system") Draw.String("Output: ", self.EVENT_NONE, 2*Draw.GetStringWidth(file_chooser_text) + 10, y_pos, 256, height, self._get_output(), 399, "Name of output file", self._output_input_callback)
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 drawCamera(): global DOF, DOFRADIUS, DOFDIST, SPHERICALCAMERA ## camera settings col = 10 line = 200 BGL.glRasterPos2i(col, line) Draw.Text("Camera:") col = 100 line = 195 DOF = Draw.Toggle("DOF", DOF_CAMERA, col, line, 120, 18, DOF.val) col = 225 DOFDIST = Draw.Number("Distance", 2, col, line, 120, 18, DOFDIST.val, 0.0, 200.00) col = 350 DOFRADIUS = Draw.Number("Radius", 2, col, line, 120, 18, DOFRADIUS.val, 0.0, 200.00) col = 100 line = 170 SPHERICALCAMERA = Draw.Toggle("Spherical", SPHER_CAMERA, col, line, 120, 18, SPHERICALCAMERA.val) drawButtons()
def drawLights(): global MESHLIGHTPOWER, DSAMPLES ## meshlight power slider col = 10 line = 200 BGL.glRasterPos2i(col, line) Draw.Text("Meshlight:") col = 100 line = 195 MESHLIGHTPOWER = Draw.Number("Power", 2, col, line, 120, 18, MESHLIGHTPOWER.val, 1, 15) ## lightserver settings col = 10 line = 150 BGL.glRasterPos2i(col, line) Draw.Text("Lightserver:") col = 100 line = 147 DSAMPLES = Draw.Number("Direct Samples ", 2, col, line, 250, 18, DSAMPLES.val, 0, 1024) drawButtons()
def updateStatus(status): global gStatus gStatus = status BGL.glClearColor(0.392,0.396,0.549,1) BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) size = Blender.Window.GetAreaSize() isize = drawHeader(size) BGL.glColor3f(1.0,1.0,1.0) yval = size[1]-isize[1] - 40 Blender.BGL.glRasterPos2i(60, yval) Blender.Draw.Text('Status:','normal') if type(gStatus) == types.ListType: for s in gStatus: Blender.BGL.glRasterPos2i(105, yval) Blender.Draw.Text(s,'normal') yval = yval - 18 else: Blender.BGL.glRasterPos2i(105, yval) Blender.Draw.Text(gStatus,'normal') yval = yval - 18 Blender.Redraw()
def __init__(self, background): ## Basic background colour. BGL.glClearColor(background[0],background[1],background[2],background[3]) ## Clear the OpenGL script window to background colour. BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) ## Create a buffer space for the values we're after. scissorbox=BGL.Buffer(BGL.GL_FLOAT,4) ## Get the openGL window size values. BGL.glGetFloatv(BGL.GL_SCISSOR_BOX,scissorbox) ## The scissorbox values are floats, so we change them to integers. This prevents protests from Python about "int expected". ## The left and base values are mainly used to calculate the position of the mouse x and y values. # Left side of the OpenGL script window. Value is in pixels, from the left side of the main Blender window. self.left=int(scissorbox[0]) # Bottom of the OpenGL script window.Value is in pixels, up from the bottom of the main Blender window. self.base=int(scissorbox[1]) # Width of the OpenGL script window. self.width=int(scissorbox[2]) # Height of the OpenGL script window. self.height=int(scissorbox[3])
def drawHeader(size): sver = 'v' + iUtils.iversion try: bheight=10 boffset = 8 logoImage = Blender.Image.Load(scriptsLocation + 'irrblend.png') isize = logoImage.getSize() BGL.glColor3f(0.8,0.8,0.8) BGL.glRectd(11+isize[0],size[1]-bheight-boffset,size[0]-5, size[1]-boffset) Blender.BGL.glEnable(Blender.BGL.GL_BLEND ) Blender.BGL.glBlendFunc(Blender.BGL.GL_SRC_ALPHA, Blender.BGL.GL_ONE_MINUS_SRC_ALPHA) Blender.Draw.Image(logoImage, 6, size[1]-isize[1]-5) Blender.BGL.glDisable(Blender.BGL.GL_BLEND) Blender.BGL.glRasterPos2i(183, size[1]-33) Blender.Draw.Text(sver,'normal') except IOError: BGL.glColor3f(1.0,1.0,1.0) Blender.BGL.glRasterPos2i(45, size[1]-30) Blender.Draw.Text('Irrlicht Plugin for Blender - ' + sver, 'large') isize = [256,75] return isize
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 drawAO(): global OCCLUSSION, OCCBRIGHTR, OCCBRIGHTG, OCCBRIGHTB, OCCDARKR, OCCDARKG, OCCDARKB, OCCSAMPLES, OCCDIST col = 10 line = 200 BGL.glRasterPos2i(col, line) Draw.Text("Ambient Occlusion") col = 10 line = 175 OCCLUSSION = Draw.Toggle("Amb Occ", 2, col, line, 85, 18, OCCLUSSION.val) col = 100 OCCBRIGHTR = Draw.Number("Bright (R)", 2, col, line, 125, 18, OCCBRIGHTR.val, 0.0, 1.0) col = 230 OCCBRIGHTG = Draw.Number("Bright (G)", 2, col, line, 125, 18, OCCBRIGHTG.val, 0.0, 1.0) col = 360 OCCBRIGHTB = Draw.Number("Bright (B)", 2, col, line, 125, 18, OCCBRIGHTB.val, 0.0, 1.0) col = 100 line = 150 OCCDARKR = Draw.Number("Dark (R)", 2, col, line, 125, 18, OCCDARKR.val, 0.00, 1.0) col = 230 OCCDARKG = Draw.Number("Dark (G)", 2, col, line, 125, 18, OCCDARKG.val, 0.0, 1.0) col = 360 OCCDARKB = Draw.Number("Dark (B)", 2, col, line, 125, 18, OCCDARKB.val, 0.0, 1.0) col = 100 line = 125 OCCSAMPLES = Draw.Number("Samples", 2, col, line, 125, 18, OCCSAMPLES.val, 0, 256) col = 230 OCCDIST = Draw.Number("Distance", 2, col, line, 125, 18, OCCDIST.val, -1.0, 150.0) drawButtons()
def displayWarnings(): BGL.glClearColor(0.392,0.396,0.549,1) BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) size = Blender.Window.GetAreaSize() isize = drawHeader(size) BGL.glColor3f(1.0,1.0,0.0) yval = size[1]-isize[1] - 40 Blender.BGL.glRasterPos2i(50, yval) Blender.Draw.Text('Warnings:','normal') BGL.glColor3f(1.0,1.0,1.0) for s in gWarnings: Blender.BGL.glRasterPos2i(115, yval) Blender.Draw.Text(s,'normal') yval = yval - 18 Blender.Draw.PushButton('Back', ID_BACK, 105, 10, 100, 20, 'Back To Exporter')
def gui(): global active_object, file_str, local_toggle, global_toggle, all_to_triangle my_export_button = Draw.PushButton("Export", 3, 100, 50, 70, 20, "Export active object to selected file.") # my_local_toggle = Draw.Toggle("local coordinates", 0, 100, 100, 150, 20, local_toggle, "When selected local mesh coordinates will be exported.") # my_global_toggle = Draw.Toggle("global coordinates", 1, 250, 100, 150, 20, global_toggle, "When selected global mesh coordinates will be exported.") # my_triangles_toggle = Draw.Toggle("Quads to Triangles", 5, 100, 75, 150, 20, all_to_triangle, "When selected all faces will be transformed to triangles.") # BGL.glRasterPos2i(255, 80) # Draw.Text("!! THIS WILL ALTER YOUR OBJECT !!", "normal") my_file_choose_btn = Draw.PushButton("Choose file", 2, 100, 150, 120, 20, "Click here to select a file to save to") my_exit_btn = Draw.PushButton("Exit", 4, 200, 50, 70, 20, "Click here to abort and exit.") BGL.glRasterPos2i(230, 155) Draw.Text(file_str, "normal") BGL.glRasterPos2i(100, 175) Draw.Text("Selected object:", "normal") BGL.glRasterPos2i(230, 175) Draw.Text(active_object.name, "normal")
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 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 draw_text(text, x, y): BGL.glRasterPos2f(x, y) return Draw.Text(text)
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 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(self): area = Window.GetAreaSize() w = area[0]; wPad = int(w*0.03) h = area[1]; hPad = int(h*0.03) BGL.glColor3f(0.3, 0.3, 0.3) BGL.glRectf(wPad-5, h-60, w-wPad+5, h-85) BGL.glColor3f(1.0,1.0,1.0) BGL.glRasterPos2i(wPad, h-75) Draw.Text('Chicken Configuration script', 'large') BGL.glRasterPos2i(wPad, h-100) Draw.Text('This script is launched the first time you run Chicken, or when a configuration error has been detected') BGL.glColor3f(0.5, 0.5, 0.5) BGL.glRectf(wPad, h-205, w-wPad, h-225) BGL.glColor3f(1.0,1.0,1.0) BGL.glRasterPos2i(wPad, h-220) Draw.Text('Binary Utilities - ') Draw.Text('if executables such as "pview" are on your PATH, you can leave this on Auto. Otherwise enter the folder manually') self.bBinPathAuto.update([wPad+5, h-250, w/2-wPad-5, 20]) self.bBinPathManual.update([w/2, h-250, w/2-wPad-5, 20]) if self.bBinPathManual.val: self.bBinPath.update([wPad+5, h-272, w-2*wPad-90, 20]) self.bBinPathSel.update([w-wPad-85, h-272, 80, 20]) self.bLaunch.update([wPad+5, h-330, 100, 20]) self.bCheck.update([w-wPad-85, h-330, 80, 20]) if self.error is not None: if self.error is True: BGL.glColor3f(1.0,0.0,0.0) BGL.glRasterPos2i(w-wPad-150, h-365) Draw.Text('Configuration error detected') else: BGL.glColor3f(0.0,0.0,0.0) BGL.glRasterPos2i(w-wPad-200, h-365) Draw.Text('Configuration checked and saved')
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 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 Draw_Border(X1,Y1,X2,Y2): # X1,Y1 = Top Left X2,Y2 = Bottom Right """ Draw a border given a top left corner (X1, X2) and bottom right (X2, Y2) """ INDENT = 3 BGL.glColor3f(1.0,1.0,1.0) BGL.glBegin(BGL.GL_LINES) BGL.glVertex2i(X1+INDENT,Y1-INDENT) #top line BGL.glVertex2i(X2-INDENT,Y1-INDENT) BGL.glVertex2i(X1+INDENT,Y1-INDENT) #left line BGL.glVertex2i(X1+INDENT,Y2+INDENT) BGL.glEnd() BGL.glColor3f(0.5,0.5,0.5) BGL.glBegin(BGL.GL_LINES) BGL.glVertex2i(X2-INDENT,Y1-INDENT) #Right line BGL.glVertex2i(X2-INDENT,Y2+INDENT) BGL.glVertex2i(X1+INDENT,Y2+INDENT) #bottom line BGL.glVertex2i(X2-INDENT,Y2+INDENT) BGL.glEnd()
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 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 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")
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 gui(): # function drawing in screen BGL.glRasterPos2i(10, 230) # установка позиции Draw.Text("Type letters from a to z, ESC to leave.") BGL.glRasterPos2i(20, 200) Draw.Text(mystring)
def draw(self): area = Window.GetAreaSize() w = area[0] wPad = int(w * 0.03) h = area[1] hPad = int(h * 0.03) BGL.glColor3f(0.3, 0.3, 0.3) BGL.glRectf(wPad - 5, h - 60, w - wPad + 5, h - 85) BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(wPad, h - 75) Draw.Text('Chicken Configuration script', 'large') BGL.glRasterPos2i(wPad, h - 100) Draw.Text( 'This script is launched the first time you run Chicken, or when a configuration error has been detected' ) BGL.glColor3f(0.5, 0.5, 0.5) BGL.glRectf(wPad, h - 205, w - wPad, h - 225) BGL.glColor3f(1.0, 1.0, 1.0) BGL.glRasterPos2i(wPad, h - 220) Draw.Text('Binary Utilities - ') Draw.Text( 'if executables such as "pview" are on your PATH, you can leave this on Auto. Otherwise enter the folder manually' ) self.bBinPathAuto.update([wPad + 5, h - 250, w / 2 - wPad - 5, 20]) self.bBinPathManual.update([w / 2, h - 250, w / 2 - wPad - 5, 20]) if self.bBinPathManual.val: self.bBinPath.update([wPad + 5, h - 272, w - 2 * wPad - 90, 20]) self.bBinPathSel.update([w - wPad - 85, h - 272, 80, 20]) self.bLaunch.update([wPad + 5, h - 330, 100, 20]) self.bCheck.update([w - wPad - 85, h - 330, 80, 20]) if self.error is not None: if self.error is True: BGL.glColor3f(1.0, 0.0, 0.0) BGL.glRasterPos2i(w - wPad - 150, h - 365) Draw.Text('Configuration error detected') else: BGL.glColor3f(0.0, 0.0, 0.0) BGL.glRasterPos2i(w - wPad - 200, h - 365) Draw.Text('Configuration checked and saved')
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(): 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 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 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(): # the function to draw the screen global mystring, mymsg, toggle if len(mystring) > 90: mystring = "" BGL.glClearColor(0,0,1,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1,1,1) Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button") BGL.glRasterPos2i(72, 16) if toggle: toggle_state = "down" else: toggle_state = "up" Draw.Text("The toggle button is %s." % toggle_state, "small") BGL.glRasterPos2i(10, 230) Draw.Text("Type letters from a to z, ESC to leave.") BGL.glRasterPos2i(20, 200) Draw.Text(mystring) BGL.glColor3f(1,0.4,0.3) BGL.glRasterPos2i(340, 70) Draw.Text(mymsg, "tiny")
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 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 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