LightWrap++
AC++wrapperfortheLightWave3DSDK
itemmotion_handler.h
Go to the documentation of this file.
1 #ifndef LWPP_ITEMMOTION_HANDLER_H
2 #define LWPP_ITEMMOTION_HANDLER_H
3 
4 #include "lwpp/plugin_handler.h"
5 #include <lwmotion.h>
6 
7 namespace lwpp
8 {
11  {
12  protected:
14  public:
15  ItemMotionHandler(void* g, void* context, LWError* err)
16  : InstanceHandler(g,context,err, LWITEMMOTION_HCLASS)
17  {
18  Context.SetID(LWItemID(context));
19  }
21  {
22  ;
23  }
24 
25  virtual void Evaluate(const LWItemMotionAccess *ma)
26  {
27  ;
28  }
29  virtual unsigned int Flags()
30  {
31  return 0; //says This Plugin doesn't get applied after IK by default.
32  }
33  };
34 
36  template <class T, int min, int max>
37  class ItemMotionAdaptor : public InstanceAdaptor <T>, public ItemAdaptor <T>
38  {
39  public:
40  ItemMotionAdaptor(const char *name, ServerTagInfo *tags)
41  {
42  LWServer::AddPlugin(LWITEMMOTION_HCLASS, name, Activate, tags);
43  }
44  static int Activate (int version , GlobalFunc* global, LWInstance inst, void* serverData)
45  {
46  if(version!=LWITEMMOTION_VERSION) return AFUNC_BADVERSION;
47  lwpp::SetSuperGlobal(global);
48 
49  LWItemMotionHandler* plugin = static_cast<LWItemMotionHandler*>(inst);
50  InstanceAdaptor<T>::Activate(plugin->inst);
51  ItemAdaptor<T>::Activate(plugin->item);
52 
53  plugin->evaluate = ItemMotionAdaptor::Evaluate;
54  plugin->flags = ItemMotionAdaptor::Flags;
55 
56  UNUSED(serverData);
57  return AFUNC_OK;
58  }
59  private:
60  static void Evaluate (LWInstance inst, const LWItemMotionAccess* ma)
61  {
62  T* plugin = static_cast<T*>(inst);
63  plugin->Evaluate(ma);
64  }
65  static unsigned int Flags (LWInstance inst)
66  {
67  T* plugin = static_cast<T*>(inst);
68  return plugin->Flags();
69  }
70  };
71 
72  /* GUI Classes */
81 }
82 #endif //ITEMMOTION_H