# getting mapscale

Hello
I am writting a simple CAD viewer with OpenGL
It draw the graphics objects in a “perspective” scene.

How do I calculate the current map-scale (1:1.000, 1:2.000, …) of the view ?

Thanks in avance

That would be totally up to how you design your app. There is no one set scale in OpenGL. There are a couple ways I can see you defining a scale.

1. You specify a scale up front and then draw your models accordingly. For instance 1 unit length in the display = 1 foot real in life measurement. Then to display a 2 foot line you could just draw it from say -1,0,0 to 1,0,0.

2. You have a model of known real-life size, and you want to calculate the scale it’s displayed at. Say the model represents a real life object that is 2 feet long and the distance between the end vertices is 1. Simple division will give you the scale.

The above methods will give you a scale with regard to the coordinate length to real length. If what you really want is the scale of actual screen display length to real life length you have a lot more to worry about, some of which would be difficult to get using software. If that’s the case, you need to consider size of the monitor, current resolution, and then the OpenGL elements like projection matrix, viewport, etc. It could get ugly.

1. You specify a scale up front and then draw your models accordingly. For instance 1 unit length in the display = 1 foot real in life measurement. Then to display a 2 foot line you could just draw it from say -1,0,0 to 1,0,0.

2. You have a model of known real-life size, and you want to calculate the scale it’s displayed at. Say the model represents a real life object that is 2 feet long and the distance between the end vertices is 1. Simple division will give you the scale.

The above methods will give you a scale with regard to the coordinate length to real length. If what you really want is the scale of actual screen display length to real life length you have a lot more to worry about, some of which would be difficult to get using software. If that’s the case, you need to consider size of the monitor, current resolution, and then the OpenGL elements like projection matrix, viewport, etc. It could get ugly. [/b][/QUOTE]

Hi,
I think that I really want is the scale of actual screen display length to real life length how you said.

If I use “gluProject” in order to get the xy-window values of two 3DPoints of the zFar plane in real-life coordinate values, and I calculate the ratio xy-window length / real length, Is It correct??