// reset state void LowSpeedTurn::reset(){ // reset vehicle state SimpleVehicle::reset(); // speed along Forward direction. speed(startSpeed); // initial position along X axis position(startX, 0, 0); // steering force clip magnitude maxForce(0.3f); // velocity clip magnitude maxSpeed(1.5f); // for next instance: step starting location startX += 2; // for next instance: step speed startSpeed += 0.15f; // 15 seconds and 150 points along the trail setTrailParameters(15, 150); clearTrailHistory(); // prevent long streaks due to teleportation // load the mesh Mesh = getMesh_VehicleDisk(); Box = Mesh.getBoundingbox(); setScale(irr::core::vector3df(2.0, 1.0, 2.0)); // disable lighting Material.Lighting = false; }
//----------------------------------------------------------------------------- // reset all instance state void Pedestrian::reset (void) { float currRadius = radius(); // reset the vehicle // but keep the radius SteeringVehicle::reset (); setRadius( currRadius ); // max speed and max steering force (maneuverability) // setMaxSpeed (2.0); setMaxForce (8.0); setMaxSpeed (4.0f * currRadius); // setMaxForce (16.0f * currRadius); // initially stopped setSpeed (0); // // size of bounding sphere, for obstacle avoidance, etc. // setRadius (0.5); // width = 0.7, add 0.3 margin, take half // set the path for this Pedestrian to follow // path = getTestPath (); if( path != NULL ) { // set initial position // (random point on path + random horizontal offset) const float d = path->length() * frandom01(); const float r = path->radius(); const osVector3 randomOffset = randomVectorOnUnitRadiusXZDisk () * r; setPosition( path->mapPathDistanceToPoint (d) + randomOffset ); } // randomize 2D heading #if OPENSTEER_Z_ISUP randomizeHeadingOnXYPlane (); #else randomizeHeadingOnXZPlane (); #endif // pick a random direction for path following (upstream or downstream) pathDirection = (frandom01() > 0.5) ? -1 : +1; // trail parameters: 3 seconds with 60 points along the trail setTrailParameters (3, 60); // notify proximity database that our position has changed if( _proximityToken != nullptr) { _proximityToken->updateForNewPosition(position()); } #if 0 // notify the update states _steeringForceUpdate.setVehicle( this ); _eulerUpdate.setVehicle( this ); #endif }