PDA

View Full Version : place a 3d object of size 50 pixels at (x,y)



meahmeah
02-23-2004, 03:13 AM
I am trying to track an object in the image. I need to place a 3d object at the image coordinates (x,y), and it must cover a certain pixel size (eg 50 pixels in width). The pixel size can vary during execution time.

But i realise that the opengl command is: glutSolidCube(radius). How do i relate the number of pixels to radius, and place the cube at row x and column y of the image?

[The image is displayed via orthogonal projection while the cube is using perspective projection]

Please help! Thank you...

brcain
02-23-2004, 11:09 AM
Originally posted by meahmeah:
How do i relate the number of pixels to radius, and place the cube at row x and column y of the image?


Use the frustum and window dimensions to calculate how large an object will be.

If you're using a parallel projection, the radius-to-pixel size is a direct calculation. If you're using a perspective projection also take into consideration the perspective division.

meahmeah
02-26-2004, 05:05 AM
thanks brcain! I manage to do it via glOrtho.