@Obj.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class Obj : ObjData
  4. {
  5. static int ComparePtr(Obj*C &a, Obj*C &b);
  6. Area *area;
  7. bool selected, highlighted,
  8. invalid_refs,
  9. visible; // this should be reflection of the 'World.obj_visible'
  10. EDIT_OBJ_TYPE edit_type;
  11. MeshPtr mesh, mesh_proper; // 'mesh_proper' is set to proper MeshPtr to avoid reloading/unloading meshes in case they are empty because 'mesh' will be forced to 'WorldEdit.dummy_mesh' if empty
  12. int mesh_variation;
  13. PhysBodyPtr phys;
  14. ImagePtr icon;
  15. Particles particles;
  16. Vec light_col;
  17. flt light_angle, light_falloff;
  18. bool light_cast_shadows;
  19. ~Obj();
  20. // get
  21. bool setInvalidRefs();
  22. bool invalidRefs()C;
  23. cchar8* variationName()C;
  24. Matrix drawMatrix();
  25. Vec pos();
  26. Vec center();
  27. bool getBox(Box &box);
  28. bool onGround();
  29. bool embedded();
  30. void getCol(Color &col_lit, Color&col_shape);
  31. PhysPath physPath()C;
  32. // operations
  33. void attach(WorldData &world, Area *a=null);
  34. void detach();
  35. void setUpdatability();
  36. void setVisibility();
  37. void removeChanged();
  38. void remove();
  39. void create(C Obj &src);
  40. bool sync(C ObjData &src, cchar *edit_path);
  41. bool undo(C ObjData &src, cchar *edit_path);
  42. Obj& setChangedEmbed(C VecI2 *area_xy=null); // must be called after 'changedObj' and before 'setChangedPaths'
  43. Obj& setChangedPaths(); // must be called after 'setChangedEmbed'
  44. Obj& setChanged(bool matrix=false); // this needs to be called after making all changes
  45. void setUndo(cptr type=WorldUndo::ObjType, bool as_new=false);
  46. void moveTo(C Vec &pos, cptr undo_type=WorldUndo::ObjType);
  47. void moveTo(C Matrix3 &orn, cptr undo_type=WorldUndo::ObjType);
  48. void moveTo(C Matrix &matrix, cptr undo_type=WorldUndo::ObjType);
  49. void scaleBy (flt f);
  50. void scaleXBy(flt f);
  51. void scaleYBy(flt f);
  52. void scaleZBy(flt f);
  53. void randomRot();
  54. void resetRot();
  55. void alignGrid();
  56. void alignTerrain(bool force, cptr undo_type=WorldUndo::ObjType);
  57. void alignNormal(int axis=-1, flt blend=1);
  58. // update
  59. void update();
  60. // draw
  61. bool skipDraw();
  62. void draw();
  63. void drawShadow();
  64. void drawParticle();
  65. void drawSelected();
  66. void drawHelper(bool box, bool phys);
  67. // io
  68. void setDraw();
  69. void setMeshVariation();
  70. void setMeshPhys();
  71. bool save(File &f);
  72. bool load(File &f); // 'setMeshPhys' doesn't need to be called because it will be called in 'attach->removeChanged'
  73. public:
  74. Obj();
  75. };
  76. /******************************************************************************/
  77. /******************************************************************************/
  78. /******************************************************************************/