scimesh 0.3.4
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
scimesh::ClipPlane Struct Reference

A clipping plane that can hide parts of the scene. More...

#include <types.h>

Public Attributes

Vec3 normal = Vec3(0.0f, 0.0f, -1.0f)
 The plane normal vector.
 
float offset = 0.0f
 Signed distance of the plane from the origin along normal.
 
PlaneSpace space = PlaneSpace::WORLD
 The space ClipPlane::normal and ClipPlane::offset refer to.
 

Detailed Description

A clipping plane that can hide parts of the scene.

Geometry on the "negative" side of the plane is discarded, i.e. a point p is kept when dot(p, normal) + offset >= 0. Which space p lives in is selected by ClipPlane::space:

  • PlaneSpace::WORLD (default): p is the world-space position, so the plane is a fixed feature of the scene. Cutting the midsagittal plane of a brain mesh (normal = (-1,0,0), offset = 0) keeps cutting the same place while the camera orbits.
  • PlaneSpace::EYE: p is the view-space (eye-space) position, i.e. p = view * p_world. The plane moves with the camera.

The normal is normalized internally, and offset is always a signed distance in world units along the (normalized) normal — scaling the normal does not change the plane. A zero-length normal neutralizes the plane (it clips nothing) instead of discarding the whole scene.

Clip planes are useful for cross-section views (e.g., slicing through a brain mesh to show internal structures). Multiple planes are combined with a logical AND: only geometry kept by all planes is rendered.

Example: world-space cross-section (default)
// Keep the half of the scene with world x <= 0. The cut stays at
// x = 0 no matter where the camera is placed.
opts.clip_planes.push_back(ClipPlane{Vec3(-1, 0, 0), 0.0f});
glm::vec3 Vec3
3-component floating-point vector (xyz).
Definition types.h:46
A clipping plane that can hide parts of the scene.
Definition types.h:263
All settings that control rendering output.
std::vector< ClipPlane > clip_planes
Optional clip planes for cross-section views.
int x
Left edge of the bitmap, in image pixels.
Definition text.cpp:223
Example: eye-space (camera-attached) cutaway
// Keep only geometry at least 2 world units in front of the camera,
// so the camera always "sees inside" the scene.
opts.clip_planes.push_back(
ClipPlane{Vec3(0, 0, -1), -2.0f, PlaneSpace::EYE});
@ EYE
Eye (view/camera) space: the plane is anchored to the camera and therefore travels and rotates with i...
See also
RenderOptions, RenderOptions::clip_planes, PlaneSpace, clip_plane_to_view_space()

Definition at line 263 of file types.h.

Member Data Documentation

◆ normal

Vec3 scimesh::ClipPlane::normal = Vec3(0.0f, 0.0f, -1.0f)

The plane normal vector.

Points toward the "keep" side of the plane. It does not have to be unit-length: it is normalized internally, and ClipPlane::offset is always interpreted as a distance in world units.

Default: (0, 0, -1).

Definition at line 271 of file types.h.

◆ offset

float scimesh::ClipPlane::offset = 0.0f

Signed distance of the plane from the origin along normal.

A point p is kept when dot(p, normal) + offset >= 0 in the space given by ClipPlane::space, so offset = -d puts the plane at distance d from the origin when the normal is unit-length.

Default: 0 (the plane passes through the origin).

Definition at line 280 of file types.h.

◆ space

PlaneSpace scimesh::ClipPlane::space = PlaneSpace::WORLD

The space ClipPlane::normal and ClipPlane::offset refer to.

Default: PlaneSpace::WORLD.

See also
PlaneSpace

Definition at line 286 of file types.h.


The documentation for this struct was generated from the following file: