/** this method is used to write the reduced state of the character to a file */ void Character::saveReducedStateToFile(char* fName, ReducedCharacterStateArray& state){ // Update joint order updateJointOrdering(); if (fName == NULL) throwError("cannot write to a file whose name is NULL!"); FILE* fp = fopen(fName, "w"); if (fp == NULL) throwError("cannot open the file \'%s\' for writing...", fName); //retrieve the current heading, write it to file, and then set a zero heading for the state double heading = getHeadingAngle(); setHeading(Quaternion::getRotationQuaternion(0, PhysicsGlobals::up), &state); fprintf(fp, "# order is:\n# Heading\n# Position\n# Orientation\n# Velocity\n# AngularVelocity\n\n# Relative Orientation\n# Relative Angular Velocity\n#----------------\n\n# Heading\n%lf\n\n# Root(%s)\n", heading, root->name); fprintf(fp, "%lf %lf %lf\n", state[0], state[1], state[2]); fprintf(fp, "%lf %lf %lf %lf\n", state[3], state[4], state[5],state[6]); fprintf(fp, "%lf %lf %lf\n", state[7], state[8], state[9]); fprintf(fp, "%lf %lf %lf\n\n", state[10], state[11], state[12]); for (uint i=0;i<joints.size();i++){ fprintf(fp, "# %s\n", joints[jointOrder[i]]->name); fprintf(fp, "%lf %lf %lf %lf\n", state[13+7*i+0], state[13+7*i+1], state[13+7*i+2],state[13+7*i+3]); fprintf(fp, "%lf %lf %lf\n", state[13+7*i+4], state[13+7*i+5], state[13+7*i+6]); fprintf(fp, "\n"); } fclose(fp); }
//Rams Ai hitting steering direct void COpponentVehicle::InterpolateSteeringAngle(float deltaT) { //Override of Chris's Interpolate Steering from vehicle.cpp // Based on the ai input, we will interpolate // the front tires' rotation about the local Z axis. // We don't want the wheels to turn instantaneously from // 0 - 40 DEGS, we want them to get over the course of about // 1 or 2 seconds. These values need to be tweaked. // Positive rotation, rotates counterclockwise around the Z axis. // Negative rotation, rotates clockwise around the Z axis. float angle = getHeadingAngle(); float pi = 3.14159; float speedScalar = 1 - velocityLC.X() / 60.0f; float maxTurnAngle = (MAX_STEER_ANGLE_RADS - MIN_STEER_ANGLE_RADS) * speedScalar + MIN_STEER_ANGLE_RADS; if(inputState.lturn) { if(angle > maxTurnAngle) { steerAngleRADS = maxTurnAngle; //CLog::GetLog().Write(LOG_DEBUGOVERLAY, 118, "MAX LEFT HIT!"); } else { //CLog::GetLog().Write(LOG_DEBUGOVERLAY, 118, "NO MAX"); steerAngleRADS = angle; } } else if(inputState.rturn) { if(angle < (maxTurnAngle * -1.0f)) { // CLog::GetLog().Write(LOG_DEBUGOVERLAY, 118, "MAX RIGHT HIT!"); steerAngleRADS = maxTurnAngle * (-1.0f); } else { steerAngleRADS = angle *-1; } } }