osg.Camera

class osg.Camera
Represents:c++ class
Wraps:osg::Camera
Bases:osg.Transform, osg.CullSettings

osg.Camera - is a subclass of osg.Transform which represents encapsulates the settings of a Camera.

There is also more complex example of render-to-texture (RTT) camera creation.

Constructors:

osg.Camera()

Construct a camera.

Methods:

:setAllowEventFocus(bool allow)

Set whether this osg.Camera allows events to be generated by the associated graphics window to be associated with this osg.Camera.

Parameters:allow (bool) – Must be true to allow focus, false otherwise.
:getAllowEventFocus()

Get whether this osg.Camera allows events to be generated by the associated graphics window to be associated with this osg.Camera.

Return type:bool
:setClearMask(unsigned mask)

Parameters:mask (unsigned) –
:getClearMask()

Return type:unsigned
:setClearColor(osg.Vec4 color)

Set the clear color used in glClearColor() (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glClearColor.xml).

Parameters:color (osg.Vec4) – Clear color.
:getClearColor()

Get the clear color.

Return type:osg.Vec4
:setClearAccum(osg.Vec4 color)

Set the clear accum used in glClearAccum() (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glClearAccum.xml). glClearAcumm is only called if mask & GL_ACCUM_BUFFER_BIT is true.

Parameters:color (osg.Vec4) –
:getClearAccum()

Get the clear accum value.

Return type:osg.Vec4
:setClearDepth(double depth)

Set the clear depth used in glClearDepth() (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glClearDepth.xml). Defaults to 1.0; glClearDepth is only called if mask & GL_DEPTH_BUFFER_BIT is true.

Parameters:depth (double) –
:getClearDepth()

Get the clear depth value.

Return type:double
:setClearStencil(int depth)

Set the clear stencil value used in glClearStencil() (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glClearStencil.xml). Defaults to 0; glClearStencil is only called if mask & GL_STENCIL_BUFFER_BIT is true.

Parameters:depth (int) –
:getClearStencil()

Get the clear stencil value.

Return type:int
:setColorMask(bool r, bool g, bool b, bool a)

Set the color mask of the osg.Camera to specified values.

Parameters:
  • r (bool) –
  • g (bool) –
  • b (bool) –
  • a (bool) –
:setViewport(osg.Viewport viewport)

Parameters:viewport (osg.Viewport) –
:setViewport(int x, int y, int width, int height)

Set the viewport of the osg.Camera to specified dimensions.

Parameters:
  • x (int) –
  • y (int) –
  • width (int) –
  • height (int) –
:getViewport()

Get the viewport.

Return type:osg.Viewport
:setTransformOrder(osg.Camera.TransformOrder order)

Set the transformation order for world-to-local and local-to-world transformation.

Parameters:order (osg.Camera.TransformOrder) –
:getTransformOrder()

Get the transformation order.

Return type:osg.Camera.TransformOrder
:setProjectionResizePolicy(osg.Camera.ProjectionResizePolicy policy)

Set the policy used to determine if and how the projection matrix should be adjusted on window resizes.

Parameters:policy (osg.Camera.ProjectionResizePolicy) –
:getProjectionResizePolicy()

Get the policy used to determine if and how the projection matrix should be adjusted on window resizes.

Return type:osg.Camera.ProjectionResizePolicy
:getProjectionMatrix()

Get the projection matrix.

Return type:osg.Matrix
:setProjectionMatrix(osg.Matrix projmat)

Set the projection matrix. Can be thought of as setting the lens of a osg.Camera.

Parameters:projmat (osg.Matrix) –
:setProjectionMatrixAsOrtho(double left, double right, double bottom, double top, double zNear, double zFar)

Set to an orthographic projection. See OpenGL glOrtho for documentation further details (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml).

Parameters:
  • left (double) –
  • right (double) –
  • bottom (double) –
  • top (double) –
  • zNear (double) –
  • zFar (double) –
:setProjectionMatrixAsOrtho2D(double left, double right, double bottom, double top)

Set to a 2D orthographic projection. See OpenGL glOrtho2D documentation for further details (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluOrtho2D.xml).

Parameters:
  • left (double) –
  • right (double) –
  • bottom (double) –
  • top (double) –
:setProjectionMatrixAsFrustum(double left, double right, double bottom, double top, double zNear, double zFar)

Set to a perspective projection. See OpenGL glFrustum documentation for further details (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml).

Parameters:
  • left (double) –
  • right (double) –
  • bottom (double) –
  • top (double) –
  • zNear (double) –
  • zFar (double) –
:setProjectionMatrixAsPerspective(double fovy, double ratio, double zNear, double zFar)

Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml). Aspect ratio is defined as width/height.

Parameters:
  • fovy (double) –
  • ratio (double) –
  • zNear (double) –
  • zFar (double) –
:getProjectionMatrixAsPerspective()

Get the frustum setting of a symmetric perspective projection matrix. Returns false if matrix is not a perspective matrix, where parameter values are undefined. Note, if matrix is not a symmetric perspective matrix then the shear will be lost. Asymmetric matrices occur when stereo, power walls, caves and reality center display are used. In these configurations one should use the getProjectionMatrixAsFrustum method instead.

:setViewMatrix(osg.Matrix viewmat)

Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates.

Parameters:viewmat (osg.Matrix) –
:getViewMatrix()

Get the view matrix.

Return type:osg.Matrix
:setViewMatrixAsLookAt(osg.Vec3 eye, osg.Vec3 center, osg.Vec3 up)

Set to the position and orientation of view matrix, using the same convention as gluLookAt (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml).

Parameters:
:getViewMatrixAsLookAt()

Helper function. Short version. getViewMatrixAsLookAt call with 1.0 as lookDistance argument.

:getViewMatrixAsLookAt(double lookDistance)

Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt (https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml). Helper function, returns 3 values: eye as osg.Vec3, center as osg.Vec3 and up as osg.Vec3.

Parameters:lookDistance (double) –
:getInverseViewMatrix()

Get the inverse view matrix.

Return type:osg.Matrix
:setRenderOrder(osg.Camera.RenderOrder order, int orderNum)

Set the rendering order of this osg.Camera’s subgraph relative to any camera that this subgraph is nested within. For rendering to a texture, one typically uses osg.Camera.PRE_RENDER. For Head Up Displays, one would typically use osg.Camera.POST_RENDER from osg.Camera.RenderOrder.

Parameters:
:getRenderOrder()

Get the rendering order of this osg.Camera’s subgraph relative to any camera that this subgraph is nested within.

Return type:osg.Camera.RenderOrder
:getRenderOrderNum()

Get the rendering order number of this camera relative to any sibling cameras in this subgraph.

Return type:int
:isRenderToTextureCamera()

Return true if this osg.Camera is set up as a render to texture camera, i.e. it has textures assigned to it.

Return type:bool
:attach(osg.Camera.BufferComponent buffer, GLenum.Value internalFormat)

Attach a buffer with specified OpenGL internal format.

Parameters:
:attach(osg.Camera.BufferComponent buffer, osg.Texture texture)

Helper function. Short version. attach call with level equal to 0, face equal to 0, mipMapGeneration equal to false, multisampleSamples equal to 0 and multisampleColorSamples equal to 0.

Parameters:
:attach(osg.Camera.BufferComponent buffer, osg.Texture texture, unsigned level, int face, bool mipMapGeneration, unsigned multisampleSamples, unsigned multisampleColorSamples)

Attach a osg.Texture to specified buffer component. The level parameter controls the mip map level of the texture that is attached. The face parameter controls the face of texture cube map or z level of 3d texture. The mipMapGeneration flag controls whether mipmap generation should be done for texture.

Parameters:
  • buffer (osg.Camera.BufferComponent) –
  • texture (osg.Texture) –
  • level (unsigned) –
  • face (int) –
  • mipMapGeneration (bool) –
  • multisampleSamples (unsigned) –
  • multisampleColorSamples (unsigned) –
:attachImage(osg.Camera.BufferComponent buffer, osg.Image image)

Helper function. Short version. attachImage call with multisampleSamples equal to 0.0 and multisampleColorSamples equal to 0.

Parameters:
:attachImage(osg.Camera.BufferComponent buffer, osg.Image image, unsigned multisampleSamples, unsigned multisampleColorSamples)

Attach a osg.Image to specified buffer component.

Parameters:
:detach(osg.Camera.BufferComponent buffer)

Detach specified buffer component.

Parameters:buffer (osg.Camera.BufferComponent) –
:dirtyAttachmentMap()

:getAttachmentMapModifiedCount()

Return type:unsigned
:resizeAttachments(int width, int height)

Parameters:
  • width (int) –
  • height (int) –
:resize(int width, int height)

Parameters:
  • width (int) –
  • height (int) –
:resize(int width, int height, int resizeMask)

Parameters:
  • width (int) –
  • height (int) –
  • resizeMask (int) –
:setGraphicsContext(osg.GraphicsContext ctx)

Set the osg.GraphicsContext that provides the mechansim for managing the OpenGL graphics context associated with this osg.Camera.

Parameters:ctx (osg.GraphicsContext) –
:getGraphicsContext()

Get the osg.GraphicsContext.

Return type:osg.GraphicsContext
:setRenderer(osg.GraphicsOperation renderer)

Set the Rendering object that is used to implement rendering of the subgraph.

Parameters:renderer (osg.GraphicsOperation) –
:getRenderer()

Get the Rendering object that is used to implement rendering of the subgraph.

Return type:osg.GraphicsOperation
:setRenderingCache(osg.Object rc)

Set the Rendering cache that is used for cached objects associated with rendering of subgraphs.

Parameters:rc (osg.Object) –
:getRenderingCache()

Get the const Rendering cache that is used for cached objects associated with rendering of subgraphs.

Return type:osg.Object
:setRenderTargetImplementation(osg.Camera.RenderTargetImplementation impl)

Set the render target.

Parameters:impl (osg.Camera.RenderTargetImplementation) –
:setRenderTargetImplementation(osg.Camera.RenderTargetImplementation impl, osg.Camera.RenderTargetImplementation fallback)

Set the render target and fallback that’s used if the former isn’t available.

Parameters:
:getRenderTargetImplementation()

Get the render target.

Return type:osg.Camera.RenderTargetImplementation
:getRenderTargetFallback()

Return type:osg.Camera.RenderTargetImplementation
:setDrawBuffer(int buffer)

Set the draw buffer used at the start of each frame draw. Note, a buffer value of GLenum.GL_NONE from is used to specify that the rendering back-end should choose the most appropriate buffer.

Parameters:buffer (int) –
:setReadBuffer(int buffer)

Set the read buffer for any required copy operations to use. Note, a buffer value of GLenum.GL_NONE is used to specify that the rendering back-end should choose the most appropriate buffer.

Parameters:buffer (int) –
:setProcessorAffinity(OpenThreads.Affinity affinity)

Set the process affinity hint for any Camera Threads that are/will be assigned to this osg.Camera.

Parameters:affinity (OpenThreads.Affinity) –
:getProcessorAffinity()

Return type:OpenThreads.Affinity
:setInitialDrawCallback(osg.Camera.DrawCallback cb)

Set the initial draw callback for custom operations to be done before the drawing of the camera’s subgraph and pre render stages.

Parameters:cb (osg.Camera.DrawCallback) –
:getInitialDrawCallback()

Get the initial draw callback.

Return type:osg.Camera.DrawCallback
:addInitialDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that sets DrawCallback Initial callback of the node if it doesn’t exist, or nest it into the existing one.

Parameters:nc (osg.Camera.DrawCallback) –
:removeInitialDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found.

Parameters:nc (osg.Camera.DrawCallback) –
:setPreDrawCallback(osg.Camera.DrawCallback cb)

Set the pre draw callback for custom operations to be done before the drawing of the camera’s subgraph but after any pre render stages have been completed.

Parameters:cb (osg.Camera.DrawCallback) –
:getPreDrawCallback()

Get the pre draw callback.

Return type:osg.Camera.DrawCallback
:addPreDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that sets DrawCallback Initial callback of the node if it doesn’t exist, or nest it into the existing one.

Parameters:nc (osg.Camera.DrawCallback) –
:removePreDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found.

Parameters:nc (osg.Camera.DrawCallback) –
:setPostDrawCallback(osg.Camera.DrawCallback cb)

Set the post draw callback for custom operations to be done after the drawing of the camera’s subgraph but before the any post render stages have been completed.

Parameters:cb (osg.Camera.DrawCallback) –
:getPostDrawCallback()

Get the post draw callback.

Return type:osg.Camera.DrawCallback
:addPostDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that sets DrawCallback Initial callback of the node if it doesn’t exist, or nest it into the existing one.

Parameters:nc (osg.Camera.DrawCallback) –
:removePostDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found.

Parameters:nc (osg.Camera.DrawCallback) –
:setFinalDrawCallback(osg.Camera.DrawCallback cb)

Set the final draw callback for custom operations to be done after the drawing of the camera’s subgraph and all of the post render stages has been completed.

Parameters:cb (osg.Camera.DrawCallback) –
:getFinalDrawCallback()

Get the final draw callback.

Return type:osg.Camera.DrawCallback
:addFinalDrawCallback(osg.Camera.DrawCallback nc)

Convenience method that sets DrawCallback Initial callback of the node if it doesn’t exist, or nest it into the existing one.

Parameters:nc (osg.Camera.DrawCallback) – Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found.
:removeFinalDrawCallback(osg.Camera.DrawCallback nc)

Parameters:nc (osg.Camera.DrawCallback) –