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
structRenderTargetDiagnostics — Internal: diagnostics snapshot of one camera-owned render target (returned by renderTargetDiagnostics()).
Public types
ProjectionMode
enum class ProjectionModeProjection mode for view generation.
| Enumerator | Description |
|---|---|
PERSPECTIVE | Vertical FOV from zoom. |
ORTHOGRAPHIC | Vertical extent from orthoScale. |
SensorStorageMode
enum class SensorStorageModeStorage mode for extracting rendered images.
| Enumerator | Description |
|---|---|
SENSOR_SETTER | Copy into the raisim sensor (setImageBuffer() / setDepthArray()). |
CUSTOM_BUFFER | Write into a caller-provided buffer. |
Constructors & destructor
Camera
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
| Parameter | Description |
|---|---|
position | Camera position in world coordinates. |
up | World up vector (stored in worldUp). |
yaw | Initial yaw angle in degrees. |
pitch | Initial pitch angle in degrees. |
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
| Parameter | Description |
|---|---|
rgbCam | Raisim RGB camera to mirror. |
explicit Camera(const raisim::RGBCamera &rgbCam)Construct a camera from a const raisim RGB camera.
Parameters
| Parameter | Description |
|---|---|
rgbCam | Raisim RGB camera to mirror. |
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
| Parameter | Description |
|---|---|
depthCam | Raisim depth camera to mirror. |
explicit Camera(const raisim::DepthCamera &depthCam)Construct a camera from a const raisim depth camera.
Parameters
| Parameter | Description |
|---|---|
depthCam | Raisim depth camera to mirror. |
explicit Camera(const raisim::DepthCamera::DepthCameraProperties &properties)Build render targets from copied calibration; never accesses a live sensor.
explicit Camera(const raisim::RGBCamera::RGBCameraProperties &properties)Camera(const Camera &) = deleteCamera(Camera &&) = delete~Camera
~Camera()Public member functions
operator=
Camera &operator=(const Camera &) = deleteCamera &operator=(Camera &&) = deleteinstanceId
std::uint64_t instanceId() constReturns Process-unique id assigned at construction (never reused).
update
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
| Parameter | Description |
|---|---|
processKeyboard | If 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
glm::mat4 getViewMatrix() constGet the view matrix for the current camera pose.
Returns View matrix in column-major GLM format.
getProjectionMatrix
glm::mat4 getProjectionMatrix() constGet the projection matrix for the current camera state.
Returns Projection matrix in column-major GLM format.
getProjectionClipRange
glm::vec2 getProjectionClipRange() constNear/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
void setProjectionJitterPixels(const glm::vec2 &jitterPixels)Set subpixel projection jitter in pixels for temporal AA style viewer rendering.
Parameters
| Parameter | Description |
|---|---|
jitterPixels | Offset in render-target pixels. |
clearProjectionJitter
void clearProjectionJitter()Clear projection jitter.
projectionJitterPixels
glm::vec2 projectionJitterPixels() constReturns Current projection offset in render-target pixels (zero for sensor opt-out).
getPosition
glm::vec3 getPosition() constGet the current camera position.
Returns Position in world coordinates.
mouseDelta
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
| Parameter | Description |
|---|---|
yawOffset | Delta yaw in degrees (screen-space delta). |
pitchOffset | Delta pitch in degrees (screen-space delta). |
moveForward
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
| Parameter | Description |
|---|---|
steps | Signed step count (e.g. mouse-wheel delta). |
setCameraFixedDistance
void setCameraFixedDistance(bool fixed)Lock camera distance while orbiting.
Parameters
| Parameter | Description |
|---|---|
fixed | True to keep distance constant. |
isCameraFixedDistance
bool isCameraFixedDistance() constReturns True when the orbit distance is locked.
cameraFixedDistance
float cameraFixedDistance() constReturns Current orbit distance in metres (tracked while orbiting, locked when fixed).
setCameraFixedTarget
void setCameraFixedTarget(bool fixed)Lock the target position to a fixed point.
Parameters
| Parameter | Description |
|---|---|
fixed | True to use the target field as the orbit/look-at point. |
isCameraFixedTarget
bool isCameraFixedTarget() constReturns True when the camera target is locked to a fixed point.
setTargetObject
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
| Parameter | Description |
|---|---|
target | Raisim object to follow, or nullptr to clear. |
releaseTarget
void releaseTarget()Stop following: clears the target object and the fixed-target and fixed-distance locks.
followTargetObject
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
| Parameter | Description |
|---|---|
instance | RaisimObject::instanceId() of the object's drawable. |
position | World position of the object's origin. |
Returns False when another object now has the target's address: the caller releases it.
setProjectionMode
void setProjectionMode(ProjectionMode mode)Set projection mode.
Parameters
| Parameter | Description |
|---|---|
mode | Projection mode (perspective or orthographic). |
getProjectionMode
ProjectionMode getProjectionMode() constGet the active projection mode.
Returns Current projection mode.
setLensModel
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
| Parameter | Description |
|---|---|
lens | Lens model (pinhole or fisheye). |
hFovRad | Horizontal field of view in radians. |
getLensModel
const raisim::CameraLensModel &getLensModel() constGet the active sensor lens model.
Returns Reference to the stored lens model.
isFisheyeLens
bool isFisheyeLens() constReturns True when the camera is configured for OpenCV/ROS equidistant fisheye output.
applyFisheyeRemap
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
| Parameter | Description |
|---|---|
fisheyeShader | Fisheye remap shader (bound here). |
getTargetPosition
glm::vec3 getTargetPosition() constGet 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
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
| Parameter | Description |
|---|---|
width | Render target width. |
height | Render target height. |
resizeRenderTargets
void resizeRenderTargets(int width, int height)Resize render targets, retaining depth-only allocation when applicable.
Parameters
| Parameter | Description |
|---|---|
width | Render target width. |
height | Render target height. |
setSceneMsaaSamples
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
| Parameter | Description |
|---|---|
samples | Requested sample count; values above 1 are clamped to [2, GL_MAX_SAMPLES]. |
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
| Parameter | Description |
|---|---|
samples | Requested sample count, as in the single-argument overload. |
keepAllocation | Keep the multisampled renderbuffers when disabling MSAA. |
sceneMsaaSamples
int sceneMsaaSamples() constReturns Current scene-color MSAA sample count. 1 means disabled.
resolveSceneFboIfNeeded
void resolveSceneFboIfNeeded(bool restoreFramebuffer=true)Resolve the multisampled scene target into the regular color/depth textures.
Parameters
| Parameter | Description |
|---|---|
restoreFramebuffer | Restore the previous read/draw framebuffer bindings afterwards. |
ensurePostRenderTarget
void ensurePostRenderTarget()Ensure the post-process render target exists.
ensureLinearDepthRenderTarget
void ensureLinearDepthRenderTarget()Ensure the linear-depth render target exists.
bindSceneFbo
void bindSceneFbo()Bind the scene framebuffer for rendering.
Binds the MSAA framebuffer when MSAA is enabled, allocating targets on demand.
bindPostFbo
void bindPostFbo()Bind the post-process framebuffer for rendering.
bindLinearDepthFbo
void bindLinearDepthFbo()Bind the linear-depth framebuffer for rendering.
rtWidth
int rtWidth() constCurrent render target width.
Returns Width in pixels.
rtHeight
int rtHeight() constCurrent render target height.
Returns Height in pixels.
beginSceneFboAndClear
void beginSceneFboAndClear(bool preserveState=true)Bind scene FBO and clear color, depth and stencil with the background color.
Parameters
| Parameter | Description |
|---|---|
preserveState | Restore the color/depth/stencil write masks and scissor state afterwards; false leaves scissor disabled and masks enabled. |
postProcessDoF
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
| Parameter | Description |
|---|---|
postShader | Shader configured for DoF, FXAA, and bloom. |
fxaaEnabled | True to apply FXAA even when DoF is disabled. |
aoPrepassShader | Optional leaner post program that runs the AO prepass, which caches AO for the denoiser, in place of postShader (null: postShader runs it). |
contactShadowShader | Post 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
void resetTemporalHistory()Reset the temporal postprocess history before the next temporal frame.
updateAutoExposure
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
| Parameter | Description |
|---|---|
targetKey | Desired mean luma (approximately linear, 0..1). |
speed | Lerp factor per update, clamped to [0, 1]. |
minFactor | Lower clamp of the exposure factor. |
maxFactor | Upper clamp of the exposure factor. |
autoExposureFactor
float autoExposureFactor() constReturns Smoothed auto-exposure multiplier from the previous frame.
debugAutoExposureIssuedReadbacks
size_t debugAutoExposureIssuedReadbacks() constInternal:
Returns number of auto-exposure readbacks issued (diagnostics).
debugAutoExposureCompletedReadbacks
size_t debugAutoExposureCompletedReadbacks() constInternal:
Returns number of auto-exposure readbacks consumed (diagnostics).
debugAutoExposureSkippedIssueFrames
size_t debugAutoExposureSkippedIssueFrames() constInternal:
Returns readback slots skipped because the ring was full or fencing failed (diagnostics).
resetAutoExposure
void resetAutoExposure()Reset auto-exposure to identity (no compensation).
temporalHistoryValid
bool temporalHistoryValid() constReturns True if a temporal history texture is available for the current render target.
temporalHistoryFrameCount
int temporalHistoryFrameCount() constReturns Number of post-process frames copied into temporal history since the last reset.
ensurePickFramebuffer
void ensurePickFramebuffer()Ensure the picking framebuffer is created.
readPickIdAt
uint32_t readPickIdAt(int x, int y) constRead the encoded pick id at a pixel coordinate.
Synchronous glReadPixels from the pick framebuffer.
Parameters
| Parameter | Description |
|---|---|
x | X coordinate in render-target pixels from the left. |
y | Y 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
unsigned int getPickFbo() constGet the picking FBO id.
Returns OpenGL framebuffer id.
getFinalTexture
unsigned int getFinalTexture() constGet 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
unsigned int getSceneColorTex() constGet the scene color texture id.
Returns Color texture id, or zero before scene targets are allocated.
getSceneDepthTex
unsigned int getSceneDepthTex() constGet the scene depth texture id.
Returns Depth24/stencil8 texture id, or zero before scene targets are allocated.
getSceneFbo
unsigned int getSceneFbo() constGet the scene framebuffer id.
Returns Single-sample scene FBO id; zero before a color render or explicit ensureRenderTargets().
getLinearDepthTexture
unsigned int getLinearDepthTexture() constGet the linear depth texture id (R32F).
Returns Linear depth texture id, or zero before the linear-depth target is allocated.
renderTargetDiagnostics
std::vector<RenderTargetDiagnostics> renderTargetDiagnostics() constReturn 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
void getRawImage(
raisim::RGBCamera &sensor,
SensorStorageMode mode=SensorStorageMode::SENSOR_SETTER,
char *customBuffer=nullptr,
size_t customBufferSize=0,
bool flipVertical=true) constRead 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
| Parameter | Description |
|---|---|
sensor | Raisim RGB camera providing the resolution; filled when using SENSOR_SETTER. |
mode | Storage mode (sensor setter or custom buffer). |
customBuffer | Destination for BGRA bytes when using CUSTOM_BUFFER (required then). |
customBufferSize | Size of custom buffer in bytes (at least width*height*4). |
flipVertical | Whether to flip rows from GL origin to image origin. |
void getRawImage(
raisim::DepthCamera &sensor,
SensorStorageMode mode=SensorStorageMode::SENSOR_SETTER,
float *customBuffer=nullptr,
size_t customBufferLength=0,
bool flipVertical=true) constRead 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
| Parameter | Description |
|---|---|
sensor | Raisim depth camera providing the resolution; filled when using SENSOR_SETTER. |
mode | Storage mode (sensor setter or custom buffer). |
customBuffer | Destination for float depth values when using CUSTOM_BUFFER (required then). |
customBufferLength | Length of custom buffer in floats (at least width*height). |
flipVertical | Whether to flip rows from GL origin to image origin. |
readSceneColorBgra
void readSceneColorBgra(
char *destination,
size_t bytes,
bool flipVertical=true) constSynchronous BGRA8 readback into application-owned storage; no raisim sensor is accessed.
readLinearDepth
void readLinearDepth(
float *destination,
size_t samples,
bool flipVertical=true) constSynchronous float32 plane-depth readback; no raisim sensor is accessed.
setAsyncReadbackEnabled
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
| Parameter | Description |
|---|---|
enabled | Enable the async helpers; disabling releases the PBOs. |
ringSize | Number of PBOs per ring (min 2). |
isAsyncReadbackEnabled
bool isAsyncReadbackEnabled() constReturns True when the async readback helpers are enabled.
readSceneColorRgbaAsync
bool readSceneColorRgbaAsync(
std::vector<unsigned char> &rgba,
bool flipVertical=true) constQueue a readback of the scene color (RGBA8) and fetch the oldest pending one.
Parameters
| Parameter | Description |
|---|---|
rgba (out) | Filled with width*height*4 bytes when a frame is returned. |
flipVertical | Whether 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
bool readLinearDepthAsync(
std::vector<float> &depth,
bool flipVertical=true) constQueue a readback of the linear depth (float) and fetch the oldest pending one.
Parameters
| Parameter | Description |
|---|---|
depth (out) | Filled with width*height floats when a frame is returned. |
flipVertical | Whether 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
void setBackgroundColor(const glm::vec4 &c)Set the background clear color using legacy 0..255 RGBA channels.
Parameters
| Parameter | Description |
|---|---|
c | RGBA color where each channel is in [0, 255]. |
Prefer setBackgroundColorRgb255() in new code to make the range explicit.
setBackgroundColorRgb255
void setBackgroundColorRgb255(const glm::vec4 &c)Set the background clear color using 0..255 RGBA channels.
Parameters
| Parameter | Description |
|---|---|
c | RGBA color where each channel is in [0, 255]. |
setBackgroundColorLinear
void setBackgroundColorLinear(const glm::vec4 &c)Set the background clear color using linear 0..1 RGBA channels.
Parameters
| Parameter | Description |
|---|---|
c | Linear RGBA color where each channel is in [0, 1]. |
getBackgroundColor
glm::vec4 getBackgroundColor() constGet the background clear color.
Returns Legacy RGBA color in [0, 255].
getBackgroundColorLinear
glm::vec4 getBackgroundColorLinear() constGet the background clear color in linear 0..1 channels.
Returns Linear RGBA color in [0, 1].
setGamma
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
| Parameter | Description |
|---|---|
g | Gamma value. |
getGamma
float getGamma() constGet gamma correction value.
Returns Gamma value.
setDOFEnabled
void setDOFEnabled(bool e)Enable or disable DoF.
Parameters
| Parameter | Description |
|---|---|
e | True to enable. |
getDOFEnabled
bool getDOFEnabled() constGet DoF enabled state.
Returns True if DoF is enabled.
getDOFFocusDistance
float getDOFFocusDistance() constReturns DoF focus distance in metres.
getDOFFocusRange
float getDOFFocusRange() constReturns Width of the fully sharp band in metres.
getDOFMaxRadius
float getDOFMaxRadius() constReturns Maximum blur (bokeh) radius in pixels.
setDOFParams
void setDOFParams(float focusDist, float focusRange, float maxRadius)Set DoF parameters.
Parameters
| Parameter | Description |
|---|---|
focusDist | Focus distance in metres. |
focusRange | Width of the fully sharp band centred on the focus distance, in metres. |
maxRadius | Max blur (bokeh) radius in pixels. |
setDebugShowPick
void setDebugShowPick(bool e)Toggle rendering of the pick buffer for debugging.
Parameters
| Parameter | Description |
|---|---|
e | True to show pick buffer. |
isDebugShowingPick
bool isDebugShowingPick() constCheck if the pick buffer is shown for debugging.
Returns True if pick buffer is displayed.
Static member functions
unbindFbo static
static void unbindFbo()Unbind any framebuffer (bind default).
Public attributes
position
glm::vec3 positionCamera 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
glm::vec3 frontUnit view direction (world).
target
glm::vec3 targetFixed orbit/look-at point, used while setCameraFixedTarget(true).
up
glm::vec3 upCamera up vector (world), orthogonal to front.
right
glm::vec3 rightCamera right vector (world).
worldUp
glm::vec3 worldUpWorld up reference used to build right and for Space-key motion.
yaw
float yawYaw in degrees, measured about +Z from +X.
pitch
float pitchDegrees.
Pitch in degrees above the XY plane (clamped to +-89 by mouseDelta()).
movementSpeed
float movementSpeedKeyboard movement speed in m/s (default 5).
zoom
float zoomVertical field of view in degrees used by the perspective projection (default 45).
aspect
float aspectHorizontal / vertical.
horizontalFovRad
float horizontalFovRadRadians (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
float nearPlaneNear clip distance in metres (see getProjectionClipRange()).
farPlane
float farPlaneMetres.
Far clip distance in metres (see getProjectionClipRange()).
orthoScale
float orthoScaleMetres of vertical view extent in ortho mode.
zNear
float zNearLegacy near clip in metres; the smaller of this and nearPlane is used.
zFar
float zFarMetres. Legacy aliases — prefer nearPlane/farPlane.
Legacy far clip in metres; the larger of this and farPlane is used.
targetObject
raisim::Object *targetObjectCurrent target raisim object (if any); an identity key, never dereferenced.