Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Game XNA collisions
I want to check the collision of one model with another model.I use collision check function as follows:
//Built Bouding Sphere
 private void builtBoudingSphere()
        {
            BoundingSphere sphere = new BoundingSphere(Vector3.Zero, 0);
            foreach (ModelMesh mesh in Model.Meshes)
            {              
                BoundingSphere tranformed = mesh.BoundingSphere.Transform(modelTranforms[mesh.ParentBone.Index]);
                sphere = BoundingSphere.CreateMerged(sphere, tranformed);
            }
            this.boudingSphere = sphere;
        }
//Check Collision
 public bool CheckColision(CModel otherModel)
        {              
            return (this.BoudingSphere.Contains(otherModel.BoudingSphere)==ContainmentType.Intersects);
        }
//BoundingSphere Property
 public BoundingSphere BoudingSphere
        {
            get 
            {
                Matrix worldTranform = Matrix.CreateScale(Scale) * Matrix.CreateTranslation(Positon);
                BoundingSphere transformed = boudingSphere;
                transformed = transformed.Transform(worldTranform);
                return transformed;
            }
        }
The function CheckCollion is great with sphere model but not good with cube or any models because I'm use check BoudingSphere. Can help me check accurate collison? Especially check collision between cubes.
Posted 22-Sep-12 8:47am
Edited 25-Oct-12 8:38am
v3
Comments
Sergey Alexandrovich Kryukov at 22-Sep-12 22:50pm
   
It depends on what accuracy do you want to achieve in your engine. What bounding shape do you want to have? If you want more or less realistic shape, the analysis of collisions can become quite difficult.
--SA
Sandeep Mewara at 23-Sep-12 3:15am
   
Reply from OP:
Yes, it's very difficult! I plan to split into smaller pieces to review collision.It can be a solution acceptable.
Sergey Alexandrovich Kryukov at 2-Oct-12 17:52pm
   
I just sent you a message: you should not re-post; and it cannot help you.
It's extremely unlikely that you could get an answer, especially in this forum. It means a lot of work, really.
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Plan to split into smaller pieces to review collision.It can be a solution acceptable. Use BoudingSphere to check that pieces.
Example: the airplane, split: head airplane, tail airplane, wing airplane. And check each part for collision.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 10 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100