Difference between revisions of "Application:configureFrustum"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2015.04.04<br/> === Description === Configure the field of view (fov) and far clipping plane for 3D projection. Setting a fov of 0 se...")
 
Line 18: Line 18:
 
If fov is set at 0 then the eye is at +infinity and a near plane is set at z=+farplane. Objects closer than this are clipped. The farplane remains at z=-farplane.
 
If fov is set at 0 then the eye is at +infinity and a near plane is set at z=+farplane. Objects closer than this are clipped. The farplane remains at z=-farplane.
 
<source lang="lua">
 
<source lang="lua">
= Application:configureFrustum(fovfarplane,)
+
Application:configureFrustum(fov,farplane)
 
</source>
 
</source>
'''fov:''' (number) Specifies the field of view angle in degrees If fov>0 a perspective projection is used with the eye at position z=+h/tan(fov/2) where h is half the larger screen dimension (logical coordinates). In this case there is a farplane but no nearplane: clipping is done only at the eye position. If fov=0, an orthographic projection is used with both a farplane and a nearplane (see below) ''''''<br/>
+
'''fov''': (number) Specifies the field of view angle in degrees If fov>0 a perspective projection is used with the eye at position z=+h/tan(fov/2) where h is half the larger screen dimension (logical coordinates). In this case there is a farplane but no nearplane: clipping is done only at the eye position. If fov=0, an orthographic projection is used with both a farplane and a nearplane (see below) ''''''<br/>
'''farplane:''' (number) The distance of the far clipping plane along Z axis. If fov>0 and this value is not set, the farplane is set at distance 100*(screen height) from the origin (z=0). If fov=0 (orthographic projection), a nearplane is also used at distance farplane from the origin. If fov=0 and no farplane is set then near and farplanes are set at 1 pixel from the origin. '''optional'''<br/>
+
'''farplane''': (number) The distance of the far clipping plane along Z axis. If fov>0 and this value is not set, the farplane is set at distance 100*(screen height) from the origin (z=0). If fov=0 (orthographic projection), a nearplane is also used at distance farplane from the origin. If fov=0 and no farplane is set then near and farplanes are set at 1 pixel from the origin. '''optional'''<br/>

Revision as of 10:21, 23 August 2018

Available since: Gideros 2015.04.04

Description

Configure the field of view (fov) and far clipping plane for 3D projection.

Setting a fov of 0 selects default orthographic projection (no perspective).

The field of view specifies the angle of vision by which the largest side of the scene is seen. It is used to compute the distance of the eye relative to the screen along the Z axis:

Z=(largest screen dimension/2)/tan(fov/2)

is eye location. The far clipping plane specifies the maximum distance of an object. Objects more distant than the far clipping plane are not drawn.
Note the perspective is oriented so that the full screen is at Z=0 (so sprite:setPosition(x,y,0) will place the sprite at exactly (x,y) pixels on the screen, irrespective of fov) and distant objects are placed at negative Z values.

If the fov is set at non-zero then perspective projection is activated. If farplane is then not set it takes the default value 100*(screen height). Normally the user should set this value. Note that there is no nearplane in perspective mode (objects are clipped only at the eye position)
If fov is set at 0 then the eye is at +infinity and a near plane is set at z=+farplane. Objects closer than this are clipped. The farplane remains at z=-farplane.

 Application:configureFrustum(fov,farplane)

'fov: (number) Specifies the field of view angle in degrees If fov>0 a perspective projection is used with the eye at position z=+h/tan(fov/2) where h is half the larger screen dimension (logical coordinates). In this case there is a farplane but no nearplane: clipping is done only at the eye position. If fov=0, an orthographic projection is used with both a farplane and a nearplane (see below) '
farplane: (number) The distance of the far clipping plane along Z axis. If fov>0 and this value is not set, the farplane is set at distance 100*(screen height) from the origin (z=0). If fov=0 (orthographic projection), a nearplane is also used at distance farplane from the origin. If fov=0 and no farplane is set then near and farplanes are set at 1 pixel from the origin. optional