Sign in to follow this  
cyric74

Obtaining Triangle X/Y Points From Mesh

Recommended Posts

Hello, I'm fairly new to DirectX and am still trying to get down some of the basics. At the moment I'm working on a birds-eye view spaceship game and have come up with a small problem: For C-D I've implemented a basic point-in-triangle check but I am now stumped on how to get the 3 points of each seperate triangle that make up one of my .X mesh spaceships. I have played around with building Vector2 arrays from the Mesh's VertexBuffer but that just gives me the points I'd like to test and not the triangles I need to test them in. Am I approaching this part of collision detection from the wrong direction? I've just been teaching myself DirectX with no formal learning structure beyond reading net articles, so I'm sure I don't know the difference between a good and bad technique. Also would it generally be more effective to use a point-in-triangle detection or a byte grid representing X|Y around my spaceship? If a byte grid would be better, how would I go about implementing the detection of the mesh? Using Mesh.Intersect? Thanks, Cyric cyric74@hotmail.com

Share this post


Link to post
Share on other sites
checking every polygon for collision detection is (or may be) a good idea, but also very slow. First you should use circles/rectangles (for 2d... birds view right?) or spheres/boxes to check if the objects are close enough to warrant an expensive polygon-collision test. In fact, if the sphere/box encapsulates your ships well enough, you may not even need polygon collision testing (as long as it looks right, depends on how far the camera is). Also, this is a good tutorial for collision detection using ellipsoids (a sphere with 3 radii).

As for getting the 3 points that make up your polygons... If you're drawing the polygons you should be able to get them. You can't draw a polygon without it's verts. Also not quite sure what you're doing with Vector2 arrays... Remember, polygons have 3 vertices, not 2 (even if you make it look like 2d). If you don't need/want the Z value, just don't use it, but don't ignore it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this