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