|
|
"daviddoria" <nomail@nomail> wrote in message
news:web.4849a25ff5d589ac145cec320@news.povray.org...
>I have a mesh (list of vertices - .obj type of file) that i would like to
>shoot
> a ray at from a particular point and see if it hits the mesh, and if it
> does,
> get the coordinates of the intersection. Is this possible to do with pov
> ray?
> Can someone point me to an example that does something like this? Does pov
> ray
> have its own scripting language or will I have to dig through the source
> code
> to do this task?
>
> Thanks,
>
> Dave
>
You'd need to convert it into a POV-Ray mesh which can be done using
PoseRay.
You can then wrap the mesh definition in an object declaration using
#declare to give it a name, then you can pass this into the 'trace' function
along with the start point and a direction vector for the line you want to
trace. This will return the coordinates of the point of intersection.
You should also pass the optional last parameter in which will be set to the
normal at the point of intersection. You can then test the value and if it
has a zero length, the ray didn't hit the object.
Your SDL would look something like this, assuming that the file
'YourMeshFile.inc' contains the mesh definition generated using PoseRay and
wrapped in a #declare statement to give it the name 'MyMesh':
#include "YourMeshFile.inc"
#declare MyNormal = <0,0,0>;
#declare MyStart = <1, 1, 1>;
#declare MyDirection = <0, 0, 0> - MyStart;
#declare MyIntersection = trace ( MyMesh, MyStart, MyDirection, MyNormal);
#if (vlength(MyNormal)=0)
... // What to do if the ray missed the object
#else
... // What to do if the ray hit the object
#end
Of course you then need to decide what you're going to do with the
information. e.g. write the coordinates out to the debug stream or to a
file, or display a scene with a sphere at the point of intersection.
Regards,
Chris B
Post a reply to this message
|
|