• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

Raytracing

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.

2 replies to this topic

#1Shawn619  Members   -  Reputation: 342

Like
1Likes
Like

Posted 07 June 2013 - 02:54 PM

I'm not quite sure which section this question be better suited, so feel free to move it.

This question is about raytracing line-triangle, more specifically, a vertical line intersecting with a triangle.

I'm following the algorithm from http://www.angelfire.com/fl/houseofbartlett/solutions/line2tri.html#Code

Goal: Place a vertical line anywhere on a non-flat surface(terrain) and be able to detect which triangle it hits.

I'll try to make my question simple:

When my line point starts above the terrain and has a negative vertical vector direction(enough to pierce the terrain and create intersection), I produce correct results:

//vertical line from 10y to -10y
vec3f linept = {0.0, 10.0, 0.0}; //start line point
vec3f linevect = {0.0, -20.0, 0.0}; // line vector direction

*the black triangle means the line-triangle algorithm has returned true for that polygon.

While simply having the line start below the terrain, instead of the top, and changing the direction of the line direction(from down->top), which you would think have no effect and still pierce the terrain because it's really still the same line, now does not recognize intersecting with the triangle:

//vertical line from -10y to 10y
vec3f linept = {0.0, -10.0, 0.0}; //start line point
vec3f linevect = {0.0, 20.0, 0.0}; // line vector direction

*the algorithm does not deal with normalized vectors of direction, so that's why the line's direction is (0,10,0) instead of (0,1,0).

Why does changing the vector direction make the algorithm fail?

Edited by Shawn619, 07 June 2013 - 02:55 PM.

#2Kjell Andersson  Members   -  Reputation: 428

Like
1Likes
Like

Posted 07 June 2013 - 04:08 PM

The dot product between the normal of the surface and your intersection vector will be > 0 and thus fail the if test in the intersection test.

This means that the intersection test is designed to use back-face culling, i.e. the back of a triangles are not visible.

#3Shawn619  Members   -  Reputation: 342

Like
0Likes
Like

Posted 07 June 2013 - 04:47 PM

Ah, that wasn't mentioned in the algorithm notes. Thanks!

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.

PARTNERS