Hi Andrey,

Thanks for the explanation, make more sense now.

If you have a perspective camera then you'll be able to assume that
the all the line segments will start at the cameras eye point and end
at the intersection point that is returned.  To compute the camera's
eye position in world coordinates what you need to do is multiple the
(0,0,0) eye position in eye coorindates into the world coordinates by
multiply it by the the inverse of the camera's view matrix.

i.e.

  osg::Vec3d eyeInWorld = osg::Vec3d(0.0,0.0,0.0) *
osg::Matrixd::inverse(camera->getViewMatrix());


Robert.

On 9 March 2012 10:41, Andrey Ibe <[email protected]> wrote:
> i am trying to compute the direction of an osg::LineSegmentIntersector 
> object. i can get the collision point and i am trying to get the starting 
> point - i need the vector of the intersector's direction.
>
> i do this for the purpose of ray tracing (or ray casting). i create the 
> intersectors this way
> Code:
> new osgUtil::LineSegmentIntersector(cf, x, y);
>
> where cf is 'WINDOW' (this is for the primary rays). i am not sure how to 
> transform the starting/end point of the intersector into model (world) space. 
> that's why i am trying to get the position of the camera as the starting 
> point. i looked at the code of the linesegmentintersector thoroughly, but 
> still am confused about the matrices, so i decided it could be less difficult 
> to use the camera.
>
> i need the vector to calculate the specular color.
>
> robert, thank you very much for your help.
>
> andrey
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=46129#46129
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to