Luanti 5.15.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, const 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, const video::SColor color);
52
53/*
54 Set a constant color for all vertices in the mesh
55*/
56void setMeshColor(scene::IMesh *mesh, const video::SColor color);
57
62void colorizeMeshBuffer(scene::IMeshBuffer *buf, const video::SColor *buffercolor);
63
64/*
65 Set the color of all vertices in the mesh.
66 For each vertex, determine the largest absolute entry in
67 the normal vector, and choose one of colorX, colorY or
68 colorZ accordingly.
69*/
70void setMeshColorByNormalXYZ(scene::IMesh *mesh,
71 const video::SColor &colorX,
72 const video::SColor &colorY,
73 const video::SColor &colorZ);
74
75void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal,
76 const 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 = NULL, float 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 colorizeMeshBuffer(scene::IMeshBuffer *buf, const video::SColor *buffercolor)
Definition mesh.cpp:197
void rotateMeshXYby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:265
scene::IAnimatedMesh * createCubeMesh(v3f scale)
Definition mesh.cpp:43
scene::IMeshBuffer * cloneMeshBuffer(scene::IMeshBuffer *mesh_buffer)
Definition mesh.cpp:353
void setMaterialFilters(video::SMaterialLayer &tex, bool bilinear, bool trilinear, bool anisotropic)
Definition mesh.cpp:482
void applyFacesShading(video::SColor &color, const v3f normal)
Definition mesh.cpp:23
void rotateMeshBy6dFacedir(scene::IMesh *mesh, u8 facedir)
Definition mesh.cpp:280
void translateMesh(scene::IMesh *mesh, v3f vec)
Definition mesh.cpp:139
void rotateMeshXZby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:270
void setMeshColor(scene::IMesh *mesh, const video::SColor color)
Definition mesh.cpp:172
void rotateMeshYZby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:275
void setMeshColorByNormalXYZ(scene::IMesh *mesh, const video::SColor &colorX, const video::SColor &colorY, const video::SColor &colorZ)
Definition mesh.cpp:213
bool checkMeshNormals(scene::IMesh *mesh)
Definition mesh.cpp:312
void recalculateBoundingBox(scene::IMesh *src_mesh)
Definition mesh.cpp:298
scene::IMesh * convertNodeboxesToMesh(const std::vector< aabb3f > &boxes, const f32 *uv_coords=NULL, float expand=0)
Definition mesh.cpp:380
void scaleMesh(scene::IMesh *mesh, v3f scale)
Definition mesh.cpp:116
void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal, const video::SColor &color)
Definition mesh.cpp:234
void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor color)
Definition mesh.cpp:162
scene::SMesh * cloneStaticMesh(scene::IMesh *src_mesh)
Clone a mesh. For an animated mesh, this will clone the static pose.
Definition mesh.cpp:367
Definition camera.h:24
Definition clientmap.h:36