Camera3D
Set up view and projection matrices for 3D visualizations — point clouds, surface meshes, and volumetric data.
API
class Camera3D {
public:
Camera3D();
void lookAt(const Eigen::Vector3f& eye,
const Eigen::Vector3f& target,
const Eigen::Vector3f& up = Eigen::Vector3f::UnitY());
void setPerspective(float fovDegrees, float aspect,
float nearPlane, float farPlane);
auto viewMatrix() const -> Eigen::Matrix4f;
auto projectionMatrix() const -> Eigen::Matrix4f;
auto viewProjectionMatrix() const -> Eigen::Matrix4f;
auto position() const -> const Eigen::Vector3f&;
auto target() const -> const Eigen::Vector3f&;
};
Methods
| Method | Description |
|---|---|
lookAt(eye, target, up) | Position camera at eye, looking at target |
setPerspective(fov, aspect, near, far) | Set perspective projection parameters |
viewMatrix() | Returns the 4×4 view (camera) matrix |
projectionMatrix() | Returns the 4×4 perspective projection matrix |
viewProjectionMatrix() | Returns projection × view |
Default Values
| Parameter | Default |
|---|---|
| Eye position | (0, 0, 5) |
| Target | (0, 0, 0) |
| Up | (0, 1, 0) |
| FOV | 45° |
| Aspect | 1.0 |
| Near | 0.1 |
| Far | 100.0 |
View Matrix
The view matrix transforms world coordinates to camera space using a standard right-handed look-at construction:
where , , .
Example
Skigen::Plot::Camera3D camera;
camera.lookAt({3.f, 3.f, 3.f}, {0.f, 0.f, 0.f});
camera.setPerspective(45.f, 16.f / 9.f, 0.1f, 50.f);
Skigen::Plot::PlotView view;
view.pointCloud(vertices);
view.setCamera(camera);
view.show();