C++, DirectX9, collision with .x terrain?

Started by
2 comments, last by marius1930 14 years, 7 months ago
Hello. I've been searching on Google but haven't managed to find, how to detect collision between .x model (either it's position) and .x terrain. I think it has something with getting height of terrain at X, Y coordinates, but I'm not sure how. Maybe anyone could help?
Advertisement
There isn't a collision detection system built into DirectX or C++.

You can consider one of the D3DXIntersect functions to determine the relative positions of one mesh with another. If you're strictly interested in height-above-terrain that would be your best bet.

Otherwise you may want to use one of several collision/physics engines available around the web (Havok, Bullet, ODE, etc.).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Well thanks for reply
Appears rotation of terrain didn't apply when detecting collision, so it wasn't right, after rotating model in editor, not in code it became all fine.

Thanks again
Still, you should read all the height data from the model and store it in a local vector/array, to avoid having to read from agp memory :)

This topic is closed to new replies.

Advertisement