marked stable
[synfig.git] / synfig-core / tags / stable / src / modules / mod_particle / plant.h
1 /* === S I N F 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 __SINFG_PLANT_H
25 #define __SINFG_PLANT_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <list>
30 #include <vector>
31 #include <sinfg/layer_composite.h>
32 #include <sinfg/segment.h>
33 #include <sinfg/blinepoint.h>
34 #include <sinfg/value.h>
35 #include <sinfg/gradient.h>
36 #include <sinfg/angle.h>
37 #include "random.h"
38 #include <sinfg/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 sinfg;
47 using namespace std;
48 using namespace etl;
49
50 class Plant : public sinfg::Layer_Composite
51 {
52         SINFG_LAYER_MODULE_EXT
53 private:
54
55         std::vector<sinfg::BLinePoint> bline;
56         bool bline_loop;
57
58         sinfg::Gradient gradient;
59
60         struct Particle
61         {
62                 sinfg::Point point;
63                 sinfg::Color color;
64                 
65                 Particle(const sinfg::Point &point,const sinfg::Color& color):
66                         point(point),color(color) { }
67         };
68
69         mutable std::vector<Particle> particle_list;
70         mutable sinfg::Rect     bounding_rect;
71         sinfg::Angle split_angle;
72         sinfg::Vector gravity;
73         sinfg::Real velocity;
74         sinfg::Real step;
75         sinfg::Real mass;
76         sinfg::Real drag;
77         sinfg::Real size;
78         int splits;
79         int sprouts;
80         sinfg::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, sinfg::Point position,sinfg::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 sinfg::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(sinfg::Context context,sinfg::Surface *surface,int quality, const sinfg::RendDesc &renddesc, sinfg::ProgressCallback *cb)const;\
104
105         virtual sinfg::Rect get_bounding_rect(sinfg::Context context)const;
106 };
107
108 /* === E N D =============================================================== */
109
110 #endif