Exemplo n.º 1
0
def draw():
    global as_package_name
    global fileButton, expFileName
    global engine_menu, engine_name
    global EVENT_NOEVENT, EVENT_DRAW, EVENT_EXIT, EVENT_EXPORT
    global export_all
    expFileName = ""
    ########## Titles
    glClear(GL_COLOR_BUFFER_BIT)
    glRasterPos2i(40, 240)

    logoImage = Image.Load(Get('scriptsdir') + sys.sep + 'AS3Export.png')
    Draw.Image(logoImage, 40, 155)

    as_package_name = Draw.String("Package name: ", EVENT_NOEVENT, 40, 130,
                                  250, 20, as_package_name.val, 300)
    engine_name = "Away3D%x1|Away3D 2.1.0%x5|Away3D 2.2.0%x6|Papervision3D%x2|Papervision3D 2.0%x3|Sandy 3.0%x4"
    engine_menu = Draw.Menu(engine_name, EVENT_NOEVENT, 40, 100, 200, 20,
                            engine_menu.val, "Choose your engine")

    fileButton = Draw.String('File location: ', EVENT_NOEVENT, 40, 70, 250, 20,
                             fileButton.val, 255)
    Draw.PushButton('...', EVENT_BROWSEFILE, 300, 70, 30, 20, 'browse file')
    export_all = Draw.Toggle('Export ALL scene objects', EVENT_NOEVENT, 40, 45,
                             200, 20, 0)
    ######### Draw and Exit Buttons
    Draw.Button("Export", EVENT_EXPORT, 40, 20, 80, 18)
    Draw.Button("Exit", EVENT_EXIT, 140, 20, 80, 18)
Exemplo n.º 2
0
    def render(self):
        if self.image_block:
            width, height = self.image_block.getSize()
            self.x_zoom = float(self.width) / width
            self.y_zoom = float(self.height) / height

            Draw.Image(self.image_block, self.x, self.y, self.x_zoom,
                       self.y_zoom, self.x_clip, self.y_clip, self.clip_width,
                       self.clip_height)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
 def render(self):
     Draw.Image(self.image_block, self.x, self.y, 1.0, 1.0, self.clip_x,
                self.clip_y, self.clip_width, self.clip_height)
Exemplo n.º 5
0
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.')