Static.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /******************************************************************************
  2. Use 'Static' class for solid objects, which position will never change.
  3. /******************************************************************************/
  4. namespace Game{
  5. /******************************************************************************/
  6. STRUCT(Static , Obj) // Game Static Object, these objects are static and can't be moved during game (this class is similar to Game::Kinematic, with the exception that Kinematic can be moved manually)
  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
  18. virtual void pos (C Vec &pos ); // set position
  19. virtual Matrix matrix ( ); // get matrix , returned matrix is normalized
  20. virtual Matrix matrixScaled( ); // get matrix , returned matrix is scaled by 'scale'
  21. virtual void matrix (C Matrix &matrix); // set matrix , 'matrix' must be normalized
  22. // callbacks
  23. virtual void memoryAddressChanged(); // called when object memory address has been changed, you should override it and adjust Actor::obj pointer for all actors
  24. // update
  25. virtual Bool update(); // update, return false when object wants to be deleted, and true if wants to exist
  26. // draw
  27. 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)
  28. virtual void drawShadow (); // in this method you should add the meshes to the shadow draw list (Mesh::drawShadow)
  29. // io
  30. virtual Bool save(File &f); // save, false on fail
  31. virtual Bool load(File &f); // load, false on fail
  32. ~Static();
  33. Static();
  34. protected:
  35. Matrix _matrix, _matrix_scaled;
  36. };
  37. /******************************************************************************/
  38. } // namespace
  39. /******************************************************************************/