00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __LERP_H__
00020 #define __LERP_H__
00021
00022 #include <pandabase.h>
00023
00024 #include "lerpfunctor.h"
00025 #include "lerpblend.h"
00026
00027 #include <typedReferenceCount.h>
00028 #include <eventHandler.h>
00029
00030 class EXPCL_PANDA Lerp : public TypedReferenceCount {
00031 private:
00032 PT(LerpBlendType) _blend;
00033 PT(LerpFunctor) _func;
00034 std::string _event;
00035 float _startt;
00036 float _endt;
00037 float _delta;
00038 float _t;
00039
00040 PUBLISHED:
00041 Lerp(LerpFunctor* func, float endt, LerpBlendType* blend);
00042 Lerp(LerpFunctor* func, float startt, float endt, LerpBlendType* blend);
00043 Lerp(const Lerp&);
00044 virtual ~Lerp(void);
00045 Lerp& operator=(const Lerp&);
00046 void step(void);
00047 void set_step_size(float);
00048 float get_step_size(void) const;
00049 void set_t(float);
00050 float get_t(void) const;
00051 bool is_done(void) const;
00052 LerpFunctor* get_functor(void) const;
00053 void set_end_event(const std::string&);
00054 std::string get_end_event(void) const;
00055
00056 public:
00057
00058 static TypeHandle get_class_type(void) {
00059 return _type_handle;
00060 }
00061 static void init_type(void) {
00062 TypedReferenceCount::init_type();
00063 register_type(_type_handle, "Lerp", TypedReferenceCount::get_class_type());
00064 }
00065 virtual TypeHandle get_type(void) const {
00066 return get_class_type();
00067 }
00068 virtual TypeHandle force_init_type(void) {
00069 init_type();
00070 return get_class_type();
00071 }
00072 private:
00073 static TypeHandle _type_handle;
00074 };
00075
00076 class EXPCL_PANDA AutonomousLerp : public TypedReferenceCount {
00077 private:
00078 PT(LerpBlendType) _blend;
00079 PT(LerpFunctor) _func;
00080 EventHandler* _handler;
00081 std::string _event;
00082 float _startt;
00083 float _endt;
00084 float _t;
00085
00086 virtual void step(void);
00087 static void handle_event(CPT(Event), void*);
00088
00089 PUBLISHED:
00090 AutonomousLerp(LerpFunctor* func, float endt, LerpBlendType* blend,
00091 EventHandler* handler);
00092 AutonomousLerp(LerpFunctor* func, float startt, float endt,
00093 LerpBlendType* blend, EventHandler* handler);
00094 AutonomousLerp(const AutonomousLerp&);
00095 virtual ~AutonomousLerp(void);
00096 AutonomousLerp& operator=(const AutonomousLerp&);
00097 void start(void);
00098 void stop(void);
00099 void resume(void);
00100 bool is_done(void) const;
00101 LerpFunctor* get_functor(void) const;
00102 void set_t(float);
00103 float get_t(void) const;
00104 void set_end_event(const std::string&);
00105 std::string get_end_event(void) const;
00106
00107 public:
00108
00109 static TypeHandle get_class_type(void) {
00110 return _type_handle;
00111 }
00112 static void init_type(void) {
00113 TypedReferenceCount::init_type();
00114 register_type(_type_handle, "AutonomousLerp",
00115 TypedReferenceCount::get_class_type());
00116 }
00117 virtual TypeHandle get_type(void) const {
00118 return get_class_type();
00119 }
00120 virtual TypeHandle force_init_type(void) {
00121 init_type();
00122 return get_class_type();
00123 }
00124 private:
00125 static TypeHandle _type_handle;
00126 };
00127
00128 #endif