using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace BansheeEngine
{
/** @addtogroup Rendering
* @{
*/
///
/// Camera determines how is world geometry projected onto a 2D surface. You may position and orient it in space, set
/// options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
///
public partial class Camera : Component
{
private Camera(bool __dummy0) { }
protected Camera() { }
/// Returns the viewport used by the camera.
[ShowInInspector]
public Viewport Viewport
{
get { return Internal_getViewport(mCachedPtr); }
}
///
/// Determines the camera horizontal field of view. This determines how wide the camera viewing angle is along the
/// horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
///
[ShowInInspector]
public Radian FieldOfView
{
get
{
Radian temp;
Internal_getHorzFOV(mCachedPtr, out temp);
return temp;
}
set { Internal_setHorzFOV(mCachedPtr, ref value); }
}
///
/// Determines the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane
/// will not be rendered. Decreasing this value decreases depth buffer precision.
///
[ShowInInspector]
public float NearClipPlane
{
get { return Internal_getNearClipDistance(mCachedPtr); }
set { Internal_setNearClipDistance(mCachedPtr, value); }
}
///
/// Determines the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane will
/// not be rendered. Increasing this value decreases depth buffer precision.
///
[ShowInInspector]
public float FarClipPlane
{
get { return Internal_getFarClipDistance(mCachedPtr); }
set { Internal_setFarClipDistance(mCachedPtr, value); }
}
/// Determines the current viewport aspect ratio (width / height).
[ShowInInspector]
public float AspectRatio
{
get { return Internal_getAspectRatio(mCachedPtr); }
set { Internal_setAspectRatio(mCachedPtr, value); }
}
///
/// Returns the standard projection matrix that determines how are 3D points projected to two dimensions. The layout of
/// this matrix depends on currently used render system.
///
[ShowInInspector]
public Matrix4 ProjMatrix
{
get
{
Matrix4 temp;
Internal_getProjectionMatrixRS(mCachedPtr, out temp);
return temp;
}
}
/// Gets the camera view matrix. Used for positioning/orienting the camera.
[ShowInInspector]
public Matrix4 ViewMatrix
{
get
{
Matrix4 temp;
Internal_getViewMatrix(mCachedPtr, out temp);
return temp;
}
}
///
/// Determines the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
/// 2D plane.
///
[ShowInInspector]
public ProjectionType ProjectionType
{
get { return Internal_getProjectionType(mCachedPtr); }
set { Internal_setProjectionType(mCachedPtr, value); }
}
///
/// Determines the orthographic window height, for use with orthographic rendering only. The width of the window will be
/// calculated from the aspect ratio. Value is specified in world units.
///
[ShowInInspector]
public float OrthoHeight
{
get { return Internal_getOrthoWindowHeight(mCachedPtr); }
set { Internal_setOrthoWindowHeight(mCachedPtr, value); }
}
///
/// Determines the orthographic window width, for use with orthographic rendering only. The height of the window will be
/// calculated from the aspect ratio. Value is specified in world units.
///
[ShowInInspector]
public float OrthoWidth
{
get { return Internal_getOrthoWindowWidth(mCachedPtr); }
set { Internal_setOrthoWindowWidth(mCachedPtr, value); }
}
///
/// Determines a priority that determines in which orders the cameras are rendered. This only applies to cameras
/// rendering to the same render target. Higher value means the camera will be rendered sooner.
///
[ShowInInspector]
public int Priority
{
get { return Internal_getPriority(mCachedPtr); }
set { Internal_setPriority(mCachedPtr, value); }
}
/// Determines layer bitfield that is used when determining which object should the camera render.
[ShowInInspector]
public ulong Layers
{
get { return Internal_getLayers(mCachedPtr); }
set { Internal_setLayers(mCachedPtr, value); }
}
///
/// Determines number of samples to use when rendering to this camera. Values larger than 1 will enable MSAA rendering.
///
[ShowInInspector]
public uint SampleCount
{
get { return Internal_getMSAACount(mCachedPtr); }
set { Internal_setMSAACount(mCachedPtr, value); }
}
///
/// Settings that control rendering for this view. They determine how will the renderer process this view, which effects
/// will be enabled, and what properties will those effects use.
///
[ShowInInspector]
public RenderSettings RenderSettings
{
get { return Internal_getRenderSettings(mCachedPtr); }
set { Internal_setRenderSettings(mCachedPtr, value); }
}
///
/// Determines whether this is the main application camera. Main camera controls the final render surface that is
/// displayed to the user.
///
[ShowInInspector]
public bool Main
{
get { return Internal_isMain(mCachedPtr); }
set { Internal_setMain(mCachedPtr, value); }
}
/// Converts a point in world space to screen coordinates.
/// 3D point in world space.
/// 2D point on the render target attached to the camera's viewport, in pixels.
public Vector2I WorldToScreenPoint(Vector3 worldPoint)
{
Vector2I temp;
Internal_worldToScreenPoint(mCachedPtr, ref worldPoint, out temp);
return temp;
}
/// Converts a point in world space to normalized device coordinates.
/// 3D point in world space.
/// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
public Vector2 WorldToNdcPoint(Vector3 worldPoint)
{
Vector2 temp;
Internal_worldToNdcPoint(mCachedPtr, ref worldPoint, out temp);
return temp;
}
/// Converts a point in world space to view space coordinates.
/// 3D point in world space.
/// 3D point relative to the camera's coordinate system.
public Vector3 WorldToViewPoint(Vector3 worldPoint)
{
Vector3 temp;
Internal_worldToViewPoint(mCachedPtr, ref worldPoint, out temp);
return temp;
}
/// Converts a point in screen space to a point in world space.
/// 2D point on the render target attached to the camera's viewport, in pixels.
///
/// Depth to place the world point at, in world coordinates. The depth is applied to the vector going from camera origin
/// to the point on the near plane.
///
/// 3D point in world space.
public Vector3 ScreenToWorldPoint(Vector2I screenPoint, float depth = 0.5f)
{
Vector3 temp;
Internal_screenToWorldPoint(mCachedPtr, ref screenPoint, depth, out temp);
return temp;
}
/// Converts a point in screen space to a point in view space.
/// 2D point on the render target attached to the camera's viewport, in pixels.
///
/// Depth to place the world point at, in device depth. The depth is applied to the vector going from camera origin to
/// the point on the near plane.
///
/// 3D point relative to the camera's coordinate system.
public Vector3 ScreenToViewPoint(Vector2I screenPoint, float depth = 0.5f)
{
Vector3 temp;
Internal_screenToViewPoint(mCachedPtr, ref screenPoint, depth, out temp);
return temp;
}
/// Converts a point in screen space to normalized device coordinates.
/// 2D point on the render target attached to the camera's viewport, in pixels.
/// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
public Vector2 ScreenToNdcPoint(Vector2I screenPoint)
{
Vector2 temp;
Internal_screenToNdcPoint(mCachedPtr, ref screenPoint, out temp);
return temp;
}
/// Converts a point in view space to world space.
/// 3D point relative to the camera's coordinate system.
/// 3D point in world space.
public Vector3 ViewToWorldPoint(Vector3 viewPoint)
{
Vector3 temp;
Internal_viewToWorldPoint(mCachedPtr, ref viewPoint, out temp);
return temp;
}
/// Converts a point in view space to screen space.
/// 3D point relative to the camera's coordinate system.
/// 2D point on the render target attached to the camera's viewport, in pixels.
public Vector2I ViewToScreenPoint(Vector3 viewPoint)
{
Vector2I temp;
Internal_viewToScreenPoint(mCachedPtr, ref viewPoint, out temp);
return temp;
}
/// Converts a point in view space to normalized device coordinates.
/// 3D point relative to the camera's coordinate system.
/// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
public Vector2 ViewToNdcPoint(Vector3 viewPoint)
{
Vector2 temp;
Internal_viewToNdcPoint(mCachedPtr, ref viewPoint, out temp);
return temp;
}
/// Converts a point in normalized device coordinates to world space.
///
/// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
///
///
/// Depth to place the world point at. The depth is applied to the vector going from camera origin to the point on the
/// near plane.
///
/// 3D point in world space.
public Vector3 NdcToWorldPoint(Vector2 ndcPoint, float depth = 0.5f)
{
Vector3 temp;
Internal_ndcToWorldPoint(mCachedPtr, ref ndcPoint, depth, out temp);
return temp;
}
/// Converts a point in normalized device coordinates to view space.
///
/// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
///
///
/// Depth to place the world point at. The depth is applied to the vector going from camera origin to the point on the
/// near plane.
///
/// 3D point relative to the camera's coordinate system.
public Vector3 NdcToViewPoint(Vector2 ndcPoint, float depth = 0.5f)
{
Vector3 temp;
Internal_ndcToViewPoint(mCachedPtr, ref ndcPoint, depth, out temp);
return temp;
}
/// Converts a point in normalized device coordinates to screen space.
///
/// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
///
/// 2D point on the render target attached to the camera's viewport, in pixels.
public Vector2I NdcToScreenPoint(Vector2 ndcPoint)
{
Vector2I temp;
Internal_ndcToScreenPoint(mCachedPtr, ref ndcPoint, out temp);
return temp;
}
/// Converts a point in screen space to a ray in world space.
/// 2D point on the render target attached to the camera's viewport, in pixels.
/// Ray in world space, originating at the selected point on the camera near plane.
public Ray ScreenPointToRay(Vector2I screenPoint)
{
Ray temp;
Internal_screenPointToRay(mCachedPtr, ref screenPoint, out temp);
return temp;
}
///
/// Projects a point in view space to normalized device coordinates. Similar to viewToNdcPoint() but preserves the depth
/// component.
///
/// 3D point relative to the camera's coordinate system.
///
/// 3D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport. Z value range depends
/// on active render API.
///
public Vector3 ProjectPoint(Vector3 point)
{
Vector3 temp;
Internal_projectPoint(mCachedPtr, ref point, out temp);
return temp;
}
/// Un-projects a point in normalized device space to view space.
///
/// 3D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport. Z value range depends
/// on active render API.
///
/// 3D point relative to the camera's coordinate system.
public Vector3 UnprojectPoint(Vector3 point)
{
Vector3 temp;
Internal_unprojectPoint(mCachedPtr, ref point, out temp);
return temp;
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Viewport Internal_getViewport(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setHorzFOV(IntPtr thisPtr, ref Radian fovy);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getHorzFOV(IntPtr thisPtr, out Radian __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setNearClipDistance(IntPtr thisPtr, float nearDist);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getNearClipDistance(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setFarClipDistance(IntPtr thisPtr, float farDist);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getFarClipDistance(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setAspectRatio(IntPtr thisPtr, float ratio);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getAspectRatio(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getProjectionMatrixRS(IntPtr thisPtr, out Matrix4 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getViewMatrix(IntPtr thisPtr, out Matrix4 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setProjectionType(IntPtr thisPtr, ProjectionType pt);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern ProjectionType Internal_getProjectionType(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setOrthoWindowHeight(IntPtr thisPtr, float h);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getOrthoWindowHeight(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setOrthoWindowWidth(IntPtr thisPtr, float w);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getOrthoWindowWidth(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setPriority(IntPtr thisPtr, int priority);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int Internal_getPriority(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setLayers(IntPtr thisPtr, ulong layers);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern ulong Internal_getLayers(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMSAACount(IntPtr thisPtr, uint count);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern uint Internal_getMSAACount(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setRenderSettings(IntPtr thisPtr, RenderSettings settings);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern RenderSettings Internal_getRenderSettings(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_worldToScreenPoint(IntPtr thisPtr, ref Vector3 worldPoint, out Vector2I __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_worldToNdcPoint(IntPtr thisPtr, ref Vector3 worldPoint, out Vector2 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_worldToViewPoint(IntPtr thisPtr, ref Vector3 worldPoint, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_screenToWorldPoint(IntPtr thisPtr, ref Vector2I screenPoint, float depth, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_screenToViewPoint(IntPtr thisPtr, ref Vector2I screenPoint, float depth, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_screenToNdcPoint(IntPtr thisPtr, ref Vector2I screenPoint, out Vector2 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_viewToWorldPoint(IntPtr thisPtr, ref Vector3 viewPoint, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_viewToScreenPoint(IntPtr thisPtr, ref Vector3 viewPoint, out Vector2I __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_viewToNdcPoint(IntPtr thisPtr, ref Vector3 viewPoint, out Vector2 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_ndcToWorldPoint(IntPtr thisPtr, ref Vector2 ndcPoint, float depth, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_ndcToViewPoint(IntPtr thisPtr, ref Vector2 ndcPoint, float depth, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_ndcToScreenPoint(IntPtr thisPtr, ref Vector2 ndcPoint, out Vector2I __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_screenPointToRay(IntPtr thisPtr, ref Vector2I screenPoint, out Ray __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_projectPoint(IntPtr thisPtr, ref Vector3 point, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_unprojectPoint(IntPtr thisPtr, ref Vector3 point, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMain(IntPtr thisPtr, bool main);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool Internal_isMain(IntPtr thisPtr);
}
/** @} */
}