예제 #1
0
        public Matrix3x3(SharpDX.Matrix3x3 m)
        {
            M11 = m.M11;
            M12 = m.M12;
            M13 = m.M13;
            M14 = 0;

            M21 = m.M21;
            M22 = m.M22;
            M23 = m.M23;
            M24 = 0;

            M31 = m.M31;
            M32 = m.M32;
            M33 = m.M33;
            M34 = 1;
        }
예제 #2
0
        public void Setup(Vector3D origin, Matrix4x4 m, bool change = true, float yaw = 0, float pitch = 0, float roll = 0)
        {
            Matrix3x3 yawMat   = new Matrix3x3();
            Matrix3x3 pitchMat = new Matrix3x3();
            Matrix3x3 rollMat  = new Matrix3x3();

            if (yaw != 0)
            {
                float cosY = (float)Math.Cos(yaw);
                float sinY = (float)Math.Sin(yaw);

                float cosX = (float)Math.Cos(pitch);
                float sinX = (float)Math.Sin(pitch);

                float cosZ = (float)Math.Cos(roll);
                float sinZ = (float)Math.Sin(roll);

                pitchMat = new Matrix3x3(new[]
                {
                    cosX, -sinX, 0,
                    sinX, cosX, 0,
                    0, 0, 1
                });

                yawMat = new Matrix3x3(new[]
                {
                    cosY, 0, sinY,
                    0, 1, 0,
                    -sinY, 0, cosY
                });

                rollMat = new Matrix3x3(new[]
                {
                    1, 0, 0,
                    0, cosZ, -sinZ,
                    0, sinZ, cosZ
                });

                pitchMat.Transpose();
                yawMat.Transpose();
                rollMat.Transpose();
            }

            for (int i = 0; i < 8; ++i)
            {
                Vector3D n = corners[i];

                if (change)
                {
                    if (yaw == 0)
                    {
                        Matrix3x3 m2 = new Matrix3x3(new[]
                        {
                            m.M11, m.M12, m.M13,
                            m.M21, m.M22, m.M23,
                            m.M31, m.M32, m.M33,
                        });

                        m2.Transpose();
                        n *= new MemLibs.Matrix3x3(m2);
                    }
                    else
                    {
                        n *= new MemLibs.Matrix3x3(yawMat);
                        n *= new MemLibs.Matrix3x3(pitchMat);
                        n *= new MemLibs.Matrix3x3(rollMat);
                    }
                }

                corners[i]  = new Vector3D(n.X, n.Y, n.Z);
                corners[i] += origin;
            }
        }
예제 #3
0
        public void DrawAxisAlignedBoundingBox(Player p, AxisAlignedBox aabb = null, bool isVehicle = false, Color drawColor = new Color(), bool c = false)
        {
            if (aabb == null)
            {
                aabb = p.GetAAB();
                if (p.SoldierTransform.M44 == 100f)
                {
                    Matrix3x3 matrixx = new Matrix3x3(new[] { p.SoldierTransform.M11, p.SoldierTransform.M12, p.SoldierTransform.M13, p.SoldierTransform.M21, p.SoldierTransform.M22, p.SoldierTransform.M23, p.SoldierTransform.M31, p.SoldierTransform.M32, p.SoldierTransform.M33 });
                    matrixx.Transpose();
                    float[] vals = new float[0x10];
                    vals[0]            = matrixx.M11;
                    vals[1]            = matrixx.M12;
                    vals[2]            = matrixx.M13;
                    vals[3]            = p.SoldierTransform.M41;
                    vals[4]            = matrixx.M21;
                    vals[5]            = matrixx.M22;
                    vals[6]            = matrixx.M23;
                    vals[7]            = p.SoldierTransform.M42;
                    vals[8]            = matrixx.M31;
                    vals[9]            = matrixx.M32;
                    vals[10]           = matrixx.M33;
                    vals[11]           = p.SoldierTransform.M43;
                    vals[15]           = 1f;
                    p.SoldierTransform = new Matrix4x4(vals);
                }
            }
            if (p.Team == overlay.LocalPlayer.Team)
            {
                overlay.solidColorBrush.Color = isVehicle ? Color.CadetBlue : Color.LimeGreen;
            }
            else if (!p.IsOccluded)
            {
                overlay.solidColorBrush.Color = Color.Yellow;
            }
            else
            {
                overlay.solidColorBrush.Color = isVehicle ? Color.OrangeRed : Color.Red;
            }

            if (c)
            {
                overlay.solidColorBrush.Color = drawColor;
            }

            for (int i = 0; i < 8; i++)
            {
                aabb.corners[i] = overlay.WorldToScreen(aabb.corners[i]);
                if (aabb.corners[i].Z < 0.5)
                {
                    return;
                }
            }

            overlay.device.DrawLine(new Vector2(aabb.corners[0].X, aabb.corners[0].Y), new Vector2(aabb.corners[1].X, aabb.corners[1].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[5].X, aabb.corners[5].Y), new Vector2(aabb.corners[6].X, aabb.corners[6].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[0].X, aabb.corners[0].Y), new Vector2(aabb.corners[5].X, aabb.corners[5].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[1].X, aabb.corners[1].Y), new Vector2(aabb.corners[6].X, aabb.corners[6].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[3].X, aabb.corners[3].Y), new Vector2(aabb.corners[2].X, aabb.corners[2].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[4].X, aabb.corners[4].Y), new Vector2(aabb.corners[7].X, aabb.corners[7].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[3].X, aabb.corners[3].Y), new Vector2(aabb.corners[4].X, aabb.corners[4].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[2].X, aabb.corners[2].Y), new Vector2(aabb.corners[7].X, aabb.corners[7].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[3].X, aabb.corners[3].Y), new Vector2(aabb.corners[0].X, aabb.corners[0].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[4].X, aabb.corners[4].Y), new Vector2(aabb.corners[5].X, aabb.corners[5].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[1].X, aabb.corners[1].Y), new Vector2(aabb.corners[2].X, aabb.corners[2].Y), overlay.solidColorBrush);
            overlay.device.DrawLine(new Vector2(aabb.corners[6].X, aabb.corners[6].Y), new Vector2(aabb.corners[7].X, aabb.corners[7].Y), overlay.solidColorBrush);
        }