00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ANIMCONTROL_H
00016 #define ANIMCONTROL_H
00017
00018 #include "pandabase.h"
00019
00020 #include "animInterface.h"
00021 #include "animBundle.h"
00022 #include "partGroup.h"
00023 #include "bitArray.h"
00024 #include "pandaNode.h"
00025 #include "typedReferenceCount.h"
00026 #include "namable.h"
00027 #include "pmutex.h"
00028 #include "conditionVarFull.h"
00029
00030 class PartBundle;
00031 class AnimChannelBase;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class EXPCL_PANDA_CHAN AnimControl : public TypedReferenceCount, public AnimInterface, public Namable {
00042 public:
00043 AnimControl(const string &name, PartBundle *part,
00044 double frame_rate, int num_frames);
00045 void setup_anim(PartBundle *part, AnimBundle *anim, int channel_index,
00046 const BitArray &bound_joints);
00047 void set_bound_joints(const BitArray &bound_joints);
00048 void fail_anim(PartBundle *part);
00049
00050 PUBLISHED:
00051 virtual ~AnimControl();
00052
00053 INLINE bool is_pending() const;
00054 void wait_pending();
00055 INLINE bool has_anim() const;
00056 void set_pending_done_event(const string &done_event);
00057 string get_pending_done_event() const;
00058
00059 PartBundle *get_part() const;
00060 INLINE AnimBundle *get_anim() const;
00061 INLINE int get_channel_index() const;
00062 INLINE const BitArray &get_bound_joints() const;
00063
00064 INLINE void set_anim_model(PandaNode *model);
00065 INLINE PandaNode *get_anim_model() const;
00066
00067 virtual void output(ostream &out) const;
00068
00069 public:
00070
00071
00072
00073
00074 bool channel_has_changed(AnimChannelBase *channel, bool frame_blend_flag) const;
00075 void mark_channels(bool frame_blend_flag);
00076
00077 protected:
00078 virtual void animation_activated();
00079
00080 private:
00081 bool _pending;
00082 string _pending_done_event;
00083 Mutex _pending_lock;
00084 ConditionVarFull _pending_cvar;
00085
00086
00087
00088
00089 PT(PartGroup) _part;
00090 PT(AnimBundle) _anim;
00091 int _channel_index;
00092
00093
00094
00095
00096 int _marked_frame;
00097 double _marked_frac;
00098
00099
00100
00101
00102 BitArray _bound_joints;
00103
00104 PT(PandaNode) _anim_model;
00105
00106 public:
00107 virtual TypeHandle get_type() const {
00108 return get_class_type();
00109 }
00110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00111
00112 static TypeHandle get_class_type() {
00113 return _type_handle;
00114 }
00115 static void init_type() {
00116 TypedReferenceCount::init_type();
00117 AnimInterface::init_type();
00118 register_type(_type_handle, "AnimControl",
00119 TypedReferenceCount::get_class_type(),
00120 AnimInterface::get_class_type());
00121 }
00122
00123 private:
00124 static TypeHandle _type_handle;
00125 };
00126
00127 INLINE ostream &operator << (ostream &out, const AnimControl &control);
00128
00129 #include "animControl.I"
00130
00131 #endif