scimesh 0.3.2
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <glm/vec2.hpp>
15#include <glm/vec3.hpp>
16#include <glm/vec4.hpp>
17#include <glm/mat4x4.hpp>
18#include <vector>
19#include <cstdint>
20#include <string>
21
22namespace scimesh {
23
24// ---------------------------------------------------------------------------
25// Vector & matrix type aliases (GLM)
26// ---------------------------------------------------------------------------
27
32using Vec2 = glm::vec2;
33
46using Vec3 = glm::vec3;
47
52using Vec4 = glm::vec4;
53
65using Mat4 = glm::mat4;
66
67// ---------------------------------------------------------------------------
68// Color
69// ---------------------------------------------------------------------------
70
88struct Color {
89 float r = 0.0f;
90 float g = 0.0f;
91 float b = 0.0f;
92 float a = 1.0f;
93
94 constexpr Color() = default;
95
101 constexpr Color(float r_, float g_, float b_, float a_ = 1.0f)
102 : r(r_), g(g_), b(b_), a(a_) {}
103};
104
105// ---------------------------------------------------------------------------
106// Triangle
107// ---------------------------------------------------------------------------
108
127struct Triangle {
129 uint32_t v0 = 0;
131 uint32_t v1 = 0;
133 uint32_t v2 = 0;
134};
135
136// ---------------------------------------------------------------------------
137// Named color constants
138// ---------------------------------------------------------------------------
139
144constexpr Color DEFAULT_COLOR{0.7f, 0.7f, 0.7f, 1.0f};
145
150constexpr Color TRANSPARENT_BLACK{0.0f, 0.0f, 0.0f, 0.0f};
151
156constexpr Color WHITE{1.0f, 1.0f, 1.0f, 1.0f};
157
158// ---------------------------------------------------------------------------
159// Light
160// ---------------------------------------------------------------------------
161
179struct Light {
184 Vec3 position = Vec3(0.0f, 0.0f, 1.0f);
185
189 Color color = Color(1.0f, 1.0f, 1.0f, 1.0f);
190
194 float intensity = 1.0f;
195
200 bool is_directional = true;
201};
202
203// ---------------------------------------------------------------------------
204// ClipPlane
205// ---------------------------------------------------------------------------
206
224struct ClipPlane {
229 Vec3 normal = Vec3(0.0f, 0.0f, -1.0f);
230
234 float offset = 0.0f;
235};
236
237} // namespace scimesh
glm::vec2 Vec2
2-component floating-point vector (xy).
Definition types.h:32
glm::mat4 Mat4
4×4 floating-point matrix.
Definition types.h:65
glm::vec3 Vec3
3-component floating-point vector (xyz).
Definition types.h:46
constexpr Color DEFAULT_COLOR
The default mesh color: a neutral light gray (0.7, 0.7, 0.7).
Definition types.h:144
constexpr Color WHITE
An opaque white color (1, 1, 1, 1).
Definition types.h:156
constexpr Color TRANSPARENT_BLACK
A fully transparent black color (0, 0, 0, 0).
Definition types.h:150
glm::vec4 Vec4
4-component floating-point vector (xyzw).
Definition types.h:52
A clipping plane that can hide parts of the scene.
Definition types.h:224
Vec3 normal
The plane normal vector (should be unit-length).
Definition types.h:229
float offset
Offset along the normal.
Definition types.h:234
An RGBA color with floating-point components.
Definition types.h:88
float g
Green channel, [0, 1].
Definition types.h:90
float r
Red channel, [0, 1].
Definition types.h:89
float b
Blue channel, [0, 1].
Definition types.h:91
constexpr Color()=default
float a
Alpha (opacity) channel, [0, 1]. 1.0 = fully opaque.
Definition types.h:92
constexpr Color(float r_, float g_, float b_, float a_=1.0f)
Construct a Color from RGBA values.
Definition types.h:101
A light source for the Blinn-Phong shading model.
Definition types.h:179
bool is_directional
Whether this is a directional light (default: true).
Definition types.h:200
Color color
Color of the light (default: white).
Definition types.h:189
Vec3 position
Position of the light.
Definition types.h:184
float intensity
Brightness multiplier (default: 1.0).
Definition types.h:194
A triangle defined by three vertex indices.
Definition types.h:127
uint32_t v2
Index of the third vertex in Mesh::vertices.
Definition types.h:133
uint32_t v1
Index of the second vertex in Mesh::vertices.
Definition types.h:131
uint32_t v0
Index of the first vertex in Mesh::vertices.
Definition types.h:129