Skip to content

raisin::Camera ​

class · #include <rayrai/Camera.hpp>

Camera for offscreen rendering and interaction.

The camera owns its render targets (scene color/depth, post-process, linear depth, and picking). It can be driven by user input or by raisim sensor parameters.

Nested classes ​

  • struct RenderTargetDiagnostics — Internal: diagnostics snapshot of one camera-owned render target (returned by renderTargetDiagnostics()).

Public types ​

ProjectionMode ​

cpp
enum class ProjectionMode

Projection mode for view generation.

EnumeratorDescription
PERSPECTIVEVertical FOV from zoom.
ORTHOGRAPHICVertical extent from orthoScale.

SensorStorageMode ​

cpp
enum class SensorStorageMode

Storage mode for extracting rendered images.

EnumeratorDescription
SENSOR_SETTERCopy into the raisim sensor (setImageBuffer() / setDepthArray()).
CUSTOM_BUFFERWrite into a caller-provided buffer.

Constructors & destructor ​

Camera ​

cpp
explicit Camera(
    glm::vec3 position=glm::vec3(5.0f, 4.0f, 5.0f),
    glm::vec3 up=glm::vec3(0.0f, 0.0f, 1.0f),
    float yaw=-135.0f,
    float pitch=-30.0f)

Construct a camera with a position, up vector, and yaw/pitch.

Does not allocate GL resources. The view direction is (cos(yaw)cos(pitch), sin(yaw)cos(pitch), sin(pitch)), i.e. yaw is measured about +Z from +X and pitch upward from the XY plane (Z-up world).

Parameters

ParameterDescription
positionCamera position in world coordinates.
upWorld up vector (stored in worldUp).
yawInitial yaw angle in degrees.
pitchInitial pitch angle in degrees.
cpp
explicit Camera(raisim::RGBCamera &rgbCam)

Construct a camera from a raisim RGB camera (and allocate targets).

Copies resolution, clip planes, horizontal FOV (radians, or degrees if greater than pi) and lens model, then allocates the scene targets, so a GL context must be current. The pose is not copied.

Parameters

ParameterDescription
rgbCamRaisim RGB camera to mirror.
cpp
explicit Camera(const raisim::RGBCamera &rgbCam)

Construct a camera from a const raisim RGB camera.

Parameters

ParameterDescription
rgbCamRaisim RGB camera to mirror.
cpp
explicit Camera(raisim::DepthCamera &depthCam)

Construct a depth camera and allocate only its linear-depth target. Scene color targets are allocated if this camera is later used for RGB. Requires a current GL context; projection setup is as for the RGB overload.

Parameters

ParameterDescription
depthCamRaisim depth camera to mirror.
cpp
explicit Camera(const raisim::DepthCamera &depthCam)

Construct a camera from a const raisim depth camera.

Parameters

ParameterDescription
depthCamRaisim depth camera to mirror.
cpp
explicit Camera(const raisim::DepthCamera::DepthCameraProperties &properties)

Build render targets from copied calibration; never accesses a live sensor.

cpp
explicit Camera(const raisim::RGBCamera::RGBCameraProperties &properties)
cpp
Camera(const Camera &) = delete
cpp
Camera(Camera &&) = delete

~Camera ​

cpp
~Camera()

Public member functions ​

operator= ​

cpp
Camera &operator=(const Camera &) = delete
cpp
Camera &operator=(Camera &&) = delete

instanceId ​

cpp
std::uint64_t instanceId() const

Returns Process-unique id assigned at construction (never reused).

update ​

cpp
void update(bool processKeyboard=true)

Update camera orientation and handle input.

Recomputes front, right and up from yaw / pitch. When a target object or fixed distance is active, the camera is placed on the orbit around getTargetPosition() instead.

Parameters

ParameterDescription
processKeyboardIf true, WASD and Space (along worldUp) move the camera by movementSpeed per second assuming a fixed 1/60 s step. Ignored while orbiting a target or with a fixed distance.

getViewMatrix ​

cpp
glm::mat4 getViewMatrix() const

Get the view matrix for the current camera pose.

Returns View matrix in column-major GLM format.

getProjectionMatrix ​

cpp
glm::mat4 getProjectionMatrix() const

Get the projection matrix for the current camera state.

Returns Projection matrix in column-major GLM format.

getProjectionClipRange ​

cpp
glm::vec2 getProjectionClipRange() const

Near/far distances actually used by getProjectionMatrix().

Near is the smaller of nearPlane and zNear (when positive) and far the larger of farPlane and zFar, with fallbacks for invalid values.

Returns (near, far) in metres.

setProjectionJitterPixels ​

cpp
void setProjectionJitterPixels(const glm::vec2 &jitterPixels)

Set subpixel projection jitter in pixels for temporal AA style viewer rendering.

Parameters

ParameterDescription
jitterPixelsOffset in render-target pixels.

clearProjectionJitter ​

cpp
void clearProjectionJitter()

Clear projection jitter.

projectionJitterPixels ​

cpp
glm::vec2 projectionJitterPixels() const

Returns Current projection offset in render-target pixels (zero for sensor opt-out).

getPosition ​

cpp
glm::vec3 getPosition() const

Get the current camera position.

Returns Position in world coordinates.

mouseDelta ​

cpp
void mouseDelta(float yawOffset, float pitchOffset)

Apply mouse delta to yaw/pitch or pan in orthographic mode.

Perspective: yaw -= yawOffset, pitch += pitchOffset (pitch clamped to +-89 deg). Orthographic: pans the position by 0.05 m per unit. Call update() afterwards to refresh the direction vectors.

Parameters

ParameterDescription
yawOffsetDelta yaw in degrees (screen-space delta).
pitchOffsetDelta pitch in degrees (screen-space delta).

moveForward ​

cpp
void moveForward(float steps)

Move forward/backward or zoom in orthographic mode.

Free perspective camera: moves steps metres along front. Orthographic: scales orthoScale by 0.9^steps (min 0.1), so positive zooms in. Orbiting a target or with a fixed distance: scales the orbit distance by 1.2^steps (min 0.05 m), so positive steps move away from the target.

Parameters

ParameterDescription
stepsSigned step count (e.g. mouse-wheel delta).

setCameraFixedDistance ​

cpp
void setCameraFixedDistance(bool fixed)

Lock camera distance while orbiting.

Parameters

ParameterDescription
fixedTrue to keep distance constant.

isCameraFixedDistance ​

cpp
bool isCameraFixedDistance() const

Returns True when the orbit distance is locked.

cameraFixedDistance ​

cpp
float cameraFixedDistance() const

Returns Current orbit distance in metres (tracked while orbiting, locked when fixed).

setCameraFixedTarget ​

cpp
void setCameraFixedTarget(bool fixed)

Lock the target position to a fixed point.

Parameters

ParameterDescription
fixedTrue to use the target field as the orbit/look-at point.

isCameraFixedTarget ​

cpp
bool isCameraFixedTarget() const

Returns True when the camera target is locked to a fixed point.

setTargetObject ​

cpp
void setTargetObject(raisim::Object *target)

Set a raisim object to track as the camera target.

A non-null object clears the fixed-target lock. The camera never reads the object: the RayraiWindow that renders with this camera follows its origin in the rendered physics frame (followTargetObject()), and releases the camera once the object is gone. A fixed distance locked before the first followed frame is measured on that frame.

Parameters

ParameterDescription
targetRaisim object to follow, or nullptr to clear.

releaseTarget ​

cpp
void releaseTarget()

Stop following: clears the target object and the fixed-target and fixed-distance locks.

followTargetObject ​

cpp
bool followTargetObject(uint64_t instance, const glm::vec3 &position)

Internal: the followed targetObject as rendered, set by RayraiWindow whenever it renders; applications do not call this.

A camera that update() placed moves with the object.

Parameters

ParameterDescription
instanceRaisimObject::instanceId() of the object's drawable.
positionWorld position of the object's origin.

Returns False when another object now has the target's address: the caller releases it.

setProjectionMode ​

cpp
void setProjectionMode(ProjectionMode mode)

Set projection mode.

Parameters

ParameterDescription
modeProjection mode (perspective or orthographic).

getProjectionMode ​

cpp
ProjectionMode getProjectionMode() const

Get the active projection mode.

Returns Current projection mode.

setLensModel ​

cpp
void setLensModel(const raisim::CameraLensModel &lens, double hFovRad)

Configure the camera lens model used for sensor rendering.

Only stores the lens and horizontalFovRad; it does not change zoom.

Parameters

ParameterDescription
lensLens model (pinhole or fisheye).
hFovRadHorizontal field of view in radians.

getLensModel ​

cpp
const raisim::CameraLensModel &getLensModel() const

Get the active sensor lens model.

Returns Reference to the stored lens model.

isFisheyeLens ​

cpp
bool isFisheyeLens() const

Returns True when the camera is configured for OpenCV/ROS equidistant fisheye output.

applyFisheyeRemap ​

cpp
void applyFisheyeRemap(Shader &fisheyeShader)

Resample scene color through the fisheye lens model.

No-op unless isFisheyeLens() and scene targets exist. Renders into the post target and blits the result back into the scene color texture.

Parameters

ParameterDescription
fisheyeShaderFisheye remap shader (bound here).

getTargetPosition ​

cpp
glm::vec3 getTargetPosition() const

Get the current target position for orbiting.

Returns target when the fixed-target lock is on, else the target object's position, else the world origin.

ensureRenderTargets ​

cpp
void ensureRenderTargets(int width, int height)

Ensure render targets match the given size.

(Re)allocates the scene color/depth targets (and the MSAA target when enabled) and updates aspect. Requires a current GL context; ignored for non-positive sizes.

Parameters

ParameterDescription
widthRender target width.
heightRender target height.

resizeRenderTargets ​

cpp
void resizeRenderTargets(int width, int height)

Resize render targets, retaining depth-only allocation when applicable.

Parameters

ParameterDescription
widthRender target width.
heightRender target height.

setSceneMsaaSamples ​

cpp
void setSceneMsaaSamples(int samples)

Set scene-color MSAA samples for future scene FBO rendering.

Values <= 1 disable MSAA. The resolved color/depth are still written into the existing single-sample texture targets so postprocessing and readback APIs keep working.

Parameters

ParameterDescription
samplesRequested sample count; values above 1 are clamped to [2, GL_MAX_SAMPLES].
cpp
void setSceneMsaaSamples(int samples, bool keepAllocation)

Same as setSceneMsaaSamples(), optionally keeping an existing multisampled target.

With keepAllocation, disabling MSAA keeps the multisampled renderbuffers so re-enabling the same sample count reuses them instead of reallocating. Every scene render clears the target before drawing, so reuse cannot change the image. A later call without keepAllocation that leaves MSAA disabled releases the kept target.

Parameters

ParameterDescription
samplesRequested sample count, as in the single-argument overload.
keepAllocationKeep the multisampled renderbuffers when disabling MSAA.

sceneMsaaSamples ​

cpp
int sceneMsaaSamples() const

Returns Current scene-color MSAA sample count. 1 means disabled.

resolveSceneFboIfNeeded ​

cpp
void resolveSceneFboIfNeeded(bool restoreFramebuffer=true)

Resolve the multisampled scene target into the regular color/depth textures.

Parameters

ParameterDescription
restoreFramebufferRestore the previous read/draw framebuffer bindings afterwards.

ensurePostRenderTarget ​

cpp
void ensurePostRenderTarget()

Ensure the post-process render target exists.

ensureLinearDepthRenderTarget ​

cpp
void ensureLinearDepthRenderTarget()

Ensure the linear-depth render target exists.

bindSceneFbo ​

cpp
void bindSceneFbo()

Bind the scene framebuffer for rendering.

Binds the MSAA framebuffer when MSAA is enabled, allocating targets on demand.

bindPostFbo ​

cpp
void bindPostFbo()

Bind the post-process framebuffer for rendering.

bindLinearDepthFbo ​

cpp
void bindLinearDepthFbo()

Bind the linear-depth framebuffer for rendering.

rtWidth ​

cpp
int rtWidth() const

Current render target width.

Returns Width in pixels.

rtHeight ​

cpp
int rtHeight() const

Current render target height.

Returns Height in pixels.

beginSceneFboAndClear ​

cpp
void beginSceneFboAndClear(bool preserveState=true)

Bind scene FBO and clear color, depth and stencil with the background color.

Parameters

ParameterDescription
preserveStateRestore the color/depth/stencil write masks and scissor state afterwards; false leaves scissor disabled and masks enabled.

postProcessDoF ​

cpp
void postProcessDoF(
    Shader &postShader,
    bool fxaaEnabled=false,
    bool bloomEnabled=false,
    float bloomThreshold=0.82f,
    float bloomStrength=0.18f,
    float bloomRadius=4.0f,
    float bloomKnee=0.22f,
    int bloomQuality=1,
    float bloomSourceClamp=8.0f,
    float bloomAnamorphic=0.0f,
    float bloomDirtStrength=0.0f,
    float bloomDirtScale=1.0f,
    unsigned int bloomDirtTexture=0,
    int bloomBlendMode=0,
    float bloomMix=0.05f,
    const glm::vec3 &viewerWhiteBalance=glm::vec3(1.0f),
    float viewerSaturation=1.0f,
    bool screenSpaceAoEnabled=false,
    float screenSpaceAoRadius=2.0f,
    float screenSpaceAoStrength=0.0f,
    float screenSpaceAoBias=0.02f,
    int screenSpaceAoSamples=12,
    float screenSpaceAoFalloff=0.08f,
    bool screenSpaceAoRadiusWorldSpace=false,
    float screenSpaceAoMaxPixelRadius=48.0f,
    bool screenSpaceAoGeometryAware=false,
    float contactAoRadius=0.0f,
    float contactAoStrength=0.0f,
    int contactAoSamples=8,
    float contactAoFalloff=0.05f,
    bool screenSpaceAoDenoiseEnabled=false,
    float screenSpaceAoDenoiseStrength=0.0f,
    int screenSpaceAoDenoiseRadius=1,
    float screenSpaceAoDenoiseDepthSigma=0.035f,
    bool screenSpaceIndirectLightingEnabled=false,
    float screenSpaceIndirectLightingRadius=3.0f,
    float screenSpaceIndirectLightingStrength=0.0f,
    int screenSpaceIndirectLightingSamples=12,
    float screenSpaceIndirectLightingFalloff=0.22f,
    float screenSpaceIndirectLightingNormalRejection=0.75f,
    float screenSpaceIndirectLightingSaturation=1.0f,
    bool volumetricFogEnabled=false,
    float volumetricFogDensity=0.0f,
    float volumetricFogNoiseScale=6.0f,
    float volumetricFogNoiseStrength=0.55f,
    const glm::vec3 &volumetricFogColor=glm::vec3(0.72f, 0.80f, 0.90f),
    float volumetricFogAnisotropy=0.0f,
    float volumetricFogAnimationTimeSeconds=0.0f,
    const glm::vec2 &volumetricFogWindDirection=glm::vec2(1.0f, 0.0f),
    float volumetricFogWindSpeed=0.0f,
    float volumetricFogTurbulenceSpeed=0.0f,
    bool volumetricLightingEnabled=false,
    float volumetricLightStrength=0.0f,
    float volumetricLightDecay=0.88f,
    int volumetricLightSamples=16,
    const glm::vec2 &volumetricLightScreenPosition=glm::vec2(0.5f),
    const glm::vec3 &volumetricLightColor=glm::vec3(1.0f),
    int localFogVolumeCount=0,
    const std::array<glm::vec4, 8> &localFogVolumeCenterRadius={},
    const std::array<glm::vec4, 8> &localFogVolumeColorDensity={},
    const std::array<glm::vec4, 8> &localFogVolumeParams={},
    int projectedDecalCount=0,
    const std::array<glm::mat4, 8> &projectedDecalWorldToLocal={},
    const std::array<glm::vec4, 8> &projectedDecalColor={},
    const std::array<glm::vec4, 8> &projectedDecalParams={},
    const std::array<unsigned int, 8> &projectedDecalAlbedoMaps={},
    const std::array<unsigned int, 8> &projectedDecalEmissionMaps={},
    const std::array<unsigned int, 8> &projectedDecalNormalMaps={},
    const std::array<unsigned int, 8> &projectedDecalOrmMaps={},
    const std::array<glm::vec4, 8> &projectedDecalTextureParams={},
    const std::array<glm::vec4, 8> &projectedDecalSurfaceParams={},
    const std::array<glm::vec4, 8> &projectedDecalUvScaleOffset={},
    bool temporalAaEnabled=false,
    float temporalAaBlend=0.08f,
    bool temporalAaReset=false,
    int postProcessDebugMode=0,
    bool aerialPerspectiveEnabled=false,
    unsigned int apVolumeTex=0,
    float apStrength=1.0f,
    int viewerColorGradePreset=0,
    float viewerColorGradeStrength=1.0f,
    float viewerVignetteStrength=0.0f,
    float viewerChromaticAberrationStrength=0.0f,
    float viewerFilmGrainStrength=0.0f,
    float viewerLensCharacterTime=0.0f,
    bool lightShaftsEnabled=false,
    float lightShaftsStrength=1.0f,
    float lightShaftsDecay=0.965f,
    float lightShaftsDensity=1.0f,
    const glm::vec2 &lightShaftsSunScreenPos=glm::vec2(0.5f, 0.5f),
    const glm::vec3 &lightShaftsTint=glm::vec3(1.0f),
    float lensFlareGhostStrength=0.0f,
    float lensFlareStreakStrength=0.0f,
    const glm::vec3 &lensFlareTint=glm::vec3(1.0f),
    bool contactShadowsEnabled=false,
    float contactShadowsLength=0.12f,
    float contactShadowsStrength=0.7f,
    float contactShadowsThickness=0.08f,
    const glm::vec2 &contactShadowsSunScreenPos=glm::vec2(0.5f, 0.5f),
    const glm::vec3 &contactShadowsLightDirectionWorld=glm::vec3(0.0f, 0.0f, -1.0f),
    bool motionBlurEnabled=false,
    const glm::vec2 &motionBlurDirection=glm::vec2(0.0f),
    float motionBlurStrength=0.0f,
    bool ssrEnabled=false,
    float ssrStrength=0.0f,
    int ssrSteps=24,
    float ssrMaxDistance=6.0f,
    float ssrThickness=0.35f,
    bool heatHazeEnabled=false,
    float heatHazeStrength=0.0f,
    float heatHazeFrequency=4.0f,
    float heatHazeSpeed=1.0f,
    float heatHazeMaxY=0.55f,
    bool zoomBlurEnabled=false,
    float zoomBlurStrength=0.0f,
    const glm::vec2 &zoomBlurCenter=glm::vec2(0.5f),
    float zoomBlurInnerRadius=0.15f,
    bool posterizeEnabled=false,
    int posterizeLevels=4,
    bool starburstEnabled=false,
    float starburstStrength=0.0f,
    int starburstSpikes=6,
    float starburstAngleOffset=0.0f,
    float starburstRadius=0.35f,
    const glm::vec3 &starburstTint=glm::vec3(1.0f, 0.95f, 0.85f),
    bool lensDistortionEnabled=false,
    float lensDistortionStrength=0.0f,
    const glm::vec2 &lensDistortionCenter=glm::vec2(0.5f),
    bool underwaterEnabled=false,
    const glm::vec3 &underwaterTint=glm::vec3(0.30f, 0.60f, 0.85f),
    float underwaterCausticStrength=0.5f,
    float underwaterCausticScale=1.0f,
    float underwaterDepthExtinction=1.0f,
    bool pixelateEnabled=false,
    int pixelateBlockSize=4,
    bool nightVisionEnabled=false,
    float nightVisionStrength=0.0f,
    float nightVisionGain=2.5f,
    bool ditherEnabled=false,
    float ditherStrength=0.004f,
    bool thermalEnabled=false,
    float thermalStrength=0.0f,
    float thermalGain=1.5f,
    bool scanlineEnabled=false,
    float scanlineStrength=0.3f,
    float scanlineFrequency=360.0f,
    bool letterboxEnabled=false,
    float letterboxAspect=2.35f,
    const glm::vec3 &letterboxColor=glm::vec3(0.0f),
    Shader *aoPrepassShader=nullptr,
    Shader *contactShadowShader=nullptr)

Apply viewer post-processing.

Internal: called by RayraiWindow, which fills the long parameter list from its render-quality and weather settings. The remaining parameters map one-to-one onto post-shader uniforms. When no effect is enabled the pass is skipped and getFinalTexture() keeps returning the scene color.

Parameters

ParameterDescription
postShaderShader configured for DoF, FXAA, and bloom.
fxaaEnabledTrue to apply FXAA even when DoF is disabled.
aoPrepassShaderOptional leaner post program that runs the AO prepass, which caches AO for the denoiser, in place of postShader (null: postShader runs it).
contactShadowShaderPost program that renders only the unfiltered contact shadows of the filter taps, into a texture postShader then filters (uContactShadowTexture). Each tap is marched once although up to four pixels share it. Required when postShader declares that sampler and contact shadows are enabled; ignored otherwise. That program's decal map pool is one slot smaller.

resetTemporalHistory ​

cpp
void resetTemporalHistory()

Reset the temporal postprocess history before the next temporal frame.

updateAutoExposure ​

cpp
void updateAutoExposure(
    float targetKey,
    float speed,
    float minFactor,
    float maxFactor)

Sample mean scene-color luma and lerp the auto-exposure factor.

Every 4th call issues an asynchronous PBO readback of the smallest mip of the post-process (or scene) color; a completed earlier readback, if any, yields the mean luma, and autoExposureFactor_ is smoothed toward targetKey / mean. Never blocks: without a ready sample the factor is unchanged. Should be called once per frame, after post-process completes. The stored factor is then applied to the next frame's pbrExposure.

Parameters

ParameterDescription
targetKeyDesired mean luma (approximately linear, 0..1).
speedLerp factor per update, clamped to [0, 1].
minFactorLower clamp of the exposure factor.
maxFactorUpper clamp of the exposure factor.

autoExposureFactor ​

cpp
float autoExposureFactor() const

Returns Smoothed auto-exposure multiplier from the previous frame.

debugAutoExposureIssuedReadbacks ​

cpp
size_t debugAutoExposureIssuedReadbacks() const

Internal:

Returns number of auto-exposure readbacks issued (diagnostics).

debugAutoExposureCompletedReadbacks ​

cpp
size_t debugAutoExposureCompletedReadbacks() const

Internal:

Returns number of auto-exposure readbacks consumed (diagnostics).

debugAutoExposureSkippedIssueFrames ​

cpp
size_t debugAutoExposureSkippedIssueFrames() const

Internal:

Returns readback slots skipped because the ring was full or fencing failed (diagnostics).

resetAutoExposure ​

cpp
void resetAutoExposure()

Reset auto-exposure to identity (no compensation).

temporalHistoryValid ​

cpp
bool temporalHistoryValid() const

Returns True if a temporal history texture is available for the current render target.

temporalHistoryFrameCount ​

cpp
int temporalHistoryFrameCount() const

Returns Number of post-process frames copied into temporal history since the last reset.

ensurePickFramebuffer ​

cpp
void ensurePickFramebuffer()

Ensure the picking framebuffer is created.

readPickIdAt ​

cpp
uint32_t readPickIdAt(int x, int y) const

Read the encoded pick id at a pixel coordinate.

Synchronous glReadPixels from the pick framebuffer.

Parameters

ParameterDescription
xX coordinate in render-target pixels from the left.
yY coordinate in render-target pixels from the top (flipped internally).

Returns 24-bit id encoded in the pick texture's RGB bytes; 0 when out of bounds.

getPickFbo ​

cpp
unsigned int getPickFbo() const

Get the picking FBO id.

Returns OpenGL framebuffer id.

getFinalTexture ​

cpp
unsigned int getFinalTexture() const

Get the final texture to display (post or debug).

Returns Pick texture when setDebugShowPick(true), else the post-process color if post-processing ran since the last scene bind, else the scene color texture.

getSceneColorTex ​

cpp
unsigned int getSceneColorTex() const

Get the scene color texture id.

Returns Color texture id, or zero before scene targets are allocated.

getSceneDepthTex ​

cpp
unsigned int getSceneDepthTex() const

Get the scene depth texture id.

Returns Depth24/stencil8 texture id, or zero before scene targets are allocated.

getSceneFbo ​

cpp
unsigned int getSceneFbo() const

Get the scene framebuffer id.

Returns Single-sample scene FBO id; zero before a color render or explicit ensureRenderTargets().

getLinearDepthTexture ​

cpp
unsigned int getLinearDepthTexture() const

Get the linear depth texture id (R32F).

Returns Linear depth texture id, or zero before the linear-depth target is allocated.

renderTargetDiagnostics ​

cpp
std::vector<RenderTargetDiagnostics> renderTargetDiagnostics() const

Return a diagnostics-only snapshot of camera-owned render targets.

Queries framebuffer status, so a current GL context is required.

Returns One entry per target (scene, MSAA, post, temporal, bloom, picking, linear depth, ...).

getRawImage ​

cpp
void getRawImage(
    raisim::RGBCamera &sensor,
    SensorStorageMode mode=SensorStorageMode::SENSOR_SETTER,
    char *customBuffer=nullptr,
    size_t customBufferSize=0,
    bool flipVertical=true) const

Read the color buffer into a raisim RGB camera or custom buffer.

Synchronously reads the scene color target (before post-processing) as 8-bit BGRA, width*height*4 bytes; each channel is clamped to [0, 1] and rounded to the nearest 8-bit value. Hardware renderers pack the image on the GPU; software renderers convert native half-float pixels with exact CPU arithmetic. The sensor resolution must match the render target and the scene color target must exist (fatal otherwise). Requires a current GL context. The sensor's configured measurement noise is applied in place after readback, in either storage mode; each call advances that sensor's random stream.

Parameters

ParameterDescription
sensorRaisim RGB camera providing the resolution; filled when using SENSOR_SETTER.
modeStorage mode (sensor setter or custom buffer).
customBufferDestination for BGRA bytes when using CUSTOM_BUFFER (required then).
customBufferSizeSize of custom buffer in bytes (at least width*height*4).
flipVerticalWhether to flip rows from GL origin to image origin.
cpp
void getRawImage(
    raisim::DepthCamera &sensor,
    SensorStorageMode mode=SensorStorageMode::SENSOR_SETTER,
    float *customBuffer=nullptr,
    size_t customBufferLength=0,
    bool flipVertical=true) const

Read the linear depth buffer into a raisim depth camera or custom buffer.

Synchronous read of the R32F linear-depth target. With flipVertical the rows are reversed on the GPU for hardware renderers or in CPU memory for software renderers, preserving sample bytes. The sensor resolution must match the render target and the linear-depth target must exist (fatal otherwise). The sensor's configured measurement noise, quantization and dropout are applied in place in either storage mode. Readback does not populate the sensor's 3D points.

Parameters

ParameterDescription
sensorRaisim depth camera providing the resolution; filled when using SENSOR_SETTER.
modeStorage mode (sensor setter or custom buffer).
customBufferDestination for float depth values when using CUSTOM_BUFFER (required then).
customBufferLengthLength of custom buffer in floats (at least width*height).
flipVerticalWhether to flip rows from GL origin to image origin.

readSceneColorBgra ​

cpp
void readSceneColorBgra(
    char *destination,
    size_t bytes,
    bool flipVertical=true) const

Synchronous BGRA8 readback into application-owned storage; no raisim sensor is accessed.

readLinearDepth ​

cpp
void readLinearDepth(
    float *destination,
    size_t samples,
    bool flipVertical=true) const

Synchronous float32 plane-depth readback; no raisim sensor is accessed.

setAsyncReadbackEnabled ​

cpp
void setAsyncReadbackEnabled(bool enabled, size_t ringSize=3)

Configure optional PBO-backed readback helpers.

Sensor getRawImage() remains synchronous by default. After the configured PBO ring fills, the async helpers return an earlier completed frame and normally lag by ringSize calls.

Parameters

ParameterDescription
enabledEnable the async helpers; disabling releases the PBOs.
ringSizeNumber of PBOs per ring (min 2).

isAsyncReadbackEnabled ​

cpp
bool isAsyncReadbackEnabled() const

Returns True when the async readback helpers are enabled.

readSceneColorRgbaAsync ​

cpp
bool readSceneColorRgbaAsync(
    std::vector<unsigned char> &rgba,
    bool flipVertical=true) const

Queue a readback of the scene color (RGBA8) and fetch the oldest pending one.

Parameters

ParameterDescription
rgba (out)Filled with width*height*4 bytes when a frame is returned.
flipVerticalWhether to flip rows from GL origin to image origin.

Returns True if rgba was filled; false while the ring is filling, when disabled, or without a scene color target.

readLinearDepthAsync ​

cpp
bool readLinearDepthAsync(
    std::vector<float> &depth,
    bool flipVertical=true) const

Queue a readback of the linear depth (float) and fetch the oldest pending one.

Parameters

ParameterDescription
depth (out)Filled with width*height floats when a frame is returned.
flipVerticalWhether to flip rows from GL origin to image origin.

Returns True if depth was filled; false while the ring is filling, when disabled, or without a linear-depth target.

setBackgroundColor ​

cpp
void setBackgroundColor(const glm::vec4 &c)

Set the background clear color using legacy 0..255 RGBA channels.

Parameters

ParameterDescription
cRGBA color where each channel is in [0, 255].

Prefer setBackgroundColorRgb255() in new code to make the range explicit.

setBackgroundColorRgb255 ​

cpp
void setBackgroundColorRgb255(const glm::vec4 &c)

Set the background clear color using 0..255 RGBA channels.

Parameters

ParameterDescription
cRGBA color where each channel is in [0, 255].

setBackgroundColorLinear ​

cpp
void setBackgroundColorLinear(const glm::vec4 &c)

Set the background clear color using linear 0..1 RGBA channels.

Parameters

ParameterDescription
cLinear RGBA color where each channel is in [0, 1].

getBackgroundColor ​

cpp
glm::vec4 getBackgroundColor() const

Get the background clear color.

Returns Legacy RGBA color in [0, 255].

getBackgroundColorLinear ​

cpp
glm::vec4 getBackgroundColorLinear() const

Get the background clear color in linear 0..1 channels.

Returns Linear RGBA color in [0, 1].

setGamma ​

cpp
void setGamma(float g)

Set the display gamma (output encoded as c^(1/g); default 1).

Applied to the background clear color and passed to the scene shaders.

Parameters

ParameterDescription
gGamma value.

getGamma ​

cpp
float getGamma() const

Get gamma correction value.

Returns Gamma value.

setDOFEnabled ​

cpp
void setDOFEnabled(bool e)

Enable or disable DoF.

Parameters

ParameterDescription
eTrue to enable.

getDOFEnabled ​

cpp
bool getDOFEnabled() const

Get DoF enabled state.

Returns True if DoF is enabled.

getDOFFocusDistance ​

cpp
float getDOFFocusDistance() const

Returns DoF focus distance in metres.

getDOFFocusRange ​

cpp
float getDOFFocusRange() const

Returns Width of the fully sharp band in metres.

getDOFMaxRadius ​

cpp
float getDOFMaxRadius() const

Returns Maximum blur (bokeh) radius in pixels.

setDOFParams ​

cpp
void setDOFParams(float focusDist, float focusRange, float maxRadius)

Set DoF parameters.

Parameters

ParameterDescription
focusDistFocus distance in metres.
focusRangeWidth of the fully sharp band centred on the focus distance, in metres.
maxRadiusMax blur (bokeh) radius in pixels.

setDebugShowPick ​

cpp
void setDebugShowPick(bool e)

Toggle rendering of the pick buffer for debugging.

Parameters

ParameterDescription
eTrue to show pick buffer.

isDebugShowingPick ​

cpp
bool isDebugShowingPick() const

Check if the pick buffer is shown for debugging.

Returns True if pick buffer is displayed.

Static member functions ​

unbindFbo static ​

cpp
static void unbindFbo()

Unbind any framebuffer (bind default).

Public attributes ​

position ​

cpp
glm::vec3 position

Camera pose and view parameters (public for quick access).

Distances are in world units (typically metres). Angles in degrees unless the field name ends in Rad. nearPlane/farPlane and zNear/zFar are overlapping pairs from earlier API revisions: they are not aliases; the projection uses the wider of the two ranges (see getProjectionClipRange()), so with the default zNear of 0.01 raising only nearPlane has no effect. Prefer nearPlane/farPlane in new code.

position, front, up, right are world-space; front/up/right are recomputed by update(). target is the orbit point used only while setCameraFixedTarget(true) is active. worldUp is the up reference.

front ​

cpp
glm::vec3 front

Unit view direction (world).

target ​

cpp
glm::vec3 target

Fixed orbit/look-at point, used while setCameraFixedTarget(true).

up ​

cpp
glm::vec3 up

Camera up vector (world), orthogonal to front.

cpp
glm::vec3 right

Camera right vector (world).

worldUp ​

cpp
glm::vec3 worldUp

World up reference used to build right and for Space-key motion.

yaw ​

cpp
float yaw

Yaw in degrees, measured about +Z from +X.

pitch ​

cpp
float pitch

Degrees.

Pitch in degrees above the XY plane (clamped to +-89 by mouseDelta()).

movementSpeed ​

cpp
float movementSpeed

Keyboard movement speed in m/s (default 5).

zoom ​

cpp
float zoom

Vertical field of view in degrees used by the perspective projection (default 45).

aspect ​

cpp
float aspect

Horizontal / vertical.

horizontalFovRad ​

cpp
float horizontalFovRad

Radians (45°).

Horizontal FOV in radians used by the lens model / fisheye remap only; the perspective projection uses zoom. The constructor derives it from the default 45 deg vertical FOV and 16:9 aspect.

nearPlane ​

cpp
float nearPlane

Near clip distance in metres (see getProjectionClipRange()).

farPlane ​

cpp
float farPlane

Metres.

Far clip distance in metres (see getProjectionClipRange()).

orthoScale ​

cpp
float orthoScale

Metres of vertical view extent in ortho mode.

zNear ​

cpp
float zNear

Legacy near clip in metres; the smaller of this and nearPlane is used.

zFar ​

cpp
float zFar

Metres. Legacy aliases — prefer nearPlane/farPlane.

Legacy far clip in metres; the larger of this and farPlane is used.

targetObject ​

cpp
raisim::Object *targetObject

Current target raisim object (if any); an identity key, never dereferenced.

RaiSim — physics for robotics and AI.