def drawbody_SMPLCOCO_TotalCap26()

in renderer/glViewer.py [0:0]


def drawbody_SMPLCOCO_TotalCap26(joints,  color, normal=None):
    connMat = [ [12,2], [2,1], [1,0], #Right leg
                     [12,3], [3,4], [4,5], #Left leg
                     [12,9], [9,10], [10,11], #Left Arm
                     [12,8], [8,7], [7,6], #Right shoulder
                      [12,14],[14,16],[16,18],  #Neck(12)->Nose(14)->rightEye(16)->rightEar(18)
                      [14,15],[15,17],   #Nose(14)->leftEye(15)->leftEar(17).
                      [14,13], #Nose->headMidle(13)
                      [12,19],       #headTop19
                      [5,20], [5,21], [5,22],       #leftFoot
                      [0,23], [0,24], [0,25]       #rightFoot
                     ]
    connMat = np.array(connMat, dtype=int)  #zero Idx

    #Visualize Joints
    glColor3ub(color[0], color[1], color[2])
    for i in range(int(len(joints)/3)):

        if g_bSimpleHead and (i>=15 or i==1):
            continue
        glPushMatrix()
        glTranslate(joints[3*i], joints[3*i+1], joints[3*i+2])
        glutSolidSphere(2, 10, 10)
        glPopMatrix()

    #Visualize Bones
    for conn in connMat:
        # x0, y0, z0 is the coordinate of the base point
        x0 = joints[3*conn[0]]
        y0 = joints[3*conn[0]+1]
        z0 = joints[3*conn[0]+2]
        # x1, y1, z1 is the vector points from the base to the target
        x1 = joints[3*conn[1]] - x0
        y1 = joints[3*conn[1]+1] - y0
        z1 = joints[3*conn[1]+2] - z0


        if g_bSimpleHead and conn[0] == 0 and conn[1]==1:
            x1 = x1*0.5
            y1 = y1*0.5
            z1 = z1*0.5

        length = math.sqrt(x1*x1 + y1*y1 + z1*z1)
        theta = math.degrees(math.acos(z1/length))
        phi = math.degrees(math.atan2(y1, x1))

        glPushMatrix()
        glTranslate(x0, y0, z0)
        glRotatef(phi, 0, 0, 1)
        glRotatef(theta, 0, 1, 0)
        glutSolidCone(2, length, 10, 10)
        glPopMatrix()

    # Visualize Normals
    if normal is not None:
        i=1
        facePt = joints[(3*i):(3*i+3)]
        normalPt = facePt + normal*50

        glColor3ub(0, 255, 255)
        glPushMatrix()
        glTranslate(normalPt[0], normalPt[1], normalPt[2])
        glutSolidSphere(1, 10, 10)
        glPopMatrix()

        glBegin(GL_LINES)
        glVertex3f(facePt[0], facePt[1], facePt[2])
        glVertex3f(normalPt[0], normalPt[1],  normalPt[2])
        glEnd()