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_draw(): from Blender import BGL, Draw (width, height) = Blender.Window.GetAreaSize() BGL.glClearColor(0.4, 0.4, 0.45, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1, 1, 1) BGL.glRasterPos2f(5, 55) Draw.Text("FlightGear YASim Import: '%s'" % Global.path) Draw.PushButton("Reload", RELOAD_BUTTON, 5, 5, 80, 32, "reload YASim config file") Global.mirror_button = Draw.Toggle("Mirror", MIRROR_BUTTON, 100, 5, 50, 16, Global.mirror_button.val, \ "show symmetric surfaces on both sides (reloads config)") Draw.PushButton("Update Cursor", CURSOR_BUTTON, width - 650, 5, 100, 32, "update cursor display (in YASim coordinate system)") BGL.glRasterPos2f(width - 530 + Blender.Draw.GetStringWidth("Vector from last") - Blender.Draw.GetStringWidth("Current"), 24) Draw.Text("Current cursor pos: x = %+.3f y = %+.3f z = %+.3f" % tuple(Global.cursor)) c = Global.cursor - Global.last_cursor BGL.glRasterPos2f(width - 530, 7) Draw.Text("Vector from last cursor pos: x = %+.3f y = %+.3f z = %+.3f length = %.3f m" % (c[0], c[1], c[2], c.length))
def draw_text(text, x, y): BGL.glRasterPos2f(x, y) return Draw.Text(text)