Beispiel #1
0
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()
Beispiel #2
0
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))
Beispiel #3
0
	def drawcorner(self):


		BGL.glBegin(BGL.GL_LINES)

		BGL.glColor3f(self.col[0],self.col[1],self.col[2])

		BGL.glVertex2i(self.x+4*self.xflip,self.y+1*self.yflip)
		BGL.glVertex2i(self.x+8*self.xflip,self.y+1*self.yflip)

		BGL.glVertex2i(self.x+3*self.xflip,self.y+2*self.yflip)
		BGL.glVertex2i(self.x+8*self.xflip,self.y+2*self.yflip)

		BGL.glVertex2i(self.x+2*self.xflip,self.y+3*self.yflip)
		BGL.glVertex2i(self.x+8*self.xflip,self.y+3*self.yflip)

		BGL.glVertex2i(self.x+1*self.xflip,self.y+4*self.yflip)
		BGL.glVertex2i(self.x+8*self.xflip,self.y+4*self.yflip)

		# change colour for border, if needed

		BGL.glColor3f(self.bcol[0],self.bcol[1],self.bcol[2])

		BGL.glVertex2i(self.x+5*self.xflip,self.y)
		BGL.glVertex2i(self.x+8*self.xflip,self.y)

		BGL.glVertex2i(self.x+5*self.xflip,self.y)
		BGL.glVertex2i(self.x,self.y+5*self.yflip)


		BGL.glVertex2i(self.x,self.y+5*self.yflip)
		BGL.glVertex2i(self.x,self.y+8*self.yflip)

		BGL.glEnd()
Beispiel #4
0
    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)
Beispiel #5
0
	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)
Beispiel #6
0
	def drawpanel(self):

		##   Draw the main part of the panel.
		BGL.glColor3f(self.col[0],self.col[1],self.col[2])

		BGL.glRecti(self.left+5,self.base,self.right-5,self.top)			##   Large middle bit.
		BGL.glRecti(self.left,self.base+4,self.left+8,self.top-4)			##   Left small side strip.
		BGL.glRecti(self.right-8,self.base+4,self.right,self.top-4)		##   Right small side strip.

		##   Draw the borders.
		BGL.glColor3f(self.bcol[0],self.bcol[1],self.bcol[2])			##   Change to border colour.

		BGL.glBegin(BGL.GL_LINES)

		BGL.glVertex2i(self.left+6,self.base)						##   Base border.
		BGL.glVertex2i(self.right-6,self.base)

		BGL.glVertex2i(self.left+6,self.top)						##   Top border.
		BGL.glVertex2i(self.right-6,self.top)

		BGL.glVertex2i(self.left,self.base+6)						##   Left border.
		BGL.glVertex2i(self.left,self.top-6)

		BGL.glVertex2i(self.right,self.base+6)						##   Right border.
		BGL.glVertex2i(self.right,self.top-6)

		BGL.glEnd()
def draw():     # Define the draw function (which draws your GUI).
	global EVENT_Button
	global EVENT_Type
	global EVENT_shtoguntype
	global EVENT_String
	global EVENT_Bitmap
	global EVENT_WVTU_1
	global Object_Button
	global Object_Type
	global Object_shtoguntype
	global Object_String
	global Object_Bitmap
	global Object_WVTU_1

	BGL.glClearColor(0.244564, 0.244406, 0.244406, 0.0)
	BGL.glClear(GL_COLOR_BUFFER_BIT)

	BGL.glColor3f(1.000000, 1.000000, 1.000000)
	Object_Button = Draw.Button("Connect to Shotgun", EVENT_Button, 20, 8, 200, 20, "")
	BGL.glRasterPos2i(100, 108)
	Object_Type = Draw.Text("Type")
	Object_shtoguntype = Draw.Menu("Asset", EVENT_shtoguntype, 20, 100, 60, 20, Object_shtoguntype.val, "Type of Shotgun entry")
	Object_String = Draw.String("id : ", EVENT_String, 20, 60, 60, 20,Object_String.val, 399, "ID # for the Shotgun entry")
	BGL.glRasterPos2i(24, 210)
	BGL.glDrawPixels(0, 0, GL_RGB, GL_UNSIGNED_BYTE, Object_Bitmap)
	BGL.glRasterPos2i(24, 152)
	Object_WVTU_1 = Draw.Text("WVTU "+VERSION+"")
Beispiel #8
0
    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")
Beispiel #9
0
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')
Beispiel #10
0
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
Beispiel #11
0
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
Beispiel #12
0
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")
Beispiel #13
0
	def coversides(self):

		##   This function draws lines to cover up border lines designated by the sides arguement.

		BGL.glColor3f(self.col[0],self.col[1],self.col[2])

		if self.sides[0]:			# left border

			BGL.glBegin(BGL.GL_LINES)

			BGL.glVertex2i(self.left,self.base+1)
			BGL.glVertex2i(self.left,self.top)

			BGL.glEnd()

		if self.sides[1]:			# top border

			BGL.glBegin(BGL.GL_LINES)

			BGL.glVertex2i(self.left+1,self.top)
			BGL.glVertex2i(self.right,self.top)

			BGL.glEnd()

		if self.sides[2]:			# right border

			BGL.glBegin(BGL.GL_LINES)

			BGL.glVertex2i(self.right,self.base+1)
			BGL.glVertex2i(self.right,self.top)

			BGL.glEnd()

		if self.sides[3]:			# base border

			BGL.glBegin(BGL.GL_LINES)

			BGL.glVertex2i(self.left+1,self.base)
			BGL.glVertex2i(self.right,self.base)

			BGL.glEnd()
Beispiel #14
0
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')
Beispiel #15
0
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)
Beispiel #16
0
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))
Beispiel #17
0
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()
Beispiel #18
0
	def drawcorner(self):

		BGL.glColor3f(self.col[0],self.col[1],self.col[2])

		for i in range(8):
			
			BGL.glBegin(BGL.GL_LINES)
			BGL.glVertex2i(self.x,self.y+i*self.yflip)
			BGL.glVertex2i(self.x+8*self.xflip,self.y+i*self.yflip)

			BGL.glEnd()

		# change colour for border, if needed
		BGL.glColor3f(self.bcol[0],self.bcol[1],self.bcol[2])

		BGL.glBegin(BGL.GL_LINES)

		BGL.glVertex2i(self.x,self.y)
		BGL.glVertex2i(self.x+9*self.xflip,self.y)

		BGL.glVertex2i(self.x,self.y)
		BGL.glVertex2i(self.x,self.y+9*self.yflip)

		BGL.glEnd()
Beispiel #19
0
 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")
Beispiel #20
0
def OnDraw():
    global Ticks, Tickctrl
    BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT)
    
    BGL.glColor3f(0.2, 0.3, 0.3)
    DrawBox(LEFT-10, TOP - 10, 300, 380)
    
    BGL.glColor3f(0.1, 0.1, 0.1)
    
    BGL.glRasterPos2i(LEFT, TOP)
    Draw.Text("DirectX Exporter", "large")
    
    BGL.glRasterPos2i(LEFT, TOP - 40)
    Draw.Text("Export", "large")
    Draw.Toggle("All", 0, LEFT, TOP - 80, 80, 20, ExportType == 0, "Export all static objects in the current scene.")
    Draw.Toggle("Selected", 1, LEFT + 100, TOP - 80, 80, 20, ExportType == 1, "Export all selected objects.")
    Draw.Toggle("Animated", 2, LEFT + 200, TOP - 80, 80, 20, ExportType == 2, "Export one mesh with one armature. Make sure that only the mesh and it's armature are selected.")
     
    BGL.glRasterPos2i(LEFT, EDATA)
    Draw.Text("Exported data", "large")
    Draw.Toggle("Normals", 3, LEFT, EDATA - 40, 80, 20, Normals, "Export vertex normals.")
    Draw.Toggle("Colors", 4, LEFT + 200, EDATA - 40, 80, 20, Colors, "Export vertex diffuse colors.")
    Draw.Toggle("Texcoords", 6, LEFT, EDATA - 70, 80, 20, TexCoords, "Export vertex texture coordinates.")   
    Draw.Toggle("Materials", 7, LEFT + 100, EDATA - 40, 80, 20, Materials, "Export materials.") 
     
    BGL.glRasterPos2i(LEFT, MISC)
    Draw.Text("Misc options", "large")
    Draw.Toggle("Swap y and z", 8, LEFT, MISC - 40, 80, 20, SwapYZ, "Right-handed to left-handed system.")
    Draw.Toggle("Apply world", 9, LEFT + 100, MISC - 40, 80, 20, UseWTrans, "Apply world transformation to exported vertices.")
    Tickctrl = Draw.Number("Speed", 10, LEFT + 200, MISC - 40, 80, 20, Ticks, 1, 100, "Animation ticks per second.")
    #Draw.Toggle("Compressed", 11, LEFT, MISC - 70, 80, 20, Compressed, "Compress the file.")
    
    Draw.Button("Export...", 100, LEFT + 40, DOIT, 80, 40, "Export data.")
    Draw.Button("Exit", 101, LEFT + 140, DOIT, 80, 40, "Exit the script.")
     
    BGL.glColor3f(0.3, 0.3, 0.3)
    BGL.glRasterPos2i(LEFT, 35)
    Draw.Text("(C) 2006 Heikki Salo", "small")
    BGL.glRasterPos2i(LEFT, 20)
    Draw.Text("http://directpython.sourceforge.net/exportx.html", "small")
Beispiel #21
0
def draw():
    global EVENT_gui_exit
    global EVENT_gui_instruction
    global EVENT_gui_prepare
    global EVENT_gui_export
    global EVENT_gui_nexuizPath
    global EVENT_gui_fileName
    global EVENT_Text
    global EVENT_Text_0
    global EVENT_gui_scale
    global EVENT_Text_1
    global EVENT_gui_extrudeHeight
    global EVENT_Text_2
    global EVENT_gui_extrudeDownwards
    global EVENT_Text_3
    global EVENT_gui_echo
    global EVENT_Text_4
    global EVENT_Text_5
    global EVENT_Text_6
    global EVENT_Text_7
    global EVENT_Text_8
    global EVENT_Text_9
    global EVENT_Text_10
    global EVENT_Text_11
    global EVENT_Text_12
    global EVENT_Text_13
    global EVENT_Text_14
    global EVENT_Text_15
    global EVENT_gui_version
    global EVENT_Text_16
    global EVENT_gui_exportSurf
    global EVENT_Text_17
    global EVENT_gui_textureStri
    global EVENT_name_textureInd
    global EVENT_Text_18
    global EVENT_gui_textureBtn
    global Object_gui_exit
    global Object_gui_instruction
    global Object_gui_prepare
    global Object_gui_export
    global Object_gui_nexuizPath
    global Object_gui_fileName
    global Object_Text
    global Object_Text_0
    global Object_gui_scale
    global Object_Text_1
    global Object_gui_extrudeHeight
    global Object_Text_2
    global Object_gui_extrudeDownwards
    global Object_Text_3
    global Object_gui_echo
    global Object_Text_4
    global Object_Text_5
    global Object_Text_6
    global Object_Text_7
    global Object_Text_8
    global Object_Text_9
    global Object_Text_10
    global Object_Text_11
    global Object_Text_12
    global Object_Text_13
    global Object_Text_14
    global Object_Text_15
    global Object_gui_version
    global Object_Text_16
    global Object_gui_exportSurf
    global Object_Text_17
    global Object_gui_textureStri
    global Object_name_textureInd
    global Object_Text_18
    global Object_gui_textureBtn
    
    global nexify

    BGL.glClearColor(0.500000, 0.500000, 0.500000, 0.0)
    BGL.glClear(GL_COLOR_BUFFER_BIT)

    BGL.glColor3f(0.000000, 0.000000, 0.000000)
    Object_gui_exit = Draw.Button("Exit", EVENT_gui_exit, 8, 8, 76, 44, "Exit exporter")
    BGL.glRasterPos2i(64, 560)
    Object_gui_instruction = Draw.Text("Exporter  to MAP format for Nexuiz community")
    Object_gui_prepare = Draw.Button("Prepare", EVENT_gui_prepare, 88, 8, 76, 44, "Prepares for export: checks is all meshes are convex")
    Object_gui_export = Draw.Button("Export", EVENT_gui_export, 168, 8, 76, 44, "Exports prepared scene to a MAP file")
    Object_gui_nexuizPath = Draw.String("", EVENT_gui_nexuizPath, 152, 320, 148, 20, Object_gui_nexuizPath.val, 399, "Nexuiz absolute path")
    Object_gui_fileName = Draw.String("", EVENT_gui_fileName, 152, 296, 148, 20, Object_gui_fileName.val, 399, "MAP file name")
    BGL.glRasterPos2i(16, 328)
    Object_Text = Draw.Text("Nexuiz absolute path")
    BGL.glRasterPos2i(16, 304)
    Object_Text_0 = Draw.Text("MAP file name")
    Object_gui_scale = Draw.Number("", EVENT_gui_scale, 152, 272, 76, 20, Object_gui_scale.val, 0.000000, 1024.000000, "")
    BGL.glRasterPos2i(16, 280)
    Object_Text_1 = Draw.Text("Scale factor")
    Object_gui_extrudeHeight = Draw.Number("", EVENT_gui_extrudeHeight, 152, 248, 76, 20, Object_gui_extrudeHeight.val, 0.000000, 1024.000000, "")
    BGL.glRasterPos2i(16, 256)
    Object_Text_2 = Draw.Text("Extrude height")
    Object_gui_extrudeDownwards = Draw.Toggle("downwards", EVENT_gui_extrudeDownwards, 152, 224, 76, 20, Object_gui_extrudeDownwards.val, "")
    BGL.glRasterPos2i(16, 232)
    Object_Text_3 = Draw.Text("Extrude downwards")
    Object_gui_echo = Draw.Toggle("echo", EVENT_gui_echo, 152, 200, 76, 20, Object_gui_echo.val, "")
    BGL.glRasterPos2i(16, 208)
    Object_Text_4 = Draw.Text("Console echo")
    BGL.glRasterPos2i(32, 536)
    Object_Text_5 = Draw.Text("Brief instruction:")
    BGL.glRasterPos2i(8, 504)
    Object_Text_6 = Draw.Text("Exporter currently work with meshes, lights and nurbs surfaces.")
    BGL.glRasterPos2i(368, 504)
    Object_Text_7 = Draw.Text("As far as meshes are converted into NetRadiant brushes they should be convex")
    BGL.glRasterPos2i(8, 480)
    Object_Text_8 = Draw.Text("Concave meshes are splitted into individual faces. Faces after that are extruded on \"Extrude height\" parameter (see below).")
    BGL.glRasterPos2i(8, 456)
    Object_Text_9 = Draw.Text("As far as objects in NetRadiant may have properties different then objects in Blender game logic properties are used to store such params.")
    BGL.glRasterPos2i(8, 432)
    Object_Text_10 = Draw.Text("Possible mesh params: ignore(BOOL), convex(BOOL)")
    BGL.glRasterPos2i(8, 408)
    Object_Text_11 = Draw.Text("Possible light params: sun(BOOL), has_target(BOOL), target_x, target_y, target_z(FLOAT), radius(float)")
    BGL.glRasterPos2i(8, 64)
    Object_Text_12 = Draw.Text("First press PREPARE, then press EXPORT.")
    BGL.glRasterPos2i(8, 384)
    Object_Text_13 = Draw.Text("Due to Blender doesn't understand Radiant shaders one may use texture[i](STRING) properties, to overwrite texture files with shaders(i = material index).")
    BGL.glRasterPos2i(8, 84)
    Object_Text_14 = Draw.Text("REMEMBER: textures are to be on \".../nexuiz/data/textures\" subpath!")
    BGL.glRasterPos2i(272, 24)
    Object_Text_15 = Draw.Text("Ver")
    BGL.glRasterPos2i(304, 24)
    Object_gui_version = Draw.Text( __version__ )
    BGL.glRasterPos2i(16, 176)
    Object_Text_16 = Draw.Text("Focre selected surf")
    Object_gui_exportSurf = Draw.Button("Treat selected as surf when export", EVENT_gui_exportSurf, 152, 168, 212, 20, "")
    BGL.glRasterPos2i(16, 136)
    Object_Text_17 = Draw.Text("Overwrite texture")
    Object_gui_textureStri = Draw.String("", EVENT_gui_textureStri, 192, 132, 104, 20, Object_gui_textureStri.val, 399, "")
    Object_name_textureInd = Draw.Number("", EVENT_name_textureInd, 392, 132, 60, 20, Object_name_textureInd.val, 1.000000, 128.000000, "")
    BGL.glRasterPos2i(304, 140)
    Object_Text_18 = Draw.Text("material index")
    Object_gui_textureBtn = Draw.Button("over", EVENT_gui_textureBtn, 152, 132, 32, 20, "Overwrite selected object texture with the following.")
Beispiel #22
0
	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')
Beispiel #23
0
    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')
Beispiel #24
0
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
Beispiel #25
0
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")
Beispiel #26
0
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')
Beispiel #27
0
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')
Beispiel #28
0
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")
Beispiel #29
0
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
Beispiel #30
0
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")
Beispiel #31
0
 def doDraw(self):
     BGL.glColor3f(*self.color)
     BGL.glRecti(self.pos_x, self.pos_y,
                 self.pos_x + self.width,
                 self.pos_y + self.height)
Beispiel #32
0
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")
Beispiel #33
0
def gui():
    global mystring, mymsg, toggle, scriptsLocation
    global bSelectedOnly, bBaseDir, gBaseDir
    global gSelectedOnly
    global gImageDir, gORGOutput, gTGAOutput, bTGA, bORG
    global bWorld, gCreateWorld, bImageDir
    global bSceneDir, gOutDir, gExportLights, bExportLights, gLastYVal
    global bWalkTest, gWalkTest, gExportCameras, bExportCameras, bReWalkTest
    global bExportPhysics, gExportPhysics
    global gLastSceneExported, bBinary, gBinary
    global gCreateScene, bCreateScene, bIrrlichtVersion

    if gDisplayWarnings:
        displayWarnings()
        return

    BGL.glClearColor(0.392,0.396,0.549,1) 
    
    BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT)
    size = Blender.Window.GetAreaSize()

    isize = drawHeader(size)

    maxWidth = 440

	# Create File path input
    BGL.glColor3f(1.0,1.0,1.0)

    # starting x&y position values
    xval = 10
    yval = size[1]-isize[1] - 40

    fileWidth = size[0] - (xval+130)

    if fileWidth > maxWidth:
        fileWidth = maxWidth

    # Scene Directory
    Blender.BGL.glRasterPos2i(xval, yval+5)
    Blender.Draw.Text('Output Directory','normal')
    bSceneDir = Blender.Draw.String('', ID_OUTDIR, xval+95,
        yval, fileWidth, 20, gOutDir, 255)

    Blender.Draw.PushButton('...', ID_SELECTDIR, xval+95 + fileWidth,
        yval, 30,20,'Select Output Directory')

    yval -= 40

    # Option Buttons
    bCreateScene = Blender.Draw.Toggle('Create Scene File', 
        ID_CREATESCENE,xval+95, yval, 150, 20, gCreateScene, 
        'Create Scene File (.irr)')

    bSelectedOnly = Blender.Draw.Toggle('Selected Meshes Only',
            ID_SELECTEDONLY,xval+255, yval, 150, 20, gSelectedOnly, 
            'Export Select Meshes Only')

    if gHaveMeshCvt:
        bBinary = Blender.Draw.Toggle('Create Binary Meshes',
                ID_BINARY,xval+415, yval, 150, 20, gBinary, 
                'Export Binary Mesh Format (.irrbmesh)')

    # Scene Directory
    if gCreateScene:

        yval -= 25

        bExportCameras = Blender.Draw.Toggle('Export Camera(s)', 
            ID_EXPCAMERAS, xval+95, yval, 150, 20, gExportCameras,
            'Export Scene Camera(s)')

        bExportLights = Blender.Draw.Toggle('Export Light(s)', 
            ID_EXPLIGHTS, xval+255, yval, 150, 20, gExportLights,
            'Export Scene Light(s)')

        bExportPhysics = Blender.Draw.Toggle('Export Physics',
            ID_EXPPHYSICS, xval+415, yval, 150, 20, gExportPhysics,
            'Export Physics/Collision Data')

    yval -= 25
    dx = 95
    if gCreateScene and gHaveWalkTest:
        bWalkTest = Blender.Draw.Toggle('Walk Test', ID_WALKTEST, xval+95,
                yval, 150, 20, gWalkTest, 'Run Walk Test After Export')
        dx = 255

    Blender.Draw.PushButton('Create irrb Props', ID_GENPROPS, xval + dx,
            yval, 150, 20, 'Create irrb ID Properties For Selected Object(s)')


    # Irrlicht Version (target) for imeshcvt
    if gHaveMeshCvt and gBinary:
        yval -= 40
        Blender.BGL.glRasterPos2i(xval+6, yval+4)
        Blender.Draw.Text('Irrlicht Version','normal')
    
        bIrrlichtVersion = Draw.Menu(sVersionList, ID_IVERSION, xval+95, yval-1, 150, 20,
                gIrrlichtVersion, 'Irrlicht Version Target')
    
    if gWorldLogic:
        yval -= 40
        bWorld = Blender.Draw.Toggle('Create World File', ID_WORLD, xval+95, 
                yval, 150, 20, gCreateWorld, 
                'Create Compressed .wld File (experimental)')

    # Export Buttons        
    Blender.Draw.PushButton('Export', ID_EXPORT, xval+95, 10, 100, 20, 'Export')
    if gCreateScene and gHaveWalkTest and gLastSceneExported != None:
        bReWalkTest = Blender.Draw.PushButton('Run Walk Test', ID_REWALKTEST,
                xval + 250, 10, 150, 20, 
                'Run Walk Test With Last Exported Scene')            
    Blender.Draw.PushButton('Exit', ID_CANCEL, fileWidth+35, 10, 100, 
            20,'Exit the Exporter')

    yval -= 40
    Blender.BGL.glRasterPos2i(xval+50, yval)
    Blender.Draw.Text('Status:','normal')

    gLastYVal = yval
    
    if type(gStatus) == types.ListType:
        for s in gStatus:
            Blender.BGL.glRasterPos2i(xval+95, yval)
            Blender.Draw.Text(s,'normal')
            yval -= 18
        if len(gWarnings) > 0 :
            BGL.glColor3f(1.0,1.0,0.0)
            Blender.BGL.glRasterPos2i(xval+95, yval)
            Blender.Draw.Text('%d Warning(s)' % len(gWarnings),'normal')
            Blender.Draw.PushButton('Warnings', ID_SHOWWARNINGS,
                    xval+255, yval-3, 75, 20, 
                    'Display Warnings From Last Export')

    else:
        Blender.BGL.glRasterPos2i(xval+95, yval)
        Blender.Draw.Text(gStatus,'normal')
        yval -= 18