Example #1
0
        bool CheckCollision(ref Mesh m1, ref Mesh m2)
        {
            BoundingSphere c1BoundingSphere = m1.GetBoundingSphere();
            BoundingSphere c2BoundingSphere = m2.GetBoundingSphere();

            if (c1BoundingSphere.Intersects(c2BoundingSphere))
            {
                return true;
            }

            return false;
        }
Example #2
0
        //---------------------------------------
        // Collision methods
        //---------------------------------------
        public bool CollidesWithMesh(Mesh m)
        {
            if (m_Model == null)
                return false;

            // Check whether the bounding boxes of the two cubes intersect.
            BoundingSphere bs1 = GetBoundingSphere();
            BoundingSphere bs2 = m.GetBoundingSphere();

            if (bs1.Intersects(bs2))
                return true;

            return false;
        }
Example #3
0
        public bool Init(Vector3 position, Vector3 rotation, string model_name)
        {
            m_Mesh = new Mesh();
            m_Mesh.SetPosition(position);
            m_Mesh.SetRotation(rotation);

            Random r = new Random();

            for (int i = 0; i < 10; i++)
            {
                int xValue = r.Next(-1000, 1000);
                int zValue = r.Next(-1000, 1000);

                ItemArea itemArea = new ItemArea();
                itemArea.Init(new Vector3(xValue, 100.0f, zValue), Vector3.Zero);

                m_ItemAreaList.Add(itemArea);
            }

            Vector3 cp_position = Vector3.Zero;
            float rot = 0.0f;

            for (int i = 0; i < 8; i++)
            {
                cp_position = new Vector3(30000, 0, 0);
                rot += MathHelper.TwoPi / 8;

                CheckPoint cp = new CheckPoint();
                cp_position = Vector3.Transform(cp_position, Matrix.CreateFromYawPitchRoll(rot, 0, 0));
                cp.Init(this, null, cp_position, new Vector3(0.0f, rot, 0.0f), false, i);

                m_CheckPointList.Add(cp);
            }

            return m_Mesh.Load(model_name);
        }
Example #4
0
        public void OnExit(Mesh m)
        {
            // we detect that the player is going backwards
            Player p = PlayerManager.GetInstance().GetPlayerByVehicleMesh(m);

            if (p != null)
            {
                // we first check the direction of the player movement and the direction of the checpoint
                Vector3 vel = p.GetVelocity();
                vel.Normalize();
                float dot = Vector3.Dot(vel, m_vDirection);

                if (dot < 0.0)
                    m_Circuit.OnPlayerBackwardCheckpoint(p, this);
            }
        }
Example #5
0
 public FindPlayerVehicleMesh(Mesh _m)
 {
     m = _m;
 }
Example #6
0
 public Player GetPlayerByVehicleMesh(Mesh m)
 {
     return m_PlayerList.Find(new FindPlayerVehicleMesh(m).CompareMesh);
 }
Example #7
0
        public void OnEnter(Mesh m)
        {
            --m_iLife;

            if (!m_MeshesInside.Contains(m))
            {
                Debug.Print("==============> Entering trigger");
                m_MeshesInside.Add(m);

                foreach (IObserver o in m_Observers)
                {
                    o.OnEnter(m);
                }
            }
        }
Example #8
0
 public bool IsInside(Mesh m)
 {
     return m_MeshesInside.Contains(m);
 }
Example #9
0
 public void OnExit(Mesh m)
 {
     Debug.Print("==============> Exiting trigger");
     foreach (IObserver o in m_Observers)
     {
         o.OnExit(m);
     }
 }