You would also apply this scale to the z value in your lookAt matrix to see the scene as not being zoomed. What you would do then is divide all of the border parameters ( top, left.) with that value. To achieve something like that you need to define some maximum scale for instance maxZoom = 10.0. The problem now is that if you want to "zoom in" by putting the camera closer to the objects those objects will again not be drawn. By simply putting it to z=-near you should see the objects exactly as with using orthographic projection. To avoid this it is best if you use a lookAt procedure which will generate another matrix that may define "camera" position in your scene. Then if your objects are at 0.0 distance then they will all be clipped. But then you still need to define near and far values which must be positive. So having something like left = 0.0, right = width, bottom = height and top = 0.0. In your case there is no reason not to define these values as you please. These are just some examples though as there are many ways to define it. You define constant near, far and fov from which the border parameters are then computed like right = tan(fov)*near*0.5 and top = tan(fov)*near*0.5*(viewHeight/viewWidth). In most cases we define frustum with a field of view as angle. So when using depth buffer ensure that this value is as small as possible but still large enough to see all your objects. So in most cases there is no difference if you put a very large far value but one very important Effect of having a large far value will be precision of depth test. The far parameter effects nothing but where your objects will stop being drawn. Objects that are closer to near will usually not be drawn and those further will be scaled linearly depending on all parameters but far. So for instance if you put a rectangle with coordinates left, right, top, bottom as x and y then near as z and using no other matrix but the frustum the result will be exactly a full screen rectangle. It is designed so that an object at near is scaled by 1.0. What this method does is it creates a matrix that will scale the objects depending on the distance from near. There is very little difference using orthogonal or frustum matrix so the most simple answer would to simply swap the bottom and top parameters or even set them to whatever you need.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |