I use the following function to know how much of the display area is showing on a given zoom level.
static inline SizeF getDisplaySize(GLfloat fovy, GLfloat zoom, SizeF screenSize){ GLfloat height = tanf(fovy / 2.0f * PI / 180.0f) * zoom * 2.0f; GLfloat width = height * (screenSize.width / screenSize.height); return SizeFMake(width, height);}
Currently I use the following to calculate zoom limits
void Camera::SetZoomLimits(int min, int max){ m_minZoom = min; m_maxZoom = max; SizeF minDisplaySize = getDisplaySize(FOV, m_minZoom, g_screenSize); SizeF maxDisplaySize = getDisplaySize(FOV, m_maxZoom, g_screenSize); SizeF levelSize = SizeFMake(g_levelData->Width / SCALE_PIXEL, g_levelData->Height / SCALE_PIXEL); while(minDisplaySize.width > levelSize.width || minDisplaySize.height > levelSize.height) { m_minZoom--; minDisplaySize = getDisplaySize(FOV, m_minZoom, g_screenSize); } while(maxDisplaySize.width > levelSize.width || maxDisplaySize.height > levelSize.height) { m_maxZoom--; maxDisplaySize = getDisplaySize(FOV, m_maxZoom, g_screenSize); }}
This does what I want but I would like a function that returns "zoom" given the level size rather than using loops.
[Edited by - Headkaze on December 5, 2010 3:17:09 PM]