/*
Vector3 SteeringVehicle::predictFuturePosition(const float predictionTime) const
{
	//return position() +(velocity() * predictionTime);
	return getVelocity() * predictionTime;
}
*/
Vector3 SteeringVehicle::adjustRawSteeringForce(const Vector3& force)
{
    const float maxAdjustedSpeed = 0.2f * getMaxSpeed();

    if ((getSpeed() > maxAdjustedSpeed) ||(force == Vector3::ZERO))
    {
        return force;
    }
    else
    {
        const float range = getSpeed() / maxAdjustedSpeed;
        // const float cosine = interpolate(pow(range, 6), 1.0f, -1.0f);
        // const float cosine = interpolate(pow(range, 10), 1.0f, -1.0f);
        // const float cosine = interpolate(pow(range, 20), 1.0f, -1.0f);
        // const float cosine = interpolate(pow(range, 100), 1.0f, -1.0f);
        // const float cosine = interpolate(pow(range, 50), 1.0f, -1.0f);
        const float cosine = interpolate(pow(range, 20), 1.0f, -1.0f);
        return limitMaxDeviationAngle(force, cosine, getForward());
    }
}
Exemplo n.º 2
0
OpenSteer::Vec3 
OpenSteer::SimpleVehicle::adjustRawSteeringForce (const Vec3& force,
                                                  const float /* deltaTime */)
{
    const float maxAdjustedSpeed = 0.2f * maxSpeed ();

    if ((speed () > maxAdjustedSpeed) || (force == Vec3::zero))
    {
        return force;
    }
    else
    {
        const float range = speed() / maxAdjustedSpeed;
        // const float cosine = interpolate (pow (range, 6), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 10), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 20), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 100), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 50), 1.0f, -1.0f);
        const float cosine = interpolate (pow (range, 20), 1.0f, -1.0f);
        return limitMaxDeviationAngle (force, cosine, forward());
    }
}