Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_06 / src / modules / mod_particle / plant.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file plant.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_PLANT_H
26 #define __SYNFIG_PLANT_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <list>
31 #include <vector>
32 #include <synfig/layer_composite.h>
33 #include <synfig/segment.h>
34 #include <synfig/blinepoint.h>
35 #include <synfig/value.h>
36 #include <synfig/gradient.h>
37 #include <synfig/angle.h>
38 #include "random.h"
39 #include <synfig/rect.h>
40
41 /* === M A C R O S ========================================================= */
42
43 /* === T Y P E D E F S ===================================================== */
44
45 /* === C L A S S E S & S T R U C T S ======================================= */
46
47 using namespace synfig;
48 using namespace std;
49 using namespace etl;
50
51 class Plant : public synfig::Layer_Composite
52 {
53         SYNFIG_LAYER_MODULE_EXT
54 private:
55
56         std::vector<synfig::BLinePoint> bline;
57         bool bline_loop;
58
59         synfig::Gradient gradient;
60
61         struct Particle
62         {
63                 synfig::Point point;
64                 synfig::Color color;
65
66                 Particle(const synfig::Point &point,const synfig::Color& color):
67                         point(point),color(color) { }
68         };
69
70         mutable std::vector<Particle> particle_list;
71         mutable synfig::Rect    bounding_rect;
72         synfig::Angle split_angle;
73         synfig::Vector gravity;
74         synfig::Real velocity;
75         synfig::Real step;
76         synfig::Real mass;
77         synfig::Real drag;
78         synfig::Real size;
79         int splits;
80         int sprouts;
81         synfig::Real random_factor;
82         Random random;
83
84         bool size_as_alpha;
85         mutable bool needs_sync_;
86
87
88         void branch(int n, int depth,float t, float stunt_growth, synfig::Point position,synfig::Vector velocity)const;
89
90 public:
91
92         Plant();
93
94         void sync()const;
95
96         void calc_bounding_rect()const;
97
98         virtual bool set_param(const String & param, const synfig::ValueBase &value);
99
100         virtual ValueBase get_param(const String & param)const;
101
102         virtual Vocab get_param_vocab()const;
103
104         virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const;\
105
106         virtual synfig::Rect get_bounding_rect(synfig::Context context)const;
107 };
108
109 /* === E N D =============================================================== */
110
111 #endif