Advertisement Jump to content


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


Mesh vertex ordering and ray-picking

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

Hi, THE SHORT VERSION: How can I get the normal from three points in a mesh''s vertexbuffer? Are the points always stored in clockwise winding order, or do they alternate? Is there a way to inspect the mesh to find out? I have tried to use the sum of all the point normals, but it is badly inaccurate. THE LONG VERSION: I am using a ray to check collision detection between the character and the world objects. The ray goes from the current position towards the expected destination of this frame''s movement, and I loop through all the meshes in the scene to check for intersections. So far so good. The collision stuff works fine. What I want to do now is get a ''bounce'' off the mesh. To do this, I need to work out the plane of the mesh''s face that was hit, so I use the index buffer to get the three vertices. No problem there. I then use the d3dxplanefrompoints function to get a plane. The player''s vector is then reflected off the plane using the d3dxmatrixreflect and d3dxtransformnormal. The problem is that although I always record a collision properly, the bounce sometimes ''sucks'' the player through the mesh instead of bouncing off it - as if the plane is facing in the wrong direction. I have tried replacing all meshes with simple 12-polygon cubes just to simplify the debugging process, and even with these I seem to have no problem getting sucked through. A small clue: For meshes far away from the world-origin, I seem to get sucked through almost always, but for ones close to the origin it only seems to happen on certain faces. I can''t make sense of this at all because I am definitely applying the inverse model transform to the ray, and then re-applying the model transform to the vertex points after getting the face.

Share this post

Link to post
Share on other sites
Possibly if you use sphere or bounding box collision detection and check to see if the bounding object intersects with a negative difference then you can just negate or decrement the position vector of the moving mesh in the opposite direction.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!