protected bool isCollidingWalls(CObject cobject2)
        {
            BoundingBox BB1, BB2;

            foreach (ModelMesh mesh in model.Meshes)
            {
                BoundingSphere m1BoundingSphere = mesh.BoundingSphere;
                m1BoundingSphere.Center  = position;
                m1BoundingSphere.Radius *= this.scale;
                BB1 = BoundingBox.CreateFromSphere(m1BoundingSphere);
                foreach (ModelMesh mesh2 in cobject2.Model.Meshes)
                {
                    BB2 = CalculateBoundingBox(cobject2);
                    if (cobject2.ID == "floor")
                    {
                        if (i == 0)
                        {
                            Console.WriteLine(BB2.Max);
                            Console.WriteLine(BB2.Min);
                            Console.WriteLine(position);
                        }
                        i++;
                        if (i > 10)
                        {
                            i = 0;
                        }
                    }
                    if (BB1.Intersects(BB2))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        /*private BoundingBox createMerged(Model model) // Use it for low quality computers.
         * {
         *  BoundingBox b = new BoundingBox();
         *  BoundingBox aux;
         *  foreach (ModelMesh mesh in model.Meshes)
         *  {
         *      aux = BoundingBox.CreateFromSphere(mesh.BoundingSphere);
         *      BoundingBox.CreateMerged(b, aux);
         *  }
         *  return b;
         * }*/
        /*protected bool isCollidingBB(Model model2)
         * {
         *  BoundingBox BB1, BB2;
         *  BB1 = CalculateBoundingBox(this.model);
         *  BB2 = CalculateBoundingBox(model2);
         *  if (BB1.Intersects(BB2))
         *  {
         *      Console.WriteLine(BB1.GetCorners());
         *      Console.WriteLine(BB2.GetCorners());
         *      Console.WriteLine(BB1.Min + " - " + BB1.Max);
         *      Console.WriteLine(BB2.Min + " - " + BB2.Max);
         *      return true;
         *  }
         *  return false;
         * }*/
        protected bool isCollidingBB(CObject cobject2)
        {
            BoundingBox BB1, BB2;

            foreach (ModelMesh mesh in model.Meshes)
            {
                BoundingSphere m1BoundingSphere = mesh.BoundingSphere;
                m1BoundingSphere.Center  = position;
                m1BoundingSphere.Radius *= this.scale;
                BB1 = BoundingBox.CreateFromSphere(m1BoundingSphere);
                foreach (ModelMesh mesh2 in cobject2.Model.Meshes)
                {
                    BoundingSphere m2BoundingSphere = mesh2.BoundingSphere;
                    m2BoundingSphere.Center = cobject2.position;
                    if (cobject2.ID == "floor" || cobject2.ID.Contains("wall"))
                    {
                        m2BoundingSphere.Radius *= cobject2.scale * 30.0f;
                    }
                    else
                    {
                        m2BoundingSphere.Radius *= cobject2.scale;
                    }
                    BB2 = BoundingBox.CreateFromSphere(m2BoundingSphere);

                    if (BB1.Intersects(BB2))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
            public static ByteBuffer operator +(ByteBuffer BB1, ByteBuffer BB2)
            {
                ByteBuffer newBuffer = new ByteBuffer(BB1.Data());

                newBuffer.Append(BB2);

                return(newBuffer);
            }
Beispiel #4
0
 public static bool operator !=(ByteBuffer BB1, ByteBuffer BB2)
 {
     if (object.ReferenceEquals(BB1, null))
     {
         return(!object.ReferenceEquals(BB2, null));
     }
     if (object.ReferenceEquals(BB2, null))
     {
         return(true);
     }
     return(BB1.Compare(BB2) != 0);
 }
        /*private BoundingBox createMerged(Model model) // Use it for low quality computers.
         * {
         *  BoundingBox b = new BoundingBox();
         *  BoundingBox aux;
         *  foreach (ModelMesh mesh in model.Meshes)
         *  {
         *      aux = BoundingBox.CreateFromSphere(mesh.BoundingSphere);
         *      BoundingBox.CreateMerged(b, aux);
         *  }
         *  return b;
         * }*/
        protected bool isCollidingBB(Model model2)
        {
            BoundingBox BB1, BB2;

            foreach (ModelMesh mesh in model.Meshes)
            {
                BB1 = BoundingBox.CreateFromSphere(mesh.BoundingSphere);
                foreach (ModelMesh mesh2 in model2.Meshes)
                {
                    BB2 = BoundingBox.CreateFromSphere(mesh2.BoundingSphere);
                    if (BB1.Intersects(BB2))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }