void print( const PlayerT & player ) { if ( player.state_ ) { std::cout << "<Player side=\"" << player.side_ << "\""; std::cout << " unum=\"" << player.unum_ << "\""; std::cout << " type=\"" << player.type_ << "\""; if ( player.state_ != 1 ) std::cout << " mode=\"" << player.state_ << "\""; std::cout << ">\n"; printPos( player.x_, player.y_ ); printVel( player.vx_, player.vy_ ); printAngles( player.body_, player.neck_ ); printView( player.view_width_, player.view_quality_ == 'h' ); printStamina( player.stamina_, player.effort_, player.recovery_ ); printCounts( player.kick_count_, player.dash_count_, player.turn_count_, player.say_count_, player.turn_neck_count_, player.catch_count_, player.move_count_, player.change_view_count_ ); std::cout << "</Player>\n"; } }
int main(int argc, char **argv) { linkDLLs(); FILE *fp; if(argc < 2) { fp = stdin; } else { fp = fopen(argv[1], "r"); } molecule_t *mol; input(&mol, fp); printDists(mol); printAngles(mol); printMoments(mol); printRotor(mol); fclose(fp); deleteMolecule(mol); unlinkDLLs(); return (0); }
void sample_layout_1::calculateAnglesAndPrint(int label, float O, float A, float *theta, float thetaDegrees){ calculateAngles(O, A, *theta, thetaDegrees); printAngles(label, O, A, *theta, thetaDegrees); }
void printAngles( double body, double head ) { printAngles( body ); std::cout << "<HeadAng>" << head << "</HeadAng>\n"; }
void Kitten::draw() const { // Retrieve the current (interpolated) pose of the kitten. Pose pose = getPose(); // incase we have no pose angles set default to all zero if (pose.angles_.size() <NUM_ANGLES){ for (int i =pose.angles_.size();i<NUM_ANGLES;i++){ pose.angles_.push_back(0.0); } } if (DEBUG){ printed++; std::cout << pose.x_ << ", " << pose.y_ << ", " << pose.z_ << " x,y,z" << std::endl; int i =0; //for (std::vector<double>::iterator it = pose.angles_.begin(); it != pose.angles_.end();it++){ ////for (int i = 0; i < pose.angles_.size(); i++) { // std::cout << "\t" << i++ << "\t" << *it << '\n'; //} printAngles(&pose.angles_); } // The kitten should be dark brown. glColor4d(0.46f, 0.3f, 0.13f, 1); // @@@@ Add your own code to draw the kitten. You might want to split // @@@@ this into multiple functions for drawing different parts of the // @@@@ creature. GLfloat overlap = .2; // factor to adjust object seperation down by // midsection glPushMatrix(); // global matrix save glTranslatef(pose.x_,pose.y_,pose.z_); GLfloat midXRadius = .8; GLfloat midYRadius = .8; GLfloat midZRadius = .6; GLfloat midx = 0; GLfloat midy = 0; GLfloat midz = 0; glRotatef(pose.angles_[BODY_ANGLE],0,0,1); glRotatef(pose.angles_[BODY_ROTX],1,0,0); glRotatef(pose.angles_[BODY_ROTY],0,1,0); drawEllipse(midXRadius,midYRadius,midZRadius); // chest GLfloat ChestXRadius = .8; GLfloat ChestYRadius = 1.0; GLfloat ChestZRadius = .7; GLfloat Chestx = ChestXRadius + midXRadius; GLfloat Chesty = midy; GLfloat Chestz = midz; glTranslatef(midXRadius,0,0); glRotatef(pose.angles_[SHOULDERS], 0,0,1); glRotatef(pose.angles_[SHOULDER_X], 1,0,0); glRotatef(pose.angles_[SHOULDER_Y], 0,1,0); //glTranslatef(Chestx*(1-overlap),Chesty,Chestz); glTranslatef(ChestXRadius*(1-overlap),Chesty,Chestz); drawEllipse(ChestXRadius,ChestYRadius,ChestZRadius); glPushMatrix();// save Chest center for legs after done with head // head GLfloat headXRadius = .6; GLfloat headyRadius = .4; GLfloat headzRadius = .6; GLfloat headWRTchestAngle=45; //GLfloat headx = ChestXRadius*(cos(headWRTchestAngle))+headXRadius; //GLfloat heady = ChestXRadius*sin(headWRTchestAngle)+headyRadius; //GLfloat headz = Chestz; //GLfloat headRotationCntrx = ChestXRadius*(cos(headWRTchestAngle)*cos(headWRTchestAngle))*(1-overlap);//wrt chest //GLfloat headRotationCntry = ChestYRadius*(sin(headWRTchestAngle)*sin(headWRTchestAngle))*(1-overlap); GLfloat headRotationCntrx = ChestXRadius*ChestXRadius*(cos(headWRTchestAngle)*cos(headWRTchestAngle));//wrt chest GLfloat headRotationCntry = ChestYRadius*ChestYRadius*(sin(headWRTchestAngle)*sin(headWRTchestAngle)); GLfloat headRotationCntrz = 0; glTranslatef(headRotationCntrx,headRotationCntry,headRotationCntrz); glRotatef(pose.angles_[HEAD], 0,0,1); glRotatef(pose.angles_[HEAD_X], 1,0,0); glRotatef(pose.angles_[HEAD_Y], 0,1,0); glTranslatef(headXRadius, headyRadius,midz); glPushMatrix(); // save head center for second ear drawEllipse(headXRadius,headyRadius,headzRadius); // right ear glTranslatef(-0.2*headXRadius, headyRadius*(1-overlap), headzRadius*.8); drawEllipse(.1,.25,.2); // left ear glPopMatrix(); // restore head center glTranslatef(-0.2*headXRadius, headyRadius*(1-overlap), -headzRadius*.8); drawEllipse(.1,.25,.2); //glPopMatrix(); // front legs glPopMatrix(); // restore chest center glPushMatrix(); // save chest center for second leg GLfloat thighxradius = .3; GLfloat thighyradius = .5; GLfloat thighzradius = .4; //right front thigh GLfloat rfThighxPos = 0; // wrt chest center GLfloat rfThighyPos = -ChestYRadius*.3; GLfloat rfThighzPos = ChestZRadius*1.0; glTranslatef(rfThighxPos,rfThighyPos,rfThighzPos); glRotatef(pose.angles_[FRONT_RIGHT_SHOULDER],0,0,1); glRotatef(pose.angles_[FR_SHOULDER_X],1,0,0); glTranslatef(0,-thighyradius,0); drawEllipse(thighxradius,thighyradius,thighzradius); //right front shin GLfloat shinxradius = .2; GLfloat shinyradius = .6; GLfloat shinzradius = .2; glTranslatef(0,-thighyradius,0); glRotatef(pose.angles_[FRONT_RIGHT_KNEE], 0,0,1); glTranslatef(0,-shinyradius*(1-overlap),0); drawEllipse(shinxradius,shinyradius,shinzradius); //left front thigh glPopMatrix(); // recover chest center for second leg GLfloat lfThighxPos = 0; // wrt chest center GLfloat lfThighyPos = -ChestYRadius*.3; GLfloat lfThighzPos = -ChestZRadius*1.0; glTranslatef(lfThighxPos,lfThighyPos,lfThighzPos); glRotatef(pose.angles_[FRONT_LEFT_SHOULDER],0,0,1); glRotatef(pose.angles_[FL_SHOULDER_X],1,0,0); glTranslatef(0,-thighyradius,0); drawEllipse(thighxradius,thighyradius,thighzradius); //left front shin glTranslatef(0,-thighyradius,0); glRotatef(pose.angles_[FRONT_LEFT_KNEE], 0,0,1); glTranslatef(0,-shinyradius*(1-overlap),0); drawEllipse(shinxradius,shinyradius,shinzradius); glPopMatrix(); // restore global glPushMatrix(); // save global // back legs // back right thigh glTranslatef(pose.x_,pose.y_,pose.z_); glRotatef(pose.angles_[BODY_ANGLE],0,0,1); glRotatef(pose.angles_[BODY_ROTX],1,0,0); glRotatef(pose.angles_[BODY_ROTY],0,1,0); GLfloat backThighXRadius = .5; GLfloat backThighYRadius = .6; GLfloat backThighZRadius = .3; glTranslatef(-midXRadius/2,-midYRadius/3*(1-overlap),midZRadius*(1-overlap)); glRotatef(pose.angles_[BACK_RIGHT_SHOULDER],0,0,1); glRotatef(pose.angles_[BR_SHOULDER_X],1,0,0); glTranslatef(0,-backThighYRadius,0); drawEllipse(backThighXRadius,backThighYRadius,backThighZRadius); // back right shin GLfloat backShinXRadius = .2; GLfloat backShinYRadius = .5; GLfloat backShinZRadius = .2; glTranslatef(0,-backThighYRadius,0); glRotatef(pose.angles_[BACK_RIGHT_KNEE],0,0,1); glTranslatef(0,-backShinYRadius*(1-overlap),0); drawEllipse(backShinXRadius,backShinYRadius,backShinZRadius); glPopMatrix(); // restore global glPushMatrix(); // save global // back left thigh glTranslatef(pose.x_,pose.y_,pose.z_); glRotatef(pose.angles_[BODY_ANGLE],0,0,1); glRotatef(pose.angles_[BODY_ROTX],1,0,0); glRotatef(pose.angles_[BODY_ROTY],0,1,0); glTranslatef(-midXRadius/2,-midYRadius/2*(1-overlap),-midZRadius*(1-overlap)); glRotatef(pose.angles_[BACK_LEFT_SHOULDER],0,0,1); glRotatef(pose.angles_[BL_SHOULDER_X],1,0,0); glTranslatef(0,-backThighYRadius,0); drawEllipse(backThighXRadius,backThighYRadius,backThighZRadius); // back left shin glTranslatef(0,-backThighYRadius,0); glRotatef(pose.angles_[BACK_LEFT_KNEE],0,0,1); glTranslatef(0,-backShinYRadius*(1-overlap),0); drawEllipse(backShinXRadius,backShinYRadius,backShinZRadius); glPopMatrix();// restore global glPushMatrix();// save global state GLfloat tailBaseXRadius = .40; GLfloat tailBaseYRadius = 0.15; GLfloat tailBaseZRadius = 0.15; GLfloat tailTipXRadius = .40; GLfloat tailTipYRadius = 0.15; GLfloat tailTipZRadius = 0.15; glTranslatef(pose.x_,pose.y_,pose.z_); glRotatef(pose.angles_[BODY_ANGLE],0,0,1); glRotatef(pose.angles_[BODY_ROTX],1,0,0); glRotatef(pose.angles_[BODY_ROTY],0,1,0); glTranslatef(-midXRadius,0,0); if (specialtailtype==0){ glRotatef(pose.angles_[TAIL_BASE],0,0,1); glTranslatef(-tailBaseXRadius*(1-overlap),0,0); drawEllipse(tailBaseXRadius,tailBaseYRadius,tailBaseZRadius); glTranslatef(-tailBaseXRadius,0,0); glRotatef(pose.angles_[TAIL_TIP],0,0,1); glTranslatef(-tailTipXRadius*(1-overlap),0,0); drawEllipse(tailTipXRadius,tailTipYRadius,tailTipZRadius); }else if (specialtailtype >=1){ int segments = 20; double segmentradius = 2*tailBaseXRadius/segments; for (int i = 0; i< segments;i++){ glRotatef(pose.angles_[TAIL_BASE]/segments,0,0,1); glTranslatef(-segmentradius*(1-overlap),-0,0); drawEllipse(tailBaseYRadius,tailBaseYRadius,tailBaseZRadius); } int tipreverse; if (specialtailtype==1) tipreverse=1; else tipreverse=-1; segmentradius = 2*tailTipXRadius/segments; glTranslatef(-segmentradius*(1-overlap),0,0); for (int i = 0; i< segments;i++){ glRotatef(pose.angles_[TAIL_TIP]/segments*tipreverse,0,0,1); glTranslatef(-segmentradius*(1-overlap),0,0); drawEllipse(tailBaseYRadius,tailTipYRadius,tailTipZRadius); } } glPopMatrix(); // restore global state GLint depth; glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth); // this should never exceed max (32 typical) and should // really be set back to one by the time we reach bottom of loop if (depth > lastdepth){ std::cout << "matrix depth: " << depth << std::endl; lastdepth = depth; } }