33e072927fd1850780202d23938a25df5dceb125
[oweals/minetest.git] / src / mesh.h
1 /*
2 Minetest-c55
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
25 /*
26         Create a new cube mesh.
27         Vertices are at (+-scale.X/2, +-scale.Y/2, +-scale.Z/2).
28
29         The resulting mesh has 6 materials (up, down, right, left, back, front)
30         which must be defined by the caller.
31 */
32 scene::IAnimatedMesh* createCubeMesh(v3f scale);
33
34 /*
35         Create a new extruded mesh from a texture.
36         Maximum bounding box is (+-scale.X/2, +-scale.Y/2, +-scale.Z).
37         Thickness is in Z direction.
38
39         The resulting mesh has 1 material which must be defined by the caller.
40 */
41 scene::IAnimatedMesh* createExtrudedMesh(video::ITexture *texture,
42                 video::IVideoDriver *driver, v3f scale);
43
44 /*
45         Multiplies each vertex coordinate by the specified scaling factors
46         (componentwise vector multiplication).
47 */
48 void scaleMesh(scene::IMesh *mesh, v3f scale);
49
50 /*
51         Set a constant color for all vertices in the mesh
52 */
53 void setMeshColor(scene::IMesh *mesh, const video::SColor &color);
54
55 /*
56         Set the color of all vertices in the mesh.
57         For each vertex, determine the largest absolute entry in
58         the normal vector, and choose one of colorX, colorY or
59         colorZ accordingly.
60 */
61 void setMeshColorByNormalXYZ(scene::IMesh *mesh,
62                 const video::SColor &colorX,
63                 const video::SColor &colorY,
64                 const video::SColor &colorZ);
65
66 #endif