Difference between revisions of "Application:configureFrustum"
m (Text replacement - "</source" to "</syntaxhighlight") |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
'''Available since:''' Gideros 2015.04.04<br/> | '''Available since:''' Gideros 2015.04.04<br/> | ||
− | '''Class:''' [[ | + | '''Class:''' [[Application]]<br/> |
=== Description === | === Description === | ||
− | + | Configures the field of view (fov) and far clipping plane for 3D projection. | |
+ | <syntaxhighlight lang="lua"> | ||
+ | application:configureFrustum(fov,farplane) | ||
+ | </syntaxhighlight> | ||
− | Setting a fov of 0 selects default orthographic projection (no perspective). | + | Setting a fov of 0 selects the 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: | 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) | + | '''Z=(largest screen dimension/2)/tan(fov/2)''' |
− | |||
− | |||
Z is the eye location. The far clipping plane specifies the maximum distance of an object. Objects more distant than the far clipping plane are not drawn. | Z is the 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. | '''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 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. | 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. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Parameters === | === Parameters === | ||
− | '''fov''': (number) | + | '''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/> |
− | <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) | ||
− | <br/> | ||
{{Application}} | {{Application}} |
Latest revision as of 17:22, 12 July 2023
Available since: Gideros 2015.04.04
Class: Application
Description
Configures the field of view (fov) and far clipping plane for 3D projection.
application:configureFrustum(fov,farplane)
Setting a fov of 0 selects the 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)
Z is the 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.
Parameters
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
- Application:applyStyles
- Application:canOpenUrl
- Application:checkPermission
- Application:configureFrustum
- Application:enableDrawInfo
- Application:enableOnDemandDraw
- Application:exit
- Application:get
- Application:getApiVersion
- Application:getAppId
- Application:getBackgroundColor
- Application:getClipboard
- Application:getContentHeight
- Application:getContentWidth
- Application:getDeviceHeight
- Application:getDeviceInfo
- Application:getDeviceName
- Application:getDeviceOrientation
- Application:getDeviceSafeArea
- Application:getDeviceWidth
- Application:getFps
- Application:getKeyboardModifiers
- Application:getLanguage
- Application:getLocale
- Application:getLogicalBounds
- Application:getLogicalHeight
- Application:getLogicalScaleX
- Application:getLogicalScaleY
- Application:getLogicalTranslateX
- Application:getLogicalTranslateY
- Application:getLogicalWidth
- Application:getNativePath
- Application:getOrientation
- Application:getProjectProperties
- Application:getScaleMode
- Application:getScreenDensity
- Application:getTextureMemoryUsage
- Application:isPlayerMode
- Application:openUrl
- Application:requestPermissions
- Application:set
- Application:setBackgroundColor
- Application:setClipboard
- Application:setEventMerging
- Application:setFps
- Application:setFullScreen
- Application:setKeepAwake
- Application:setKeyboardVisibility
- Application:setLogicalDimensions
- Application:setOrientation
- Application:setScaleMode
- Application:setTextInput
- Application:setWindowSize
- Application:vibrate