/** * This method reads the config-file for the JointJointInteraction-module * @param fileName location of the config-file **/ void JointInteraction::readConfig(std::string fileName) { std::string ConcatenatedPath = getConcatenatedPath(fileName, "JointConfiguration"); if(!fileExists(ConcatenatedPath)) { printd(ERROR, "JointInteraction::readConfig(): cannot read from file %s\n", ConcatenatedPath.c_str()); return; } // if IrrXMLReader* xml = createIrrXMLReader(ConcatenatedPath.c_str()); if (!xml) { printd(ERROR, "JointInteraction::readConfig(): ERROR: could not find config-file %s\n", ConcatenatedPath.c_str()); return; } // if printd(INFO, "JointInteraction::readConfig(): loading from file: %s\n", fileName.c_str()); while (xml && xml->read()) { switch (xml->getNodeType()) { case EXN_ELEMENT: if (!strcmp("jointInteraction", xml->getNodeName())) { // Root node } // if else if (!strcmp("config", xml->getNodeName())) { loadConfig(xml); } // else if else if (!strcmp("joints", xml->getNodeName())) { loadJoints(xml); } // else if else { printd(WARNING, "JointInteraction::readConfig(): WARNING: unknown element with name %s found!\n", xml->getNodeName()); } // else break; default: break; } // switch } // while delete xml; } // readConfig
/** * DrawNeutral function. * * This function draws the stick figure depending on the * transforming stage of the player or draws a diamond if the * player is not tracked. * * @param player is the ID of the player. * */ void NeutralModel :: drawNeutral (XnUserID player) { // UserGenerator. UserGenerator userGen; // Color of the stick figure. XnFloat color[3]; // Material properties. GLfloat mat_specular[] = { 0.3, 0.3, 0.3, 0.3 }; GLfloat mat_shininess[] = { 10.0 }; // Center of mass. XnPoint3D com; // Player's stage. int stage; float ax; Vector3D a; Vector3D b; Vector3D c; Vector3D u; Vector3D v; Vector3D w; GLuint mode; // Select the players color according his ID. color[0] = Colors[player % nColors][0]; color[1] = Colors[player % nColors][1]; color[2] = Colors[player % nColors][2]; // Set the material for the stick figure. GLfloat materialColor[] = {color[0], color[1], color[2], 1.0f}; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColor); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); userGen = nm_UserDetector -> retUserGenerator(); SkeletonCapability skelCap = userGen.GetSkeletonCap(); mode = GLM_SMOOTH | GLM_MATERIAL; a = Vector3D(joint[LSHOULDER]); b = Vector3D(joint[RSHOULDER]); c = Vector3D(joint[RHIP]); u = b - a; v = c - a; w = u.cross(v); w.y = 0.0; w.normalize(); ax = 57.2957795 * acos(w.z); if (w.x <= 0.0) { ax = -ax; } // Init the drawing process. // Draws a stick figure if player is been tracked. if (skelCap.IsTracking(player)) { // Get player's stage. stage = nm_UserDetector -> retStage(player); loadJoints(player, skelCap); // Drawing legs. if ((stage >= 0) && (stage < 4)) { // Left leg. glPushMatrix(); orientMatrix(joint[RHIP],joint[RKNEE]); glTranslatef( 0.0, 0.0, 50.0); glScalef(250.0, 250.0, 250.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.thigh, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[RKNEE],joint[RFOOT]); glTranslatef( 0.0, 0.0, 50.0); glScalef(100.0, 100.0, 100.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.leg, mode); glPopMatrix(); // Right leg. glPushMatrix(); orientMatrix(joint[LHIP], joint[LKNEE]); glTranslatef( 0.0, 0.0, 50.0); glScalef(-250.0, 250.0, 250.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.thigh, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[LKNEE], joint[LFOOT]); glTranslatef( 0.0, 0.0, 50.0); glScalef(-100.0, 100.0, 100.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.leg, mode); glPopMatrix(); // Foots. glPushMatrix(); glTranslatef( joint[LFOOT].X, joint[LFOOT].Y, joint[LFOOT].Z); glScalef(40.0,-40.0,-40.0); glRotatef(ax, 0.0,-1.0, 0.0); glTranslatef(0.0,-0.25, 0.5); glmDraw(zamusModelParts.foot, mode); glPopMatrix(); glPushMatrix(); glTranslatef( joint[RFOOT].X, joint[RFOOT].Y, joint[RFOOT].Z); glScalef(-40.0,-40.0,-40.0); glRotatef(-ax, 0.0,-1.0, 0.0); glTranslatef(0.0,-0.25, 0.5); glmDraw(zamusModelParts.foot, mode); glPopMatrix(); } else { drawLimp(joint[LKNEE],joint[LFOOT]); drawLimp(joint[RKNEE],joint[RFOOT]); drawLimp(joint[LHIP],joint[LKNEE]); drawLimp(joint[RHIP],joint[RKNEE]); } // Draw torso. if ((stage > 0) && (stage < 4)) { glPushMatrix(); orientMatrix(joint[NECK],joint[TORSO]); glScalef(400.0, 400.0, 400.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(ax, 0.0,-1.0, 0.0); glTranslatef(0.0, -0.1, 0.0); glmDraw(zamusModelParts.chest, mode); glPopMatrix(); } else { drawTorso(); } // Drawing arms. if (stage == 2) { // Shoulders glPushMatrix(); glTranslatef(joint[LSHOULDER].X, joint[LSHOULDER].Y, joint[LSHOULDER].Z); glRotatef(-ax, 0.0,-2.0, 0.0); glTranslatef(-30.0,-40.0, 0.0); glScalef(500.0,-500.0, 500.0); glmDraw(zamusModelParts.shoulder, mode); glPopMatrix(); glPushMatrix(); glTranslatef(joint[RSHOULDER].X, joint[RSHOULDER].Y, joint[RSHOULDER].Z); glRotatef(-ax, 0.0,-1.0, 0.0); glTranslatef( 30.0,-40.0, 0.0); glScalef(500.0,-500.0, 500.0); glmDraw(zamusModelParts.shoulder, mode); glPopMatrix(); // LeftArm glPushMatrix(); orientMatrix(joint[RSHOULDER], joint[RELBOW]); glTranslatef( 0.0, 0.0, 50.0); glScalef(500.0, 500.0, 500.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.arm, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[RELBOW], joint[RHAND]); glTranslatef( 0.0, 0.0, 60.0); glScalef(250.0, 250.0, 250.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.forearm, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[LSHOULDER], joint[LELBOW]); glTranslatef( 0.0, 0.0, 50.0); glScalef(500.0, 500.0, 500.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.arm, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[LELBOW],joint[LHAND]); glTranslatef( 0.0, 0.0, 80.0); glScalef(300.0, 300.0, 300.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(zamusModelParts.cannon, mode); glPopMatrix(); } else if ((stage == 4) || (stage == 5)) { glPushMatrix(); glTranslatef(joint[LSHOULDER].X, joint[LSHOULDER].Y, joint[LSHOULDER].Z); glRotatef(-ax, 0.0,-2.0, 0.0); glScalef(500.0,-500.0, 500.0); glmDraw(linqModelParts.shoulder, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[LSHOULDER],joint[LELBOW]); glTranslatef( 0.0, 0.0, 50.0); glScalef(-180.0, 180.0, 180.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(linqModelParts.thigh, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[LELBOW],joint[LHAND]); glTranslatef( 0.0, 0.0, 50.0); glScalef(-80.0, 80.0, 80.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(linqModelParts.leg, mode); glPopMatrix(); } else { drawLimp(joint[LSHOULDER],joint[LELBOW]); drawLimp(joint[LELBOW],joint[LHAND]); } if (stage == 5) { glPushMatrix(); glTranslatef(joint[RSHOULDER].X, joint[RSHOULDER].Y, joint[RSHOULDER].Z); glRotatef(-ax, 0.0,-1.0, 0.0); glScalef(500.0,-500.0, 500.0); glmDraw(linqModelParts.shoulder, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[RSHOULDER],joint[RELBOW]); glTranslatef( 0.0, 0.0, 50.0); glScalef(350.0, 350.0, 350.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(ax, 0.0,-1.0, 0.0); glmDraw(linqModelParts.arm, mode); glPopMatrix(); glPushMatrix(); orientMatrix(joint[RELBOW],joint[RHAND]); glTranslatef( 0.0, 0.0, 60.0); glScalef(250.0, 250.0, 250.0); glRotatef(90, -1.0, 0.0, 0.0); glRotatef(-ax, 0.0,-1.0, 0.0); glmDraw(linqModelParts.forearm, mode); glPopMatrix(); } else { drawLimp(joint[RSHOULDER],joint[RELBOW]); drawLimp(joint[RELBOW],joint[RHAND]); } // Draw head. drawHead(); } // Draws a diamond in the player's center of mass. else { userGen.GetCoM(player, com); nm_DepthGenerator.ConvertRealWorldToProjective(1, &com, &com); glPushMatrix(); glTranslatef(com.X, com.Y, com.Z); glutSolidSphere(60.0, 4, 2); glPopMatrix(); } }