def keyboard()

in renderer/glViewer.py [0:0]


def keyboard(key, x, y):
    global g_stopMainLoop,g_frameIdx,g_show_fps
    global g_ptSize
    global g_xRotate,g_yRotate,g_zRotate


    if isinstance(key, bytes):
        key = key.decode()  #Python3: b'X' -> 'X' (bytes -> str)
    if key == chr(27) or key == 'q':
        #sys.exit()
        g_stopMainLoop= True
        g_frameIdx = 0
        # glutIdleFunc(0); # Turn off Idle function if used.
        # glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_CONTINUE_EXECUTION)
        # glutLeaveMainLoop()
        # glutDestroyWindow(g_winID) # Close open windows
    elif key == 'p':
        #global width, height
        glReadBuffer(GL_FRONT)
        img = glReadPixels(0, 0, g_Width, g_Height, GL_RGBA, GL_UNSIGNED_BYTE, outputType=None)
        img = Image.frombytes("RGBA", (g_Width, g_Height), img)
        img = ImageOps.flip(img)
        img.save('temp.jpg', 'JPG')

    elif key == 's':
        g_frameIdx = 0
  

    elif key == 't':
        
        g_xRotate =0
        g_yRotate =-90
        g_zRotate =0
        print('showTopView')
        
    elif key == 'r':
           global g_bSaveToFile
           g_frameIdx = 0
           g_bSaveToFile = not g_bSaveToFile

    elif key == 'w':
        global g_bShowWiredMesh
        g_bShowWiredMesh = not g_bShowWiredMesh

    elif key == 'h':        #Load Next Haggling Data
            LoadHagglingData_Caller()
    elif key =='o':
        global g_bApplyRootOffset
        g_bApplyRootOffset = not g_bApplyRootOffset

    elif key =='f':
        global g_bShowFloor
        g_bShowFloor = not g_bShowFloor

    elif key =='V':
        SaveCamViewInfo()

    elif key =='v':
        LoadCamViewInfo()

    # elif key =='c':
    #     g_xRotate =0
    #     g_yRotate =0
    #     g_zRotate =180

    elif key =='c':     #put the target human in the center
       PuttingObjectCenter()
    elif key=='+':
        g_ptSize +=1
    elif key=='-':
        # global g_ptSize
        if g_ptSize >=2:
            g_ptSize -=1
    elif key =='R':     #rotate cameras
        global g_bRotateView, g_rotateView_counter

        g_bRotateView = not g_bRotateView
        g_rotateView_counter =0

    elif key =='j':  #Toggle joint
        global g_bShowSkeleton
        g_bShowSkeleton = not g_bShowSkeleton
    elif key =='m':
        global g_bShowMesh
        g_bShowMesh = not g_bShowMesh
    elif key =='b':
        global g_bShowBackground
        g_bShowBackground = not g_bShowBackground

    # elif key =='C':
    #     g_xRotate =0
    #     g_yRotate =0
    #     g_zRotate =0
    elif key == 'C':
        print('Toggle camview / freeview')
        global g_viewMode, g_nearPlane
        if g_viewMode=='free':
            g_viewMode = 'camView'
            g_nearPlane = 500          #cameramode
        else:
            g_viewMode ='free'
            g_nearPlane = 0.01        #original

      
    elif key == 'S':
        global g_zoom, g_xTrans, g_yTrans
        g_xTrans=  -4.126092433929443
        g_yTrans= 12
        # g_zoom= 190
        g_zoom= 1028
        # g_xRotate = 90
        g_xRotate = -58
        # g_yRotate= 0
        g_yRotate= 9
        g_zRotate= 0.0
        g_viewMode = 'free'

    # elif key>='0' and key<='9':
    #     g_camid.popleft()
    #     g_camid.append(key)
    #     print('camView: CamID:{}'.format(g_camid))

    elif key =='0':
        glutReshapeWindow(1920,720)

    elif key =='z': # Toggle fps printing
        g_show_fps = not g_show_fps

    glutPostRedisplay()