Obj Decal.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. namespace EE{
  4. namespace Game{
  5. /******************************************************************************/
  6. ObjDecal::~ObjDecal()
  7. {
  8. }
  9. ObjDecal::ObjDecal()
  10. {
  11. }
  12. /******************************************************************************/
  13. // MANAGE
  14. /******************************************************************************/
  15. void ObjDecal::create(Object &obj)
  16. {
  17. decal.terrain_only=true;
  18. if(C Param *material=obj.findParam("material"))decal.material(material->asID());
  19. decal.matrix=obj.matrixFinal(); decal.matrix.scaleOrn(0.5f); Swap(decal.matrix.y, decal.matrix.z); decal.matrix.y.chs();
  20. }
  21. /******************************************************************************/
  22. // GET / SET
  23. /******************************************************************************/
  24. Vec ObjDecal::pos ( ) {return decal.matrix.pos ;}
  25. Matrix ObjDecal::matrix( ) {return decal.matrix ;}
  26. void ObjDecal::pos (C Vec &pos ) { decal.matrix.pos=pos ;}
  27. void ObjDecal::matrix(C Matrix &matrix) { decal.matrix =matrix;}
  28. /******************************************************************************/
  29. // UPDATE
  30. /******************************************************************************/
  31. Bool ObjDecal::update()
  32. {
  33. return true;
  34. }
  35. /******************************************************************************/
  36. // DRAW
  37. /******************************************************************************/
  38. UInt ObjDecal::drawPrepare()
  39. {
  40. return IndexToFlag(RM_OVERLAY); // decal requires RM_OVERLAY render mode
  41. }
  42. void ObjDecal::drawOverlay() {decal.drawStatic();}
  43. /******************************************************************************/
  44. // IO
  45. /******************************************************************************/
  46. Bool ObjDecal::save(File &f)
  47. {
  48. if(super::save(f))
  49. {
  50. f.cmpUIntV(0); // version
  51. if(decal.save(f))
  52. return f.ok();
  53. }
  54. return false;
  55. }
  56. Bool ObjDecal::load(File &f)
  57. {
  58. if(super::load(f))switch(f.decUIntV()) // version
  59. {
  60. case 0:
  61. {
  62. if(decal.load(f))
  63. if(f.ok())return true;
  64. }break;
  65. }
  66. return false;
  67. }
  68. /******************************************************************************/
  69. }}
  70. /******************************************************************************/