Click here to Skip to main content
Sign Up to vote bad
good
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 - 7:47
Edited 25 Oct '12 - 7:38

Comments
Sergey Alexandrovich Kryukov - 22 Sep '12 - 22:50
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 - 23 Sep '12 - 3:15
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 - 2 Oct '12 - 17:52
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

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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 495
1 OriginalGriff 273
2 Dave Kreskowiak 175
3 Mohammed Hameed 145
4 Mayur_Panchal 144
0 Sergey Alexandrovich Kryukov 8,123
1 OriginalGriff 6,173
2 CPallini 3,482
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 10 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid