Example #1
0
        private bool WorldToScreen(UE.Vector3 _Enemy, out UE.Vector3 _Screen)
        {
            _Screen = new UE.Vector3(0, 0, 0);
            Numerics.Matrix4x4 temp = Numerics.Matrix4x4.Transpose(Memory.Read <Numerics.Matrix4x4>(Base.GetPtr(EFTCore.fpsCamera, new int[] { 0x30, 0x18, 0xC0 }).ToInt64()));

            UE.Vector3 translationVector = new UE.Vector3(temp.M41, temp.M42, temp.M43);
            UE.Vector3 up    = new UE.Vector3(temp.M21, temp.M22, temp.M23);
            UE.Vector3 right = new UE.Vector3(temp.M11, temp.M12, temp.M13);

            float w = D3DXVec3Dot(translationVector, _Enemy) + temp.M44;

            if (w < 0.098f)
            {
                return(false);
            }

            float y = D3DXVec3Dot(up, _Enemy) + temp.M24;
            float x = D3DXVec3Dot(right, _Enemy) + temp.M14;

            _Screen.x = (this.Width / 2) * (1f + x / w);
            _Screen.y = (this.Height / 2) * (1f - y / w);
            _Screen.z = w;

            return(true);
        }