]> git.lizzy.rs Git - minetest-m13.git/blob - src/mesh.h
f7844ac2fef02a67b25c2afa0fe430cc40f5bf59
[minetest-m13.git] / src / mesh.h
1 /*
2 Minetest-m13
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MESH_HEADER
21 #define MESH_HEADER
22
23 #include "common_irrlicht.h"
24 #include <string>
25
26 /*
27         Create a new cube mesh.
28         Vertices are at (+-scale.X/2, +-scale.Y/2, +-scale.Z/2).
29
30         The resulting mesh has 6 materials (up, down, right, left, back, front)
31         which must be defined by the caller.
32 */
33 scene::IAnimatedMesh* createCubeMesh(v3f scale);
34
35 /*
36         Create a new extruded mesh from a texture.
37         Maximum bounding box is (+-scale.X/2, +-scale.Y/2, +-scale.Z).
38         Thickness is in Z direction.
39
40         The resulting mesh has 1 material which must be defined by the caller.
41 */
42 scene::IAnimatedMesh* createExtrudedMesh(video::ITexture *texture,
43                 video::IVideoDriver *driver, v3f scale);
44
45 /*
46         Multiplies each vertex coordinate by the specified scaling factors
47         (componentwise vector multiplication).
48 */
49 void scaleMesh(scene::IMesh *mesh, v3f scale);
50
51 /*
52         Translate each vertex coordinate by the specified vector.
53 */
54 void translateMesh(scene::IMesh *mesh, v3f vec);
55
56 /*
57         Set a constant color for all vertices in the mesh
58 */
59 void setMeshColor(scene::IMesh *mesh, const video::SColor &color);
60
61 /*
62         Set the color of all vertices in the mesh.
63         For each vertex, determine the largest absolute entry in
64         the normal vector, and choose one of colorX, colorY or
65         colorZ accordingly.
66 */
67 void setMeshColorByNormalXYZ(scene::IMesh *mesh,
68                 const video::SColor &colorX,
69                 const video::SColor &colorY,
70                 const video::SColor &colorZ);
71
72 /*
73         Render a mesh to a texture.
74         Returns NULL if render-to-texture failed.
75 */
76 video::ITexture *generateTextureFromMesh(scene::IMesh *mesh,
77                 IrrlichtDevice *device,
78                 core::dimension2d<u32> dim,
79                 std::string texture_name,
80                 v3f camera_position,
81                 v3f camera_lookat,
82                 core::CMatrix4<f32> camera_projection_matrix,
83                 video::SColorf ambient_light,
84                 v3f light_position,
85                 video::SColorf light_color,
86                 f32 light_radius);
87
88 #endif