I'm working on opengl project. I set up perspective projection and render a transformed rectangle (rotated, scaled)
How i can calculate rectangle's bounding box (rectangle position,size)
Thank you
I'm working on opengl project. I set up perspective projection and render a transformed rectangle (rotated, scaled)
How i can calculate rectangle's bounding box (rectangle position,size)
Thank you
You'd run the rectangle through the same matrices that OpenGL does to transform the 3D points into 2D screen-space ones. Get your input vectors, multiply them by any that you want to apply to the object, ModelView matrix, Projection matrix, then you have screen-space coords. Then check whether the resulting coordinates are on-screen, then you can calculate the minimum/maximum X and Y coordinates, and you have your bounding rectangle.
See also here (9.100), if you've got the GLU utility library functions available:
http://www.opengl.org/resources/faq/technical/transformations.htm
Hope that helps.