Animatable.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /******************************************************************************
  2. Use 'Animatable' class for animatable objects using Skeleton and Animation.
  3. /******************************************************************************/
  4. namespace Game{
  5. /******************************************************************************/
  6. STRUCT(Animatable , Obj) // Game Animatable Object
  7. //{
  8. Flt scale ; // scale
  9. ObjectPtr base ; // base object
  10. MeshPtr mesh ; // mesh
  11. Int mesh_variation; // mesh variation index
  12. AnimatedSkeleton skel ; // animated skeleton
  13. SkelAnim *skel_anim ; // skeleton animation
  14. Actor actor ; // actor
  15. // manage
  16. virtual void create(Object &obj); // create from object
  17. virtual void setUnsavedParams(); // set parameters which are not included in the save file
  18. // get / set
  19. virtual Vec pos ( ); // get position
  20. virtual void pos (C Vec &pos ); // set position
  21. virtual Matrix matrix( ); // get matrix , returned matrix is normalized
  22. virtual void matrix(C Matrix &matrix); // set matrix , 'matrix' must be normalized
  23. // callbacks
  24. virtual void memoryAddressChanged(); // called when object memory address has been changed, you should override it and adjust Actor::obj pointer for all actors
  25. // update
  26. virtual Bool update(); // update, return false when object wants to be deleted, and true if wants to exist
  27. // draw
  28. virtual UInt drawPrepare(); // prepare for drawing, this will be called in RM_PREPARE mode, in this method you should add the meshes to the draw list (Mesh::draw), and return a combination of bits of which additional render modes will be required for custom drawing of the object (for example "return IndexToFlag(RM_BLEND)" requests blend mode rendering)
  29. virtual void drawShadow (); // in this method you should add the meshes to the shadow draw list (Mesh::drawShadow)
  30. // io
  31. virtual Bool save(File &f); // save, false on fail
  32. virtual Bool load(File &f); // load, false on fail
  33. ~Animatable();
  34. Animatable();
  35. protected:
  36. Matrix _matrix;
  37. };
  38. /******************************************************************************/
  39. } // namespace
  40. /******************************************************************************/