Exemple #1
0
def __DrawGUI(w, h, RotMatrix):  # called directly by the display function after drawing the scene
    global pw, ph
    # the GUI is drawn over the scene by clearing the depth buffer
    pw, ph = 1.0 / w, 1.0 / h

    global W_HitDefs
    W_HitDefs = {}  # clear the hitdefs to avoid improper activation

    __GL.glMatrixMode(__GL.GL_PROJECTION)
    __GL.glLoadIdentity()
    # glOrtho(-2*P, 2*P, -2, 2, -100, 100)
    __GLU.gluOrtho2D(0.0, 1.0, 1.0, 0.0)

    __GL.glMatrixMode(__GL.GL_MODELVIEW)

    __GL.glClear(__GL.GL_DEPTH_BUFFER_BIT)
    __GL.glPolygonMode(__GL.GL_FRONT_AND_BACK, __GL.GL_FILL)

    __GL.glLoadIdentity()

    __GL.glEnable(__GL.GL_BLEND)
    __GL.glDisable(__GL.GL_DEPTH_TEST)
    __GL.glDisable(__GL.GL_LIGHTING)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(0.4, 0.4, 0.4, 0.8)  # options toggle
    __GL.glVertex2f(pw * 0, ph * 0)
    __GL.glVertex2f(pw * w, ph * 0)
    __GL.glVertex2f(pw * w, ph * 20)
    __GL.glVertex2f(pw * 0, ph * 20)
    __GL.glEnd()
    __GL.glColor4f(0.0, 0.0, 0.0, 0.2)
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex2f(pw * ((w / 2) - 10), ph * 6)
    __GL.glVertex2f(pw * ((w / 2) + 10), ph * 6)
    __GL.glVertex2f(pw * (w / 2), ph * 15)
    __GL.glEnd()

    M = __ExPanel(pw * 0, ph * 21, pw * 210, ph * h, 1, "MODEL")
    if M:
        __BrowseBar(pw * 10, ph * 40, 180)

    A = __ExPanel(pw * (w - 210), ph * 21, pw * w, ph * h, 3, "ANIM")
    D = __ExPanel(
        pw * (211 if M else 1),
        ph * 21,
        pw * (w - (211 if A else 1)),
        ph * 150,
        2,
        "DSPL",
        (0 if M else pw * 105) + (0 if A else pw * -105),
    )
    if D:
        VIEWER.TOGGLE_LIGHTING = __TButton(pw * (221 if M else 11), ph * 31, "EnLight", True, "Lighting")
        VIEWER.TOGGLE_WIREFRAME = __TButton(pw * (221 if M else 11), ph * 56, "EnWire", False, "Wireframe")
        VIEWER.TOGGLE_BONES = __TButton(pw * (221 if M else 11), ph * 81, "EnBone", True, "Bones")

        global ORTHO
        if VIEWER.TOGGLE_ORTHO != ORTHO:
            W_States["EnOrtho"] = VIEWER.TOGGLE_ORTHO
            ORTHO = VIEWER.TOGGLE_ORTHO  # HACK
        ORTHO = __TButton(pw * (321 if M else 111), ph * 31, "EnOrtho", True, "Ortho")
        VIEWER.TOGGLE_ORTHO = ORTHO

        VIEWER.TOGGLE_3D = __TButton(pw * (321 if M else 111), ph * 56, "En3D", False, "3D Analglyph")
        VIEWER.TOGGLE_NORMALS = __TButton(pw * (321 if M else 111), ph * 81, "EnNrm", False, "Normals")

    C = __ExPanel(
        pw * (211 if M else 1),
        ph * (h - 150),
        pw * (w - (211 if A else 1)),
        ph * h,
        0,
        "CTRL",
        (0 if M else pw * 105) + (0 if A else pw * -105),
    )

    __GL.glDisable(__GL.GL_BLEND)
    __GL.glEnable(__GL.GL_DEPTH_TEST)

    # axis
    __GL.glLineWidth(1.0)
    __GL.glPushMatrix()
    __GL.glTranslatef(pw * (228 if M else 17), ph * (h - (167 if C else 17)), 0)
    __GL.glScalef(pw * 600, ph * 600, 1)
    __GL.glMultMatrixf(RotMatrix)

    __GL.glColor3f(1.0, 0.0, 0.0)
    __GL.glBegin(__GL.GL_LINES)
    __GL.glVertex3f(0.0, 0.0, 0.0)
    __GL.glVertex3f(0.02, 0.0, 0.0)
    __GL.glEnd()  # X
    __GL.glTranslatef(0.0145, 0.0, 0.0)
    __GL.glRotatef(90, 0.0, 1.0, 0.0)
    # __GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 0.0, 1.0, 0.0)
    __GL.glTranslatef(-0.0145, 0.0, 0.0)
    __GL.glColor3f(0.0, 1.0, 0.0)
    __GL.glBegin(__GL.GL_LINES)
    __GL.glVertex3f(0.0, 0.0, 0.0)
    __GL.glVertex3f(0.0, -0.02, 0.0)
    __GL.glEnd()  # Y
    __GL.glTranslatef(0.0, -0.0145, 0.0)
    __GL.glRotatef(90, 1.0, 0.0, 0.0)
    # __GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 1.0, 0.0, 0.0)
    __GL.glTranslatef(0.0, 0.0145, 0.0)
    __GL.glColor3f(0.0, 0.0, 1.0)
    __GL.glBegin(__GL.GL_LINES)
    __GL.glVertex3f(0.0, 0.0, 0.0)
    __GL.glVertex3f(0.0, 0.0, 0.02)
    __GL.glEnd()  # Z
    __GL.glTranslatef(0.0, 0.0, 0.0145)
    # __GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glTranslatef(0.0, 0.0, -0.0145)
    __GL.glColor3f(0.5, 0.5, 0.5)
    # __GLUT.glutSolidSphere(0.003, 8, 4)
    __GL.glPopMatrix()
Exemple #2
0
def __DrawGUI(w,h,RotMatrix): #called directly by the display function after drawing the scene
    global pw,ph,lw,lh,layer
    #the GUI is drawn over the scene by clearing the depth buffer

    #using floats will cause a more accurate edge-blur between panels when the screen is resized
    pw,ph=1./w,1./h
    #using ints won't look as pretty, but you won't need the extra multiplication (TODO: add in options)

    global HitDefs
    HitDefs = {} #clear the hitdefs to avoid improper activation

    __GL.glMatrixMode(__GL.GL_PROJECTION)
    __GL.glLoadIdentity()
    __GL.glOrtho(0.0, 1.0, 1.0, 0.0, -100, 100)
    #__GLU.gluOrtho2D(0.0, 1.0, 1.0, 0.0)

    __GL.glMatrixMode(__GL.GL_MODELVIEW)

    __GL.glClear( __GL.GL_DEPTH_BUFFER_BIT )
    #__GL.glPolygonMode(__GL.GL_FRONT_AND_BACK,__GL.GL_FILL)

    __GL.glLoadIdentity()

    __GL.glBlendFunc(__GL.GL_SRC_ALPHA, __GL.GL_ONE_MINUS_SRC_ALPHA)
    __GL.glEnable(__GL.GL_BLEND)
    __GL.glEnable(__GL.GL_DEPTH_TEST)
    __GL.glDisable(__GL.GL_TEXTURE_2D)
    __GL.glDisable(__GL.GL_LIGHTING)

    #positioning precalculations
    pw211 = pw*211
    pw210 = pw*210
    pw105 = pw*105
    
    ph150 = ph*150
    ph21 = ph*21


    M,A,D,C=False,False,False,False
    if not __OprionsUpdatePanel(w,h):
        M = __ExPanel(0.,ph21,pw210,1.,1,'MODEL')
        if M: __ModelPanel()

        A = __ExPanel(1.-pw210,ph21,1.,1.,3,'ANIM')
        if A: __AnimPanel()

        D = __ExPanel(pw211 if M else 0.,ph21,1.-(pw211 if A else 0.),ph150,2,'DSPL',(0. if M else pw105)+(0. if A else -pw105))
        if D: __DisplayPanel(210 if M else 0,-210 if A else 0)

        C = __ExPanel(pw211 if M else 0.,1.-ph150,1.-(pw211 if A else 0.),1.,0,'CTRL',(0 if M else pw105)+(0 if A else -pw105))
        if C: __ControlPanel(210 if M else 0,-210 if A else 0)


        __GL.glDisable(__GL.GL_BLEND)
        #__GL.glEnable(__GL.GL_DEPTH_TEST)

        #axis
        __GL.glLineWidth(1.0)
        __GL.glPushMatrix()
        __GL.glTranslatef(pw*(228 if M else 17),ph*(h-(167 if C else 17)),0)
        __GL.glScalef(pw*600,ph*600,1)
        __GL.glMultMatrixf(RotMatrix)

        __GL.glColor3f(1.0,0.0,0.0)
        __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.02,0.0,0.0); __GL.glEnd() #X
        __GL.glTranslatef(0.0145,0.0,0.0); __GL.glRotatef(90, 0.0, 1.0, 0.0)
        #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
        __GL.glRotatef(-90, 0.0, 1.0, 0.0); __GL.glTranslatef(-0.0145,0.0,0.0)
        __GL.glColor3f(0.0,1.0,0.0)
        __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.0,-0.02,0.0); __GL.glEnd() #Y
        __GL.glTranslatef(0.0,-0.0145,0.0); __GL.glRotatef(90, 1.0, 0.0, 0.0)
        #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
        __GL.glRotatef(-90, 1.0, 0.0, 0.0); __GL.glTranslatef(0.0,0.0145,0.0)
        __GL.glColor3f(0.0,0.0,1.0)
        __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.0,0.0,0.02); __GL.glEnd() #Z
        __GL.glTranslatef(0.0,0.0,0.0145)
        #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
        __GL.glTranslatef(0.0,0.0,-0.0145)
        __GL.glColor3f(0.5,0.5,0.5) ; #__GLUT.glutSolidSphere(0.003, 8, 4)
        __GL.glPopMatrix()

    for lid in layer: layer[lid].draw()

    global doFrameCheck
    if doFrameCheck: __FrameCheck(); doFrameCheck=False
    __GL.glBlendFunc(__GL.GL_SRC_ALPHA, __GL.GL_ONE_MINUS_SRC_ALPHA) #reset to mormal for anything else
Exemple #3
0
def __DrawGUI(w,h,RotMatrix): #called directly by the display function after drawing the scene

    global pw,ph
    #the GUI is drawn over the scene by clearing the depth buffer
    pw,ph=1./w,1./h

    global W_HitDefs
    W_HitDefs = {} #clear the hitdefs to avoid improper activation

    __GL.glMatrixMode(__GL.GL_PROJECTION)
    __GL.glLoadIdentity()
    #glOrtho(-2*P, 2*P, -2, 2, -100, 100)
    __GLU.gluOrtho2D(0.0, 1.0, 1.0, 0.0) #TODO update the viewport with the pixel range instead of 1.0 (less GUI calculations will be needed)

    __GL.glMatrixMode(__GL.GL_MODELVIEW)

    __GL.glClear( __GL.GL_DEPTH_BUFFER_BIT )
    __GL.glPolygonMode(__GL.GL_FRONT_AND_BACK,__GL.GL_FILL)

    __GL.glLoadIdentity()

    __GL.glEnable(__GL.GL_BLEND)
    __GL.glDisable(__GL.GL_DEPTH_TEST)
    __GL.glDisable(__GL.GL_TEXTURE_2D)
    __GL.glDisable(__GL.GL_LIGHTING)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(0.4,0.4,0.4,0.8) #options toggle
    __GL.glVertex2f(pw*0,ph*0)
    __GL.glVertex2f(pw*w,ph*0)
    __GL.glVertex2f(pw*w,ph*20)
    __GL.glVertex2f(pw*0,ph*20)
    __GL.glEnd()
    __GL.glColor4f(0.0,0.0,0.0,0.2)
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex2f(pw*((w/2)-10),ph*6)
    __GL.glVertex2f(pw*((w/2)+10),ph*6)
    __GL.glVertex2f(pw*(w/2),ph*15)
    __GL.glEnd()

    M = __ExPanel(pw*0,ph*21,pw*210,ph*h,1,'MODEL')
    if M: __ModelPanel()

    A = __ExPanel(pw*(w-210),ph*21,pw*w,ph*h,3,'ANIM')
    if A: __AnimPanel()

    D = __ExPanel(pw*(211 if M else 1),ph*21,pw*(w-(211 if A else 1)),ph*150,2,'DSPL',(0 if M else pw*105)+(0 if A else pw*-105))
    if D: __DisplayPanel(210 if M else 0,-210 if A else 0)

    C = __ExPanel(pw*(211 if M else 1),ph*(h-150),pw*(w-(211 if A else 1)),ph*h,0,'CTRL',(0 if M else pw*105)+(0 if A else pw*-105))
    if C: __ControlPanel(210 if M else 0,-210 if A else 0)


    #__font(40,40,14,"testing",(128,0,0,100))


    __GL.glDisable(__GL.GL_BLEND)
    __GL.glEnable(__GL.GL_DEPTH_TEST)

    #axis
    __GL.glLineWidth(1.0)
    __GL.glPushMatrix()
    __GL.glTranslatef(pw*(228 if M else 17),ph*(h-(167 if C else 17)),0)
    __GL.glScalef(pw*600,ph*600,1)

    __GL.glMultMatrixf(RotMatrix)

    __GL.glColor3f(1.0,0.0,0.0)
    __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.02,0.0,0.0); __GL.glEnd() #X
    __GL.glTranslatef(0.0145,0.0,0.0); __GL.glRotatef(90, 0.0, 1.0, 0.0)
    #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 0.0, 1.0, 0.0); __GL.glTranslatef(-0.0145,0.0,0.0)

    __GL.glColor3f(0.0,1.0,0.0)
    __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.0,-0.02,0.0); __GL.glEnd() #Y
    __GL.glTranslatef(0.0,-0.0145,0.0); __GL.glRotatef(90, 1.0, 0.0, 0.0)
    #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 1.0, 0.0, 0.0); __GL.glTranslatef(0.0,0.0145,0.0)

    __GL.glColor3f(0.0,0.0,1.0)
    __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.0,0.0,0.02); __GL.glEnd() #Z
    __GL.glTranslatef(0.0,0.0,0.0145)
    #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glTranslatef(0.0,0.0,-0.0145)

    __GL.glColor3f(0.5,0.5,0.5) ; #__GLUT.glutSolidSphere(0.003, 8, 4)
    __GL.glPopMatrix()