The Stone Goose OpenGL engine has the ability to calculate sprite scales. Lets see if I can explain the difficulty here...
OpenGL measures everything in "texels". When you specify sizes in OpenGL, you are working with texels. When you have finished telling OpenGL what to draw, the scene is rendered and you can see the image you have produced.
Sometimes, we want to know how big our polygons are going to be in pixels on our screens. If I draw a square that's 32 x 32 texels in size at a distance z from the camera, how big is that going to appear in pixels?
Well really we don't care what size it is going to be, rather, we want to know how we can draw a square that appears to be 32 x 32 pixels on our screen at distance z.
What we need to compute is the texel to pixel ratio. How many texels are there to the pixel? Stone Goose OpenGL engine can do this calculation for you. Of course this depends on how far things are away from the camera ( z distance ), since things get smaller due to perspective as they move away from the camera, so you have to specify the z distance and you get a ratio for that distance.
I have attached a screenshot of this in action. Thanks go to Hayo for the lovely graphics.
You can see that the main player looks like a 2D image. I decided that my main player sprite was going to be 50 texels away from the camera, and then calculated the sprite scale at z = 50. I calculate this number, and then draw all my sprites at actual pixel size * sprite scale, and then all of the sprites are scaled relatively.
I am thinking of making this scaling automatic, it would probably make it easier for people who don't understand it very well, but it might cause issues for people using lighting.
Another point to mention is that the HUD graphic you can see is actually a 2D sprite. This is not drawn in 3D but actually drawn as a 2D image on top.
That's all for now
|
|