• Advertisement
Sign in to follow this  

Collision with an MD2 model.

This topic is 4142 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

Let me first say I'm relatively new to 3d programming, and my vector calculus is a little rusty. After reading a tutorial from this site I've been able to render an MD2 model to the screen. Here's the tutorial http://www.gamedev.net/reference/articles/article1653.asp very good by the way. Now I'd like to be able to click on the screen and have it know that I either hit, or missed the model (FPS style.) I've done some reading on this site as well as others but I seem to be confusing myself more and more. If anyone has any experience with this (obviously someone does) and can shed some light on the situation. Or if someone knows a good site for me to look at I'd really appreciate it. I apologize if this is in the wrong forum. I figured it's a long the lines of collision detection, but at the same time it may just be a DirectX problem, so I wasn't sure where to post. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
You want to check if you've clicked on the model with the mouse?
One of the most common way's to do this is to make a "ray" (= line that goes infinatly in on direction from a point) starting at the camera and going through the mouse position (in 3D). then check if this ray intersects the model. to get the mouse position in 3D you need to use the projection matrix. in opengl there's a ready made function called gluUnProject() which maps window coordinates to object coords. I really don't know but i assume that there's something silmilar in DirectX. to get the direction of the ray just subtract the mouse position in world space from the camera position. the starting point of the ray is the camera position.
Another way to do this is called color selection. to do this you render (to the backbuffer - you don't want anyone to see ths part) all the shapes that you're testing, each one in a different (solid) color. then you check the color of the pixels next to the mouse to see what you clicked on.
hope this helped.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement