Get raycast world intersection point?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Get raycast world intersection point?

Postby meds » Fri Jan 09, 2009 5:02 am

When a ray intersects with a newton body is it possible to get the point (in world coordinates) where it intersected?
meds
 
Posts: 6
Joined: Sat Dec 20, 2008 7:01 am

Re: Get raycast world intersection point?

Postby JernejL » Fri Jan 09, 2009 9:32 am

Ofcourse, you take the origin point of the ray and direction normal you gave it when initiating ray, and move the point along the normal for the intresect distance.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Get raycast world intersection point?

Postby meds » Fri Jan 09, 2009 10:32 am

Delfi wrote:Ofcourse, you take the origin point of the ray and direction normal you gave it when initiating ray, and move the point along the normal for the intresect distance.


Thanks, I was actually trying to do something similar but after reading your post realized I was actually moving the point along the normal of the origin rather than along the ray direction :oops:
meds
 
Posts: 6
Joined: Sat Dec 20, 2008 7:01 am

Re: Get raycast world intersection point?

Postby agi_shi » Fri Jan 09, 2009 5:16 pm

The intersect distance is in normalized [0..1] coordinates, with point0 of the ray cast being 0 and point1 being 1. Therefore, don't move along the normal, but simply interpolate between p0 and p1 of your ray cast using the intersect distance (or intersect parameter as the Newton header calls it). For example:
Code: Select all
vec3 p0 = origin, p1 = origin + direction * 100;
NewtonWorldRayCast(..., &p0.x, &p1.x, ...);

onHit(..., intersectParam)
{
    vec3 worldPos = p0 + (p1 - p0) * intersectParam;
}
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 13 guests

cron