コード例 #1
0
        //TODO solve IK and tick normal in different methods
        public override void tick(float dt)
        {
            Vector3 targetLocal = targetAbs.v - basisAbs.v;
            float   pole        = -targetLocal.normalized.scalarProduct(axisAbs);
            float   mul         = MyMath.mix(rotSpeedAtEquator, rotSpeedAtPole, pole) * dt;
            Vector3 n           = axisAbs;

            if (Application.isPlaying) //for battle mech 2 TODO place elbow at custom position
            {
                if (poleAxisStrength > 0)
                {
                    n = n + secondaryAxisAbs.mul(pole * poleAxisStrength);
                }
            }
            resultAbs.v = lastResult.mix(targetLocal.crossProduct(n).normalized(), MyMath.min(mul, 1)).normalized;
            lastResult  = resultAbs.v;
        }
コード例 #2
0
 public static Vector3 clamp(Vector3 value, float min, float max)
 {
     return(new Vector3(MyMath.max(min, MyMath.min(value.x, max)), MyMath.max(min, MyMath.min(value.y, max)), MyMath.max(min, MyMath.min(value.z, max))));
 }
コード例 #3
0
 public static float clamp(float value, float min, float max)
 {
     return(MyMath.max(min, MyMath.min(value, max)));
 }
コード例 #4
0
 public static Vector2 clamp(Vector2 value, Vector2 min, Vector2 max)
 {
     return(new Vector2(MyMath.max(min.x, MyMath.min(value.x, max.x)), MyMath.max(min.y, MyMath.min(value.y, max.y))));
 }
コード例 #5
0
 public static Vector3 pow(this Vector3 a, float x, float y, float z)
 {
     return(new Vector3(MyMath.pow(a.x, x), MyMath.pow(a.y, y), MyMath.pow(a.z, z)));
 }