Exemplo n.º 1
0
        public static FMat4 View(FVec3 position, FVec3 lookAt, FVec3 upVector)
        {
            FVec3 forward = FVec3.Normalize(lookAt - position);
            FVec3 xVec    = FVec3.Normalize(forward.Cross(upVector));

            upVector = xVec.Cross(forward);

            FMat4 result;

            result.x.x = xVec.x;
            result.x.y = xVec.y;
            result.x.z = xVec.z;
            result.x.w = position.Dot(-xVec);

            result.y.x = upVector.x;
            result.y.y = upVector.y;
            result.y.z = upVector.z;
            result.y.w = position.Dot(-upVector);

            result.z.x = -forward.x;
            result.z.y = -forward.y;
            result.z.z = -forward.z;
            result.z.w = position.Dot(forward);

            result.w.x = Fix64.Zero;
            result.w.y = Fix64.Zero;
            result.w.z = Fix64.Zero;
            result.w.w = Fix64.One;

            return(result);
        }
Exemplo n.º 2
0
        public static FMat3 LookAt(FVec3 forward, FVec3 up)
        {
            FVec3 z = FVec3.Normalize(forward);
            FVec3 x = FVec3.Normalize(up.Cross(z));
            FVec3 y = z.Cross(x);

            return(new FMat3(x, y, z));
        }
Exemplo n.º 3
0
        public void Vector()
        {
            FVec3 fv  = new FVec3(12.5f, 9, 8);
            FVec3 fv2 = new FVec3(4, 6, 9);
            Vec3  v   = new Vec3(12.5f, 9, 8);
            Vec3  v2  = new Vec3(4, 6, 9);

            this._output.WriteLine((fv * fv2).ToString());
            this._output.WriteLine((v * v2).ToString());
            fv += fv2;
            v  += v2;
            this._output.WriteLine(fv.ToString());
            this._output.WriteLine(v.ToString());
            this._output.WriteLine((fv - fv2).ToString());
            this._output.WriteLine((v - v2).ToString());
            this._output.WriteLine(fv.Dot(fv2).ToString());
            this._output.WriteLine(v.Dot(v2).ToString());
            this._output.WriteLine(fv.Cross(fv2).ToString());
            this._output.WriteLine(v.Cross(v2).ToString());
            this._output.WriteLine(FVec3.Normalize(fv).ToString());
            this._output.WriteLine(Vec3.Normalize(v).ToString());
            this._output.WriteLine(FVec3.Slerp(fv, fv2, ( Fix64 )0.45678).ToString());
            this._output.WriteLine(Vec3.Slerp(v, v2, 0.45678f).ToString());
        }