PDA

View Full Version : Screen Size and Scaling


javadi
04-02-2013, 05:26 PM
Hi,

I have two questions regarding screen size and scaling of objects. Here I have attached two images (one original texture and one screen shot of the texture placed in two orientations). I have also annotated the screen shot for clarification. I have two issues,

In order to achieve an equal width of arrows (green lines in the screen shot), I have to adjust the window size to something like [760, 600]. How can I calculate these values? Further information regarding the size of the original texture and my display setting is gone in the bottom.
My other issue is the ratio of width to height of the texture (green to blue lines in the screen shot). The original texture looks much slimmer than the ones displayed. I use 'setScale' method to adjust the x and y scales differently (the blue line in the code below). When we add the texture, we specify a size. For that, I use one number, which I assume it defines a square. How can I merge this scaling in the line in blue with texture size in the line in red?

Some information on the original texture and my display settings,

The original image: 600 x 780 pixels, 72 x 72 pixels per inch resolution
The display: 1920 x 1200 LCD monitor.

The code that I used to create display the arrows:

import viz

viz.window.setSize([760, 600])

viz.go()

TextureArrow = viz.addTexture('Bank, Task\Arrow, Original.png')

DispArrow1 = viz.addTexQuad(viz.SCREEN, viz.MainScene, 500)
DispArrow1.setScale([600.0 / 780, 780.0 / 780, 1])
DispArrow1.setPosition([0.7, 0.7, 0])
DispArrow1.setEuler([0, 0, 90], mode = viz.ABSOLUTE)
DispArrow1.texture(TextureArrow)

DispArrow2 = viz.addTexQuad(viz.SCREEN, viz.MainScene, 500)
DispArrow2.setScale([600.0 / 780, 780.0 / 780, 1])
DispArrow2.setPosition([0.5, 0.3, 0])
DispArrow2.setEuler([0, 0, 0], mode = viz.ABSOLUTE)
DispArrow2.texture(TextureArrow)


Very many thanks for your attention.

Greetings,

farshizzo
04-02-2013, 05:38 PM
I would recommend adding the arrow to the viz.ORTHO layer, instead of viz.SCREEN. The SCREEN layer works in normalized (0-1) units, which is what causes the aspect ratio distortions. The ORTHO layer works in pixel units, which preserves the objects aspect ratio.

javadi
04-02-2013, 05:56 PM
I would recommend adding the arrow to the viz.ORTHO layer, instead of viz.SCREEN. The SCREEN layer works in normalized (0-1) units, which is what causes the aspect ratio distortions. The ORTHO layer works in pixel units, which preserves the objects aspect ratio.

Thanks for your prompt reply. It works. I only need to resize everything proportional to the size of the window, which should be fine.

Cheers