Archived

This topic is now archived and is closed to further replies.

collision detection with milkshape models

This topic is 5506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

loading a model is easy.....but how can you detect a collision with one, especially if they are odd shaped??? I know that everyone''s first answer is going to be vector this and vector that!!!.....but that isn''t a real answer. I want to know if anyone has come up with a loader that loads the model and stores the deminsions of the model, so that all I need to do is load the file and then test for collisions(i.e. :: MODELLOADER milkshapemodel; MODELLOADER milkshapemodel2; milkshapemodel.load("mymodel") milkshapemodel.getposition(); milkshapemodel2.load("mymodel2") milkshapemodel2.getposition(); //position is equal to an update test for the models position if(milkshapemodel.position()== milkshapemodel2.position()) { collision==true; }

Share this post


Link to post
Share on other sites
you could use spherical-collision detection.

The way this works is you know the center of each model and the radius of a sphere that would completly fit around the object. Then to collide these two spheres, use sphere one''s radius + sphere two''s radius and use pythagorus to work out if the distance between the centers is less than that value. Then you have a collision.

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.


ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA | LiT | H*R ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Reference | OGL v D3D | File Formats | Go FAQ yourself ]

Share this post


Link to post
Share on other sites
ya, the easiest way between two models would be bounding sphere collision detection. if that loading library lets you access the actual vertex data you could look up some other collision detection techniques, such as triangle-plane collision detection. yes, loading the model is the easy part when you have a library for it.

My Homepage
How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.

Share this post


Link to post
Share on other sites
One way to enclose a set of vertices is to build an axis-aligned bounding box. You can do this easily by going through your vertex data and finding the smallest and largest X, Y and Z values, individually. You end up with two vertices (Xmin, Ymin, Zmin) and (Xmax, Ymax, Zmax) which describe an axis-aligned box that encloses the model.

If you'd rather build a bounding sphere you could add together all of the model's vertices and divide the result by the number of vertices in your model. Make this value the center of your sphere and compute the distance between the sphere's center and each of the model's vertices. Make the sphere's radius the largest of all these distances.

There are better ways to compute bounding spheres and boxes, but I don't know enough to explain how to do that.

[edited by - chronos on November 19, 2002 5:10:19 PM]

Share this post


Link to post
Share on other sites
I tried this other method with codet - a free collision detection system (www.photoneffect.com/coldet).

Basically all you do is define objects using triangles and move them using matrices. Then you basically ask the system if two models have collided.

What i did was load two models - one i would draw, and i would use the other to define the collision model. I had animation in my demo but i soft of didnt work - i screwed up the matrices but the detection still worked. Anyway if you want a fairly accurate and moderately fast detection system this would work.

"Free advice is seldom cheap."
-- Rule of Acquisition #59

Share this post


Link to post
Share on other sites
You can do triangle to triangle collision detection. Thats what I have done. My code loads milkshape3d models and does triangle to triangle checks. I also added bounding boxes (that are calculated on the fly) to speed up the checking process.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------

Share this post


Link to post
Share on other sites