Luanti 5.18.0-dev
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <vector>
9
10namespace scene {
11 class IAnimatedMesh;
12 class IMesh;
13 class IMeshBuffer;
14 struct SMesh;
15}
16
17namespace video {
18 class SMaterialLayer;
19 class SColor;
20}
21
22
27void applyFacesShading(video::SColor &color, v3f normal);
28
29/*
30 Create a new cube mesh.
31 Vertices are at (+-scale.X/2, +-scale.Y/2, +-scale.Z/2).
32
33 The resulting mesh has 6 materials (up, down, right, left, back, front)
34 which must be defined by the caller.
35*/
36scene::IAnimatedMesh* createCubeMesh(v3f scale);
37
38/*
39 Multiplies each vertex coordinate by the specified scaling factors
40 (componentwise vector multiplication).
41*/
42void scaleMesh(scene::IMesh *mesh, v3f scale);
43
44/*
45 Translate each vertex coordinate by the specified vector.
46*/
47void translateMesh(scene::IMesh *mesh, v3f vec);
48
52void setMeshBufferColor(scene::IMeshBuffer *buf, video::SColor color);
53
54/*
55 Set a constant color for all vertices in the mesh
56*/
57void setMeshColor(scene::IMesh *mesh, video::SColor color);
58
64void colorizeMeshBuffer(scene::IMeshBuffer *buf, video::SColor buf_color,
65 f32 ambient_light, v3f dir_light);
66
67/*
68 Set the color of all vertices in the mesh.
69 For each vertex, determine the largest absolute entry in
70 the normal vector, and choose one of colorX, colorY or
71 colorZ accordingly.
72*/
73void setMeshColorByNormalXYZ(scene::IMesh *mesh,
74 video::SColor colorX, video::SColor colorY, video::SColor colorZ);
75
76void setMeshColorByNormal(scene::IMesh *mesh, v3f normal, video::SColor color);
77
78/*
79 Rotate the mesh by 6d facedir value.
80 Method only for meshnodes, not suitable for entities.
81*/
82void rotateMeshBy6dFacedir(scene::IMesh *mesh, u8 facedir);
83
84/*
85 Rotate the mesh around the axis and given angle in degrees.
86*/
87void rotateMeshXYby (scene::IMesh *mesh, f64 degrees);
88void rotateMeshXZby (scene::IMesh *mesh, f64 degrees);
89void rotateMeshYZby (scene::IMesh *mesh, f64 degrees);
90
91/*
92 * Clone the mesh buffer.
93 * The returned pointer should be dropped.
94 */
95scene::IMeshBuffer* cloneMeshBuffer(scene::IMeshBuffer *mesh_buffer);
96
98scene::SMesh* cloneStaticMesh(scene::IMesh *src_mesh);
99
100/*
101 Convert nodeboxes to mesh. Each tile goes into a different buffer.
102 boxes - set of nodeboxes to be converted into cuboids
103 uv_coords[24] - table of texture uv coords for each cuboid face
104 expand - factor by which cuboids will be resized
105*/
106scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
107 const f32 *uv_coords = nullptr, f32 expand = 0);
108
109/*
110 Update bounding box for a mesh.
111*/
112void recalculateBoundingBox(scene::IMesh *src_mesh);
113
114/*
115 Check if mesh has valid normals and return true if it does.
116 We assume normal to be valid when it's 0 < length < Inf. and not NaN
117 */
118bool checkMeshNormals(scene::IMesh *mesh);
119
120/*
121 Set the MinFilter, MagFilter and AnisotropicFilter properties of a texture
122 layer according to the three relevant boolean values found in the Minetest
123 settings.
124*/
125void setMaterialFilters(video::SMaterialLayer &tex, bool bilinear, bool trilinear, bool anisotropic);
core::vector3df v3f
Definition irr_v3d.h:11
void setMeshColor(scene::IMesh *mesh, video::SColor color)
Definition mesh.cpp:170
void applyFacesShading(video::SColor &color, v3f normal)
Definition mesh.cpp:23
void setMeshColorByNormal(scene::IMesh *mesh, v3f normal, video::SColor color)
Definition mesh.cpp:222
void rotateMeshXYby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:252
scene::IAnimatedMesh * createCubeMesh(v3f scale)
Definition mesh.cpp:43
scene::IMeshBuffer * cloneMeshBuffer(scene::IMeshBuffer *mesh_buffer)
Definition mesh.cpp:341
void setMaterialFilters(video::SMaterialLayer &tex, bool bilinear, bool trilinear, bool anisotropic)
Definition mesh.cpp:470
void colorizeMeshBuffer(scene::IMeshBuffer *buf, video::SColor buf_color, f32 ambient_light, v3f dir_light)
Definition mesh.cpp:189
void setMeshColorByNormalXYZ(scene::IMesh *mesh, video::SColor colorX, video::SColor colorY, video::SColor colorZ)
Definition mesh.cpp:203
void rotateMeshBy6dFacedir(scene::IMesh *mesh, u8 facedir)
Definition mesh.cpp:267
void translateMesh(scene::IMesh *mesh, v3f vec)
Definition mesh.cpp:139
void rotateMeshXZby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:257
void rotateMeshYZby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:262
void setMeshBufferColor(scene::IMeshBuffer *buf, video::SColor color)
Definition mesh.cpp:163
bool checkMeshNormals(scene::IMesh *mesh)
Definition mesh.cpp:299
void recalculateBoundingBox(scene::IMesh *src_mesh)
Definition mesh.cpp:285
scene::IMesh * convertNodeboxesToMesh(const std::vector< aabb3f > &boxes, const f32 *uv_coords=nullptr, f32 expand=0)
Definition mesh.cpp:368
void scaleMesh(scene::IMesh *mesh, v3f scale)
Definition mesh.cpp:115
scene::SMesh * cloneStaticMesh(scene::IMesh *src_mesh)
Clone a mesh. For an animated mesh, this will clone the static pose.
Definition mesh.cpp:355
Definition camera.h:24
Definition clientmap.h:36