Panda3D
|
00001 // Filename: lerp.h 00002 // Created by: frang (18Apr00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef __LERP_H__ 00016 #define __LERP_H__ 00017 00018 #include "pandabase.h" 00019 00020 #include "lerpfunctor.h" 00021 #include "lerpblend.h" 00022 00023 #include "typedReferenceCount.h" 00024 #include "eventHandler.h" 00025 00026 class EXPCL_PANDA_LERP Lerp : public TypedReferenceCount { 00027 private: 00028 PT(LerpBlendType) _blend; 00029 PT(LerpFunctor) _func; 00030 std::string _event; 00031 float _startt; 00032 float _endt; 00033 float _delta; 00034 float _t; 00035 00036 PUBLISHED: 00037 Lerp(LerpFunctor* func, float endt, LerpBlendType* blend); 00038 Lerp(LerpFunctor* func, float startt, float endt, LerpBlendType* blend); 00039 Lerp(const Lerp&); 00040 virtual ~Lerp(); 00041 Lerp& operator=(const Lerp&); 00042 void step(); 00043 void set_step_size(float); 00044 float get_step_size() const; 00045 void set_t(float); 00046 float get_t() const; 00047 bool is_done() const; 00048 LerpFunctor* get_functor() const; 00049 void set_end_event(const std::string&); 00050 std::string get_end_event() const; 00051 00052 public: 00053 // now for typehandle stuff 00054 static TypeHandle get_class_type() { 00055 return _type_handle; 00056 } 00057 static void init_type() { 00058 TypedReferenceCount::init_type(); 00059 register_type(_type_handle, "Lerp", TypedReferenceCount::get_class_type()); 00060 } 00061 virtual TypeHandle get_type() const { 00062 return get_class_type(); 00063 } 00064 virtual TypeHandle force_init_type() { 00065 init_type(); 00066 return get_class_type(); 00067 } 00068 private: 00069 static TypeHandle _type_handle; 00070 }; 00071 00072 class EXPCL_PANDA_LERP AutonomousLerp : public TypedReferenceCount { 00073 private: 00074 PT(LerpBlendType) _blend; 00075 PT(LerpFunctor) _func; 00076 EventHandler* _handler; 00077 std::string _event; 00078 float _startt; 00079 float _endt; 00080 float _t; 00081 00082 virtual void step(); 00083 static void handle_event(const Event *, void*); 00084 00085 PUBLISHED: 00086 AutonomousLerp(LerpFunctor* func, float endt, LerpBlendType* blend, 00087 EventHandler* handler); 00088 AutonomousLerp(LerpFunctor* func, float startt, float endt, 00089 LerpBlendType* blend, EventHandler* handler); 00090 AutonomousLerp(const AutonomousLerp&); 00091 virtual ~AutonomousLerp(); 00092 AutonomousLerp& operator=(const AutonomousLerp&); 00093 void start(); 00094 void stop(); 00095 void resume(); 00096 bool is_done() const; 00097 LerpFunctor* get_functor() const; 00098 void set_t(float); 00099 float get_t() const; 00100 void set_end_event(const std::string&); 00101 std::string get_end_event() const; 00102 00103 public: 00104 // now for typehandle stuff 00105 static TypeHandle get_class_type() { 00106 return _type_handle; 00107 } 00108 static void init_type() { 00109 TypedReferenceCount::init_type(); 00110 register_type(_type_handle, "AutonomousLerp", 00111 TypedReferenceCount::get_class_type()); 00112 } 00113 virtual TypeHandle get_type() const { 00114 return get_class_type(); 00115 } 00116 virtual TypeHandle force_init_type() { 00117 init_type(); 00118 return get_class_type(); 00119 } 00120 private: 00121 static TypeHandle _type_handle; 00122 }; 00123 00124 #endif /* __LERP_H__ */