Luanti 5.11.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 "SColor.h"
8#include "SMaterialLayer.h"
9#include "nodedef.h"
10
11namespace irr {
12 namespace scene {
13 class IAnimatedMesh;
14 class IMesh;
15 class IMeshBuffer;
16 }
17}
18
19using namespace irr;
20
25void applyFacesShading(video::SColor &color, const v3f normal);
26
27/*
28 Create a new cube mesh.
29 Vertices are at (+-scale.X/2, +-scale.Y/2, +-scale.Z/2).
30
31 The resulting mesh has 6 materials (up, down, right, left, back, front)
32 which must be defined by the caller.
33*/
34scene::IAnimatedMesh* createCubeMesh(v3f scale);
35
36/*
37 Multiplies each vertex coordinate by the specified scaling factors
38 (componentwise vector multiplication).
39*/
40void scaleMesh(scene::IMesh *mesh, v3f scale);
41
42/*
43 Translate each vertex coordinate by the specified vector.
44*/
45void translateMesh(scene::IMesh *mesh, v3f vec);
46
50void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor color);
51
52/*
53 Set a constant color for all vertices in the mesh
54*/
55void setMeshColor(scene::IMesh *mesh, const video::SColor color);
56
61void colorizeMeshBuffer(scene::IMeshBuffer *buf, const video::SColor *buffercolor);
62
63/*
64 Set the color of all vertices in the mesh.
65 For each vertex, determine the largest absolute entry in
66 the normal vector, and choose one of colorX, colorY or
67 colorZ accordingly.
68*/
69void setMeshColorByNormalXYZ(scene::IMesh *mesh,
70 const video::SColor &colorX,
71 const video::SColor &colorY,
72 const video::SColor &colorZ);
73
74void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal,
75 const 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
96/*
97 Clone the mesh.
98*/
99scene::SMesh* cloneMesh(scene::IMesh *src_mesh);
100
101/*
102 Convert nodeboxes to mesh. Each tile goes into a different buffer.
103 boxes - set of nodeboxes to be converted into cuboids
104 uv_coords[24] - table of texture uv coords for each cuboid face
105 expand - factor by which cuboids will be resized
106*/
107scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
108 const f32 *uv_coords = NULL, float expand = 0);
109
110/*
111 Update bounding box for a mesh.
112*/
113void recalculateBoundingBox(scene::IMesh *src_mesh);
114
115/*
116 Check if mesh has valid normals and return true if it does.
117 We assume normal to be valid when it's 0 < length < Inf. and not NaN
118 */
119bool checkMeshNormals(scene::IMesh *mesh);
120
121/*
122 Set the MinFilter, MagFilter and AnisotropicFilter properties of a texture
123 layer according to the three relevant boolean values found in the Minetest
124 settings.
125*/
126void setMaterialFilters(video::SMaterialLayer &tex, bool bilinear, bool trilinear, bool anisotropic);
core::vector3df v3f
Definition irr_v3d.h:11
scene::SMesh * cloneMesh(scene::IMesh *src_mesh)
Definition mesh.cpp:370
void colorizeMeshBuffer(scene::IMeshBuffer *buf, const video::SColor *buffercolor)
Definition mesh.cpp:196
void rotateMeshXYby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:264
scene::IAnimatedMesh * createCubeMesh(v3f scale)
Definition mesh.cpp:44
scene::IMeshBuffer * cloneMeshBuffer(scene::IMeshBuffer *mesh_buffer)
Definition mesh.cpp:333
void setMaterialFilters(video::SMaterialLayer &tex, bool bilinear, bool trilinear, bool anisotropic)
Definition mesh.cpp:485
void applyFacesShading(video::SColor &color, const v3f normal)
Definition mesh.cpp:24
void rotateMeshBy6dFacedir(scene::IMesh *mesh, u8 facedir)
Definition mesh.cpp:279
void translateMesh(scene::IMesh *mesh, v3f vec)
Definition mesh.cpp:133
void rotateMeshXZby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:269
void setMeshColor(scene::IMesh *mesh, const video::SColor color)
Definition mesh.cpp:171
void rotateMeshYZby(scene::IMesh *mesh, f64 degrees)
Definition mesh.cpp:274
void setMeshColorByNormalXYZ(scene::IMesh *mesh, const video::SColor &colorX, const video::SColor &colorY, const video::SColor &colorZ)
Definition mesh.cpp:212
bool checkMeshNormals(scene::IMesh *mesh)
Definition mesh.cpp:311
void recalculateBoundingBox(scene::IMesh *src_mesh)
Definition mesh.cpp:297
scene::IMesh * convertNodeboxesToMesh(const std::vector< aabb3f > &boxes, const f32 *uv_coords=NULL, float expand=0)
Definition mesh.cpp:383
void scaleMesh(scene::IMesh *mesh, v3f scale)
Definition mesh.cpp:105
void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal, const video::SColor &color)
Definition mesh.cpp:233
void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor color)
Definition mesh.cpp:161
Definition clientmap.h:30