Exemplo n.º 1
0
Arquivo: model.cs Projeto: er1/c376p1
        public bool IsCollisionBox(model model2)
        {
            if (this is projectile)
            {
                for (int meshIndex1 = 0; meshIndex1 < ((projectile)this).collisionModel.Meshes.Count; meshIndex1++)
                {
                    BoundingBox box1 = UpdateBoundingBox(((projectile)this).collisionModel, this.getWorld());

                    for (int meshIndex2 = 0; meshIndex2 < model2.getModel().Meshes.Count; meshIndex2++)
                    {
                        BoundingBox box2 = UpdateBoundingBox(model2.getModel(), model2.getWorld());

                        if (box1.Intersects(box2))
                            return true;
                    }
                }
            }
            else
            {
                for (int meshIndex1 = 0; meshIndex1 < this.getModel().Meshes.Count; meshIndex1++)
                {

                    BoundingBox box1 = UpdateBoundingBox(this.getModel(), this.getWorld());

                    for (int meshIndex2 = 0; meshIndex2 < model2.getModel().Meshes.Count; meshIndex2++)
                    {
                        BoundingBox box2 = UpdateBoundingBox(model2.getModel(), model2.getWorld());

                        if (box1.Intersects(box2))
                            return true;
                    }
                }
            }
            return false;
        }
Exemplo n.º 2
0
Arquivo: model.cs Projeto: er1/c376p1
        public bool IsCollision(model model2)
        {
            for (int meshIndex1 = 0; meshIndex1 < this.getModel().Meshes.Count; meshIndex1++)
            {

                BoundingSphere sphere1 = this.getModel().Meshes[meshIndex1].BoundingSphere;
                sphere1 = sphere1.Transform(this.getWorld());

                for (int meshIndex2 = 0; meshIndex2 < model2.getModel().Meshes.Count; meshIndex2++)
                {
                    BoundingSphere sphere2 = model2.getModel().Meshes[meshIndex2].BoundingSphere;
                    sphere2 = sphere2.Transform(model2.getWorld());

                    if (sphere1.Intersects(sphere2))
                        return true;
                }
            }
            return false;
        }