40 lines
685 B
C#
40 lines
685 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class Plot3DMotorFunc : Plot3DFunction
|
|
{
|
|
public CarEngine engine;
|
|
public bool power;
|
|
|
|
public Car car;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
}
|
|
|
|
public override float f(float x, float y)
|
|
{
|
|
if (engine == null)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
var t= (float)engine.GetTorque(Mathf.Clamp01(car.throlleCurve.Evaluate(y)), x);
|
|
|
|
if (!power)
|
|
{
|
|
return t;
|
|
}
|
|
|
|
|
|
return (float)MathEx.Power(t, MathEx.RpmToRadS * x) / 1000;
|
|
//return (x*x*y*y)*1000;
|
|
}
|
|
}
|