Lua API  0.4.0
Game Engine
 All Files Functions
Camera.lua File Reference

Functions

 changeCurrentCamera (object)
 Changes the current active camera. More...
 
 getCurrentCamera ()
 Retrieves the active camera. More...
 
 getCameraClearColor (object)
 Retrieves the clear color from the given camera. More...
 
 getCameraFov (object)
 Retrieves the field of view from the given camera. More...
 
 getCameraNear (object)
 Retrieves the distance to the near plane from the given camera. More...
 
 getCameraFar (object)
 Retrieves the distance to the far plane from the given camera. More...
 
 getCameraFogDistance (object)
 Retrieves the distance to the fog from the given camera. More...
 
 isCameraOrtho (object)
 Checks if the given camera is configured to be orthographic. More...
 
 isCameraFogEnabled (object)
 Checks if the given camera is configured to render fog. More...
 
 setCameraClearColor (object,{r, g, b})
 
 setCameraFov (object, fov)
 Changes the field of view of the given camera. More...
 
 setCameraNear (object, near)
 Changes the distance to the near plane of the given camera. More...
 
 setCameraFar (object, far)
 Changes the distance to the far plane of the given camera. More...
 
 setCameraFogDistance (object, fogDistance)
 Changes the distance to the fog rendered by the given camera. More...
 
 enableCameraOrtho (object, ortho)
 Updates the cameras matrix setup to allow orthographic rendering. More...
 
 enableCameraFog (object, fog)
 Enables fog rendering for the given camera. More...
 
 enableCameraLayer (object, scene)
 Turns the image that the given scene renders into an overlay over the given camera. More...
 
 disableCameraLayer (object)
 Disables the scene overlay attached to the given camera. More...
 
 enableRenderToTexture (object, texturePath, renderWidth, renderHeight)
 Enables render to texture for the given camera. More...
 
 disableRenderToTexture (object)
 Disables render to texture for the given camera. More...
 
 getProjectedPoint (object, point)
 Converts global vector to a projected vector inside the given camera viewport. More...
 
 getUnProjectedPoint (object, point)
 Converts a projected vector to a global vector using the given camera. More...
 

Function Documentation

changeCurrentCamera ( object  )

Changes the current active camera.

This change will apply in the next frame and not immediately.

Parameters
objectThe new active camera.
disableCameraLayer ( object  )

Disables the scene overlay attached to the given camera.

Parameters
objectThe camera with the scene layer.
disableRenderToTexture ( object  )

Disables render to texture for the given camera.

Parameters
objectThe camera.
enableCameraFog ( object  ,
fog   
)

Enables fog rendering for the given camera.

Parameters
objectThe camera.
fogA boolean value representing the new state.
enableCameraLayer ( object  ,
scene   
)

Turns the image that the given scene renders into an overlay over the given camera.

For rendering the scene as an overlay the default camera in that scene is used.

Parameters
objectThe camera.
sceneThe scene to overlay.
camera = getObject("MainCamera")
guiScene = getScene("GuiScene")
enableCameraLayer(camera, guiScene)
enableCameraOrtho ( object  ,
ortho   
)

Updates the cameras matrix setup to allow orthographic rendering.

Parameters
objectThe camera.
orthoA boolean value representing the new state.
enableRenderToTexture ( object  ,
texturePath  ,
renderWidth  ,
renderHeight   
)

Enables render to texture for the given camera.

This function allows you to setup any camera to render to a specific material. For this you specify the texture path to the texture you want to replace. Attention: This will not modify the texture on disk!

All surfaces referencing this texture file will be replaced by the rendered image.

Parameters
objectThe camera which is used to render the scene.
texturePathThe path to the texture file to replace.
renderWidthThe width of the render target in pixel (does not need to match the actual texture file)
renderHeightThe width of the render target in pixel (does not need to match the actual texture file)
camera = getObject("MainCamera")
enableRenderToTexture(camera, "maps/white.png", 1024, 1024)
getCameraClearColor ( object  )

Retrieves the clear color from the given camera.

Returns
The color as a vec3.

Example:

color = getCameraClearColor(camera)
print("Color: R = " .. color[1] .. " G = " .. color[2] .. " B = " .. color[3])
getCameraFar ( object  )

Retrieves the distance to the far plane from the given camera.

Parameters
objectThe distance as a number.
getCameraFogDistance ( object  )

Retrieves the distance to the fog from the given camera.

Parameters
objectThe distance as a number.
getCameraFov ( object  )

Retrieves the field of view from the given camera.

Parameters
objectThe FOV as a number.
getCameraNear ( object  )

Retrieves the distance to the near plane from the given camera.

Parameters
objectThe distance as a number.
getCurrentCamera ( )

Retrieves the active camera.

Returns
The active camera.
getProjectedPoint ( object  ,
point   
)

Converts global vector to a projected vector inside the given camera viewport.

Parameters
objectThe camera.
pointA vec3 containing positional data.
Returns
A vec3 containing the transformed vector.
getUnProjectedPoint ( object  ,
point   
)

Converts a projected vector to a global vector using the given camera.

This conversion uses the camera to determine the global coordinates for a perspectively transformed point. This can be used to generate a ray for use in raytracing as shown in the example.

camera = getObject("MainCamera")
-- Start the ray at the center of the screen
p1 = getUnProjectedPoint(camera, vec3(0.5, 0.5, 0))
p2 = getUnProjectedPoint(camera, vec3(0.5, 0.5, 1))
point, object = rayHit(p1, p2)
Parameters
objectThe camera to use.
pointA vec3 containing positional data.
Returns
A vec3 containing the converted data.
isCameraFogEnabled ( object  )

Checks if the given camera is configured to render fog.

Parameters
objectThe camera.
Returns
A boolean.
isCameraOrtho ( object  )

Checks if the given camera is configured to be orthographic.

Parameters
objectThe camera.
Returns
A boolean.
setCameraClearColor ( object  ,
{r, g, b}   
)
setCameraFar ( object  ,
far   
)

Changes the distance to the far plane of the given camera.

Parameters
objectThe camera.
farThe new distance.
setCameraFogDistance ( object  ,
fogDistance   
)

Changes the distance to the fog rendered by the given camera.

Parameters
objectThe camera.
fogDistanceThe new distance.
setCameraFov ( object  ,
fov   
)

Changes the field of view of the given camera.

Parameters
objectThe camera.
fovThe new field of view.
setCameraNear ( object  ,
near   
)

Changes the distance to the near plane of the given camera.

Parameters
objectThe camera.
nearThe new distance.