3#include <glm/gtc/matrix_transform.hpp>
8 Mat4 m = glm::translate(
Mat4(1.0f), translation);
15 Mat4 m = glm::scale(
Mat4(1.0f), scale);
26 Mat4 m = glm::rotate(
Mat4(1.0f), angle_radians, axis);
39 const std::vector<uint32_t> &fs_faces,
40 const std::vector<float> &per_vertex_values,
41 const std::vector<uint8_t> &rgb_bytes,
42 bool detect_transparency) {
44 size_t nv = fs_vertices.size() / 3;
47 bool have_values = !per_vertex_values.empty();
48 bool have_rgb = !rgb_bytes.empty();
50 for (
size_t i = 0; i < nv; i++) {
53 fs_vertices[i * 3 + 1],
54 fs_vertices[i * 3 + 2]));
56 if (have_values && std::isnan(per_vertex_values[i])) {
57 out.
colors.push_back(
Color(1.0f, 1.0f, 1.0f, 1.0f));
58 }
else if (have_rgb) {
60 rgb_bytes[i * 3] / 255.0f,
61 rgb_bytes[i * 3 + 1] / 255.0f,
62 rgb_bytes[i * 3 + 2] / 255.0f,
67 size_t nf = fs_faces.size() / 3;
69 for (
size_t i = 0; i < nf; i++) {
73 fs_faces[i * 3 + 2]});
77 for (
const auto &c : out.
colors) {
78 if (c.a < 1.0f - 1e-6f) {
Low-level math utilities for the rendering pipeline.
glm::mat4 Mat4
4×4 floating-point matrix.
glm::vec3 Vec3
3-component floating-point vector (xyz).
Vec3 transform_point(const Mat4 &m, const Vec3 &p)
Transform a point by a 4×4 matrix (with implicit w=1).
void scale_mesh(Mesh &mesh, const Vec3 &scale)
Scale a mesh non-uniformly along each axis.
void rotate_mesh(Mesh &mesh, float angle_radians, const Vec3 &axis)
Rotate a mesh around an arbitrary axis.
Mesh mesh_from_fs(const std::vector< float > &fs_vertices, const std::vector< uint32_t > &fs_faces, const std::vector< float > &per_vertex_values, const std::vector< uint8_t > &rgb_bytes, bool detect_transparency)
Convert a FreeSurfer-format mesh (flat vertex/face arrays) to a scimesh Mesh.
void transform_mesh(Mesh &mesh, const Mat4 &matrix)
Apply an arbitrary 4×4 transformation matrix to a mesh.
void translate_mesh(Mesh &mesh, const Vec3 &translation)
Translate (move) a mesh by a displacement vector.
An RGBA color with floating-point components.
A 3D triangle mesh using an indexed face set representation.
bool has_transparency
Whether the mesh contains any transparent fragments.
std::vector< Color > colors
Per-vertex RGBA colors.
bool has_colors() const
Does the mesh have per-vertex colors?
std::vector< Vec3 > vertices
3D vertex positions.
std::vector< Triangle > triangles
Triangle index triplets.
A triangle defined by three vertex indices.