62a220ee2e706087de701c5d753ae00a8e32c685
[oweals/minetest.git] / src / treegen.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>,
4                                    2012 RealBadAngel, Maciej Kasatkin <mk@realbadangel.pl>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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 TREEGEN_HEADER
21 #define TREEGEN_HEADER
22
23 #include <matrix4.h>
24
25 class ManualMapVoxelManipulator;
26 class INodeDefManager;
27
28
29 namespace treegen
30 {
31
32 struct TreeDef
33 {
34 std::string initial_axiom;
35 std::string rules_a;
36 std::string rules_b;
37 std::string rules_c;
38 std::string rules_d;
39 MapNode trunknode;
40 MapNode leavesnode;
41 int angle;
42 int iterations;
43 int iterations_random_level;
44 bool thin_trunks;
45 bool fruit_tree;
46 MapNode fruitnode;
47 };
48
49         // Add default tree
50         void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
51                         bool is_apple_tree, INodeDefManager *ndef);
52         
53         // Add L-Systems tree (used by engine)
54         void make_ltree(ManualMapVoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef,
55                 TreeDef tree_definition);
56         // Spawn L-systems tree from LUA
57         void spawn_ltree (ServerEnvironment *env, v3s16 p0, INodeDefManager *ndef, TreeDef tree_definition);    
58         
59         // L-System tree gen helper functions
60         void make_tree_node_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
61                 MapNode node);
62         void make_tree_trunk_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
63                 TreeDef &tree_definition);
64         void make_tree_leaves_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
65                 TreeDef &tree_definition);      
66         irr::core::matrix4 setRotationAxisRadians(irr::core::matrix4 M, double angle,v3f axis);
67         
68         v3f transposeMatrix(irr::core::matrix4 M ,v3f v);
69                         
70 }; // namespace treegen
71 #endif