[osg-users] Computing Image Co-ordinates

Zach Deedler mynamezach at gmail.com
Thu Sep 6 07:53:13 PDT 2007


Hello Harash,

 

It is difficult for me to understand what you are trying to do.  If you are
trying to convert something from 3D coordinates to 2D window coordinates
then you want to use this function:

sceneView()->projectObjectIntoWindow( position, windowPosition );

 

  _____  

From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Harash
Sharma
Sent: Thursday, September 06, 2007 10:30 AM
To: Public OpenSceneGraph Users discussion list.
Subject: Re: [osg-users] Computing Image Co-ordinates

 

Hi 

   Thanks to all. I now know the problem was probably too simplistic for
anyone to waste their precious time. I was able to figure out the way to
compute the image co-ordinates from world object co-ordinates. I am writing
here the method in case some newbie like me needs it.

   If the World Co-ordinate of the object Point is P, Then we can obtain the
Image co-ordinate C as :

 

1. C1 = P * MatView * MatProj * MatWind

2. C = C1 / C1.w()

 

where 

 

MatView:- View Matrix obtained through osg::Camera::getViewMatrix()
MatProj:-  Projection Matrix obtained through
osg::Camera::getProjectionMatrix()

MatWind:- Window Matrix obtained through
osg::Viewport::computeWindowMatrix()

 

  Here the viewport is set to the size of the image to which the scene is
rendered through RTT.

 

Regards 

 

Harash

 

      

 

Harash Sharma <harashsharma at yahoo.com> wrote:

Hi All,

 

    I want some help regarding computation of projected model co-ordinates.
The problem is like this. I have a cuboidal model (car). I have been able to
compute its bounding box -- so I know the world co-ordinates of the car
bound corners. The scene is being rendered to a texture with an image size
of MxN Pixels. I would like to calculate the image co-ordinates
corresponding to the 8 bounding box corner co-ordinates. Is there any
function available in OSG which I can use to achieve this. If not, it would
be very kind of you to indicate some  pointers on how to do it. I thought it
would be as simple as multiplying the model vectors by the
osg::View::getCamera()->getViewMatrix() *
osg::View::getCamera()->getProjectionMatrix(), but I think I am missing
something. 

 

   Please Help. Thanks in advance.

 

Regards

 

Harash


  _____  


Sick sense of humor? Visit Yahoo! TV's Comedy
<http://us.rd.yahoo.com/evt=47093/*http:/tv.yahoo.com/collections/222>  with
an Edge to see what's on, when.
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 

  


  _____  


Boardwalk for $500? In 2007? Ha! 
Play
<http://us.rd.yahoo.com/evt=48223/*http:/get.games.yahoo.com/proddesc?gameke
y=monopolyherenow>  Monopoly Here and Now (it's updated for today's economy)
at Yahoo! Games.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070906/2c4d36ab/attachment-0003.htm>


More information about the osg-users mailing list