Luanti 5.16.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
8
9namespace scene {
10 class IAnimatedMesh;
11 class IMesh;
12 class IMeshBuffer;
13 struct SMesh;
14}
15
16namespace video {
17 class SMaterialLayer;
18 class SColor;
19}
20
21
26void applyFacesShading(video::SColor &color, v3f normal);
27
28/*
29 Create a new cube mesh.
30 Vertices are at (+-scale.X/2, +-scale.Y/2, +-scale.Z/2).
31
32 The resulting mesh has 6 materials (up, down, right, left, back, front)
33 which must be defined by the caller.
34*/
35scene::IAnimatedMesh* createCubeMesh(v3f scale);
36
37/*
38 Multiplies each vertex coordinate by the specified scaling factors
39 (componentwise vector multiplication).
40*/
41void scaleMesh(scene::IMesh *mesh, v3f scale);
42
43/*
44 Translate each vertex coordinate by the specified vector.
45*/
46void translateMesh(scene::IMesh *mesh, v3f vec);
47
51void setMeshBufferColor(scene::IMeshBuffer *buf, video::SColor color);
52
53/*
54 Set a constant color for all vertices in the mesh
55*/
56void setMeshColor(scene::IMesh *mesh, video::SColor color);
57
63void colorizeMeshBuffer(scene::IMeshBuffer *buf, video::SColor buf_color,
64 f32 ambient_light, v3f dir_light);
65
66/*
67 Set the color of all vertices in the mesh.
68 For each vertex, determine the largest absolute entry in
69 the normal vector, and choose one of colorX, colorY or
70 colorZ accordingly.
71*/
72void setMeshColorByNormalXYZ(scene::IMesh *mesh,
73 video::SColor colorX, video::SColor colorY, video::SColor colorZ);
74
75void setMeshColorByNormal(scene::IMesh *mesh, v3f normal, video::SColor color);
76
77/*
78 Rotate the mesh by 6d facedir value.
79 Method only for meshnodes, not suitable for entities.
80*/
81void rotateMeshBy6dFacedir(scene::IMesh *mesh, u8 facedir);
82
83/*
84 Rotate the mesh around the axis and given angle in degrees.
85*/
86void rotateMeshXYby (scene::IMesh *mesh, f64 degrees);
87void rotateMeshXZby (scene::IMesh *mesh, f64 degrees);
88void rotateMeshYZby (scene::IMesh *mesh, f64 degrees);
89
90/*
91 * Clone the mesh buffer.
92 * The returned pointer should be dropped.
93 */
94scene::IMeshBuffer* cloneMeshBuffer(scene::IMeshBuffer *mesh_buffer);
95
97scene::SMesh* cloneStaticMesh(scene::IMesh *src_mesh);
98
99/*
100 Convert nodeboxes to mesh. Each tile goes into a different buffer.
101 boxes - set of nodeboxes to be converted into cuboids
102 uv_coords[24] - table of texture uv coords for each cuboid face
103 expand - factor by which cuboids will be resized
104*/
105scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
106 const f32 *uv_coords = nullptr, f32 expand = 0);
107
108/*
109 Update bounding box for a mesh.
110*/
111void recalculateBoundingBox(scene::IMesh *src_mesh);
112
113/*
114 Check if mesh has valid normals and return true if it does.
115 We assume normal to be valid when it's 0 < length < Inf. and not NaN
116 */
117bool checkMeshNormals(scene::IMesh *mesh);
118
119/*
120 Set the MinFilter, MagFilter and AnisotropicFilter properties of a texture
121 layer according to the three relevant boolean values found in the Minetest
122 settings.
123*/
124void 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