00001
00022
00023
00024
00025
00026 #ifndef __SYNFIG_PLANT_H
00027 #define __SYNFIG_PLANT_H
00028
00029
00030
00031 #include <list>
00032 #include <vector>
00033 #include <synfig/layer_composite.h>
00034 #include <synfig/segment.h>
00035 #include <synfig/blinepoint.h>
00036 #include <synfig/value.h>
00037 #include <synfig/gradient.h>
00038 #include <synfig/angle.h>
00039 #include "random.h"
00040 #include <synfig/rect.h>
00041
00042
00043
00044
00045
00046
00047
00048 using namespace synfig;
00049 using namespace std;
00050 using namespace etl;
00051
00052 class Plant : public synfig::Layer_Composite
00053 {
00054 SYNFIG_LAYER_MODULE_EXT
00055 private:
00056
00057 std::vector<synfig::BLinePoint> bline;
00058 bool bline_loop;
00059
00060 Point origin;
00061
00062 synfig::Gradient gradient;
00063
00064 struct Particle
00065 {
00066 synfig::Point point;
00067 synfig::Color color;
00068
00069 Particle(const synfig::Point &point,const synfig::Color& color):
00070 point(point),color(color) { }
00071 };
00072
00073 mutable std::vector<Particle> particle_list;
00074 mutable synfig::Rect bounding_rect;
00075 synfig::Angle split_angle;
00076 synfig::Vector gravity;
00077 synfig::Real velocity;
00078 synfig::Real perp_velocity;
00079 synfig::Real step;
00080 synfig::Real mass;
00081 synfig::Real drag;
00082 synfig::Real size;
00083 int splits;
00084 int sprouts;
00085 synfig::Real random_factor;
00086 Random random;
00087
00088 bool size_as_alpha;
00089 bool reverse;
00090 mutable bool needs_sync_;
00091 mutable synfig::Mutex mutex;
00092
00093 void branch(int n, int depth,float t, float stunt_growth, synfig::Point position,synfig::Vector velocity)const;
00094 void sync()const;
00095 String version;
00096 bool use_width;
00097
00098 public:
00099
00100 Plant();
00101
00102 void calc_bounding_rect()const;
00103
00104 virtual bool set_param(const String & param, const synfig::ValueBase &value);
00105
00106 virtual ValueBase get_param(const String & param)const;
00107
00108 virtual bool set_version(const synfig::String &ver);
00109
00110 virtual Vocab get_param_vocab()const;
00111
00112 virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const;\
00113
00114 virtual synfig::Rect get_bounding_rect(synfig::Context context)const;
00115 };
00116
00117
00118
00119 #endif