View unanswered posts | View active topics It is currently Thu May 24, 2018 5:55 am

Reply to topic  [ 2 posts ] 
 3D coordinates projection to snapshot image 
Author Message

Joined: Wed Oct 22, 2014 9:55 pm
Posts: 3
 3D coordinates projection to snapshot image

I am rendering a model and taking a snapshot (image) of that scene (pretty much like GLC_Player takes snapshots), so that I can see the whole scene in the image.
What I would like to do now, is to match the world bounding box corners (3D coordinates) to the corresponding 2D coordinates in the generated image.

I saw APIs to get projection matrices from GLC_Context, GLC_Camera or GLC_Viewport, but I'm not too sure which one to use.
So far, I did a simple test setting the camera's target to the world bounding box center (so that it matches the center of my generated snapshot) and trying to project the bounding box center 3D coordinates using projection matrices from those API and expecting to find the 2D coordinates of the center of my image, however I didn't get relevant results.

Hoping to find some help here, how would you do this?

Mon Jun 29, 2015 2:26 am

Joined: Wed Oct 22, 2014 9:55 pm
Posts: 3
Post Re: 3D coordinates projection to snapshot image

We only need the snapshot dimensions as well as the combination of the camera's view matrix with the projection matrix. GLC_lib actually gives this combination directly with GLC_Viewport::compositionMatrix(). This will allow to project the point from the world to the clipping space of [-1, 1] range. We finally convert that to the image coordinate system, where (0, 0) is the top left corner.

So, to transform a point P(x, y, z) from the world to a 2D point P'(x', y') on the snapshot image :

We first compute the point Pc(xc, yc, zc) as Pc = GLC_Viewport::compositionMatrix() * P(x, y, z)

Then, for a snapshot image of width W and height H :

x' = (( xc + 1 ) / 2.0) * W
y' = (( 1 - yc ) / 2.0) * H
(zc value is dropped as we get flat image)

Source : ... creen.html

Mon Jun 29, 2015 8:29 am
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.