Kinematic.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /******************************************************************************
  2. Use 'Kinematic' class for solid objects, which position can be changed only manually.
  3. /******************************************************************************/
  4. namespace Game{
  5. /******************************************************************************/
  6. STRUCT(Kinematic , Obj) // Game Kinematic Object, these objects are created as kinematic actors, which means that their position is unaffected by other objects, but can be changed manually (this class is similar to Game::Static, with the exception that Static can't move at all)
  7. //{
  8. Vec scale ; // scale
  9. ObjectPtr base ; // base object
  10. MeshPtr mesh ; // mesh
  11. Int mesh_variation; // mesh variation index
  12. Actor actor ; // actor
  13. // manage
  14. virtual void create(Object &obj); // create from object
  15. virtual void setUnsavedParams(); // set parameters which are not included in the save file
  16. // get / set
  17. virtual Vec pos ( ); // get position (based on 'actor.pos ')
  18. virtual void pos (C Vec &pos ); // set position (based on 'actor.pos ')
  19. virtual Matrix matrix ( ); // get matrix , returned matrix is normalized , (based on 'actor.matrix ')
  20. virtual Matrix matrixScaled ( ); // get matrix , returned matrix is scaled by 'scale', (based on 'actor.matrix ')
  21. virtual void matrix (C Matrix &matrix); // set matrix , 'matrix' must be normalized (based on 'actor.matrix ')
  22. virtual void kinematicMoveTo(C Vec &pos ); // move to position (based on 'actor.kinematicMoveTo'), for differences between methods please check comments on 'Actor::kinematicMoveTo'
  23. virtual void kinematicMoveTo(C Matrix &matrix); // move to matrix , 'matrix' must be normalized (based on 'actor.kinematicMoveTo'), for differences between methods please check comments on 'Actor::kinematicMoveTo'
  24. // callbacks
  25. virtual void memoryAddressChanged(); // called when object memory address has been changed, you should override it and adjust Actor::obj pointer for all actors
  26. // update
  27. virtual Bool update(); // update, return false when object wants to be deleted, and true if wants to exist
  28. // draw
  29. 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)
  30. virtual void drawShadow (); // in this method you should add the meshes to the shadow draw list (Mesh::drawShadow)
  31. // io
  32. virtual Bool save(File &f); // save, false on fail
  33. virtual Bool load(File &f); // load, false on fail
  34. ~Kinematic();
  35. Kinematic();
  36. protected:
  37. Matrix _matrix, _matrix_scaled;
  38. };
  39. /******************************************************************************/
  40. } // namespace
  41. /******************************************************************************/