• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# scenegraph for triangle-data

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1treeRunner  Members

Posted 24 March 2011 - 02:07 PM

hey ppl!

i'm looking for a tutorial/book/library, which shows/allows me to do the math for picking vertices, edges and faces.

already in use: "minimalistic" opengl-window with camera-movement, triangle-importer and -viewer

### #2ApochPiQ  Moderators

Posted 24 March 2011 - 03:40 PM

Moving to Graphics Programming and Theory.
Wielder of the Sacred Wands

### #3Vilem Otte  GDNet+

Posted 24 March 2011 - 04:47 PM

As far as I know, picking triangles is best solved using ray-cast to scene and testing it against triangles. One ray-tri test is here (Moller test, one of the most famous today) - http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf and also theory behind barycentric coordinates: http://mathworld.wolfram.com/BarycentricCoordinates.html (read first this - it might also help you with picking edges).

For point picking I would use replacing them with virtual spheres (not seen) and perform ray-cast against them. Sphere radius would grow with depth from camera (doesn't count for orthogonal projections, just for perspective), so your picking area would be same by distant and close sphere. Writing ray-sphere intersection is just a minute (or thinking it out of the head) with simple quadratic equation ... a little help for ray-sphere: Quite uneffective, but working, although very good explanation and easy to understand (e.g. read first this) http://wiki.cgsociety.org/index.php/Ray_Sphere_Intersection much better here http://www.dreamincode.net/forums/topic/124203-ray-sphere-intersection/ (read after, to see, how it can be computed effectively).

I'm not expert for writing mesh editors (I actually had never written any), but picking can be done this way quite minimalisticaly, in easy way and is quite effective (and if you pack your meshes under Bounding Volume Hierarchies, then bloody effective).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

### #4treeRunner  Members

Posted 26 March 2011 - 06:41 PM

Thank you so much Vilem Otte!

I've fitted the triangle-ray-intersection-code into my math-lib. It workes so far, but just from ONE side. Is there an easy way to make it "bothsided"?

### #5Bow_vernon  Members

Posted 26 March 2011 - 07:01 PM

Well, you could change the sign of the distance back to positive (flipping it if it was negative). Anyway, when I wrote my animator, I use gluUn/gluProject to do the trick, and it worked quite well for me...

### #6Vilem Otte  GDNet+

Posted 27 March 2011 - 07:10 AM

I've fitted the triangle-ray-intersection-code into my math-lib. It workes so far, but just from ONE side. Is there an easy way to make it "bothsided"?

Just use the code without defining TEST_CULL, e.g. use the path after #else in the code. That will perform double-sided test.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

### #7MarekKnows.com  Members

Posted 05 April 2011 - 03:26 PM

I've fitted the triangle-ray-intersection-code into my math-lib. It workes so far, but just from ONE side. Is there an easy way to make it "bothsided"?

If you flip your normal direction then you'll be able to find the solution on the other side.

---
Free C++, OpenGL, and Game Development Video Tutorials @
www.MarekKnows.com
Play my free games: Ghost Toast, Zing, Jewel Thief

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.