00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PARTBUNDLE_H
00020 #define PARTBUNDLE_H
00021
00022 #include "pandabase.h"
00023
00024 #include "partGroup.h"
00025 #include "animControl.h"
00026 #include "animControlCollection.h"
00027
00028 #include "pointerTo.h"
00029 #include "iterator_types.h"
00030
00031 class AnimBundle;
00032 class PartBundleNode;
00033 class PartBundleNode;
00034
00035
00036
00037
00038
00039
00040
00041 class EXPCL_PANDA PartBundle : public PartGroup, public AnimControlCollection {
00042 public:
00043
00044
00045
00046 typedef pmap<AnimControl *, float> ChannelBlend;
00047
00048 typedef first_of_pair_iterator<ChannelBlend::const_iterator> control_iterator;
00049 typedef ChannelBlend::size_type control_size_type;
00050
00051 protected:
00052
00053 PartBundle(const PartBundle ©);
00054
00055 public:
00056 PartBundle(const string &name = "");
00057 virtual PartGroup *make_copy() const;
00058
00059 PUBLISHED:
00060
00061
00062
00063
00064 enum BlendType {
00065
00066
00067
00068
00069
00070
00071
00072
00073 BT_single,
00074
00075
00076
00077
00078
00079
00080
00081
00082 BT_linear,
00083
00084
00085
00086
00087
00088
00089
00090
00091 BT_normalized_linear,
00092 };
00093
00094 void set_blend_type(BlendType bt);
00095 INLINE BlendType get_blend_type() const;
00096
00097 INLINE PartBundleNode *get_node() const;
00098
00099 void clear_control_effects();
00100 void set_control_effect(AnimControl *control, float effect);
00101 float get_control_effect(AnimControl *control);
00102
00103 virtual void output(ostream &out) const;
00104 virtual void write(ostream &out, int indent_level) const;
00105
00106 PT(AnimControl) bind_anim(AnimBundle *anim,
00107 int hierarchy_match_flags = 0);
00108
00109 bool bind_anim(AnimBundle *anim, const string &name,
00110 int hierarchy_match_flags = 0);
00111
00112 public:
00113
00114
00115
00116 INLINE control_iterator control_begin() const;
00117 INLINE control_iterator control_end() const;
00118 INLINE control_size_type control_size() const;
00119
00120 INLINE const ChannelBlend &get_blend_map() const;
00121
00122
00123
00124
00125
00126 void advance_time(double time);
00127 bool update();
00128 bool force_update();
00129 virtual void control_activated(AnimControl *control);
00130
00131 protected:
00132 void recompute_net_blend();
00133 void clear_and_stop_except(AnimControl *control);
00134
00135 BlendType _blend_type;
00136 PartBundleNode *_node;
00137
00138 AnimControl *_last_control_set;
00139 ChannelBlend _blend;
00140 float _net_blend;
00141 bool _anim_changed;
00142
00143 public:
00144 static void register_with_read_factory(void);
00145 virtual void finalize();
00146
00147 static TypedWritable *make_PartBundle(const FactoryParams ¶ms);
00148
00149 public:
00150
00151 virtual TypeHandle get_type() const {
00152 return get_class_type();
00153 }
00154 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00155 static TypeHandle get_class_type() {
00156 return _type_handle;
00157 }
00158 static void init_type() {
00159 PartGroup::init_type();
00160 register_type(_type_handle, "PartBundle",
00161 PartGroup::get_class_type());
00162 }
00163
00164 private:
00165 static TypeHandle _type_handle;
00166
00167 friend class PartBundleNode;
00168 };
00169
00170 inline ostream &operator <<(ostream &out, const PartBundle &bundle) {
00171 bundle.output(out);
00172 return out;
00173 }
00174
00175 #include "partBundle.I"
00176
00177 #endif