# [osg-users] Computing Image Co-ordinates

Harash Sharma harashsharma at yahoo.com
Thu Sep 6 07:29:54 PDT 2007

```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.

Regards

Harash

---------------------------------
Sick sense of humor? Visit Yahoo! TV's Comedy 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 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/108c32ef/attachment-0003.htm>
```