moreupdates
[synfig.git] / synfig-core / trunk / src / modules / mod_particle / plant.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file plant.h
3 **      \brief Template Header
4 **
5 **      $Id: plant.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SYNFIG_PLANT_H
25 #define __SYNFIG_PLANT_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <list>
30 #include <vector>
31 #include <synfig/layer_composite.h>
32 #include <synfig/segment.h>
33 #include <synfig/blinepoint.h>
34 #include <synfig/value.h>
35 #include <synfig/gradient.h>
36 #include <synfig/angle.h>
37 #include "random.h"
38 #include <synfig/rect.h>
39
40 /* === M A C R O S ========================================================= */
41
42 /* === T Y P E D E F S ===================================================== */
43
44 /* === C L A S S E S & S T R U C T S ======================================= */
45
46 using namespace synfig;
47 using namespace std;
48 using namespace etl;
49
50 class Plant : public synfig::Layer_Composite
51 {
52         SYNFIG_LAYER_MODULE_EXT
53 private:
54
55         std::vector<synfig::BLinePoint> bline;
56         bool bline_loop;
57
58         synfig::Gradient gradient;
59
60         struct Particle
61         {
62                 synfig::Point point;
63                 synfig::Color color;
64                 
65                 Particle(const synfig::Point &point,const synfig::Color& color):
66                         point(point),color(color) { }
67         };
68
69         mutable std::vector<Particle> particle_list;
70         mutable synfig::Rect    bounding_rect;
71         synfig::Angle split_angle;
72         synfig::Vector gravity;
73         synfig::Real velocity;
74         synfig::Real step;
75         synfig::Real mass;
76         synfig::Real drag;
77         synfig::Real size;
78         int splits;
79         int sprouts;
80         synfig::Real random_factor;
81         Random random;
82         
83         bool size_as_alpha;
84         mutable bool needs_sync_;
85         
86
87         void branch(int n, int depth,float t, float stunt_growth, synfig::Point position,synfig::Vector velocity)const;
88
89 public:
90
91         Plant();
92
93         void sync()const;
94
95         void calc_bounding_rect()const;
96
97         virtual bool set_param(const String & param, const synfig::ValueBase &value);
98
99         virtual ValueBase get_param(const String & param)const;
100
101         virtual Vocab get_param_vocab()const;
102
103         virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const;\
104
105         virtual synfig::Rect get_bounding_rect(synfig::Context context)const;
106 };
107
108 /* === E N D =============================================================== */
109
110 #endif