particles.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <string>
  18. #include "irrlichttypes_bloated.h"
  19. #include "tileanimation.h"
  20. #include "mapnode.h"
  21. // This file defines the particle-related structures that both the server and
  22. // client need. The ParticleManager and rendering is in client/particles.h
  23. struct CommonParticleParams {
  24. bool collisiondetection = false;
  25. bool collision_removal = false;
  26. bool object_collision = false;
  27. bool vertical = false;
  28. std::string texture;
  29. struct TileAnimationParams animation;
  30. u8 glow = 0;
  31. MapNode node;
  32. u8 node_tile = 0;
  33. CommonParticleParams() {
  34. animation.type = TAT_NONE;
  35. node.setContent(CONTENT_IGNORE);
  36. }
  37. /* This helper is useful for copying params from
  38. * ParticleSpawnerParameters to ParticleParameters */
  39. inline void copyCommon(CommonParticleParams &to) const {
  40. to.collisiondetection = collisiondetection;
  41. to.collision_removal = collision_removal;
  42. to.object_collision = object_collision;
  43. to.vertical = vertical;
  44. to.texture = texture;
  45. to.animation = animation;
  46. to.glow = glow;
  47. to.node = node;
  48. to.node_tile = node_tile;
  49. }
  50. };
  51. struct ParticleParameters : CommonParticleParams {
  52. v3f pos;
  53. v3f vel;
  54. v3f acc;
  55. f32 expirationtime = 1;
  56. f32 size = 1;
  57. void serialize(std::ostream &os, u16 protocol_ver) const;
  58. void deSerialize(std::istream &is, u16 protocol_ver);
  59. };
  60. struct ParticleSpawnerParameters : CommonParticleParams {
  61. u16 amount = 1;
  62. v3f minpos, maxpos, minvel, maxvel, minacc, maxacc;
  63. f32 time = 1;
  64. f32 minexptime = 1, maxexptime = 1, minsize = 1, maxsize = 1;
  65. // For historical reasons no (de-)serialization methods here
  66. };