baseParticleFactory.cxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Filename: baseParticleFactory.cxx
  2. // Created by: charles (05Jul00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #include "baseParticleFactory.h"
  15. ////////////////////////////////////////////////////////////////////
  16. // Function : BaseParticleFactory
  17. // Access : protected
  18. // Description : constructor
  19. ////////////////////////////////////////////////////////////////////
  20. BaseParticleFactory::
  21. BaseParticleFactory() :
  22. _lifespan_base(1.0),
  23. _lifespan_spread(0.0),
  24. _mass_base(1.0f),
  25. _mass_spread(0.0f),
  26. _terminal_velocity_base(PhysicsObject::_default_terminal_velocity),
  27. _terminal_velocity_spread(0.0f)
  28. {
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function : BaseParticleFactory
  32. // Access : protected
  33. // Description : copy constructor
  34. ////////////////////////////////////////////////////////////////////
  35. BaseParticleFactory::
  36. BaseParticleFactory(const BaseParticleFactory &copy) :
  37. _lifespan_base(copy._lifespan_base),
  38. _lifespan_spread(copy._lifespan_spread),
  39. _mass_base(copy._mass_base),
  40. _mass_spread(copy._mass_spread),
  41. _terminal_velocity_base(copy._terminal_velocity_base),
  42. _terminal_velocity_spread(copy._terminal_velocity_spread)
  43. {
  44. }
  45. ////////////////////////////////////////////////////////////////////
  46. // Function : ~BaseParticleFactory
  47. // Access : public virtual
  48. // Description : destructor
  49. ////////////////////////////////////////////////////////////////////
  50. BaseParticleFactory::
  51. ~BaseParticleFactory() {
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function : make_particle
  55. // Description : public
  56. ////////////////////////////////////////////////////////////////////
  57. void BaseParticleFactory::
  58. populate_particle(BaseParticle *bp) {
  59. bp->set_lifespan(_lifespan_base + SPREAD(_lifespan_spread));
  60. bp->set_mass(_mass_base + SPREAD(_mass_spread));
  61. bp->set_terminal_velocity(_terminal_velocity_base + SPREAD(_terminal_velocity_spread));
  62. bp->set_active(false);
  63. bp->set_alive(false);
  64. bp->set_age(0.0f);
  65. bp->set_index(0);
  66. populate_child_particle(bp);
  67. }
  68. ////////////////////////////////////////////////////////////////////
  69. // Function : output
  70. // Access : Public
  71. // Description : Write a string representation of this instance to
  72. // <out>.
  73. ////////////////////////////////////////////////////////////////////
  74. void BaseParticleFactory::
  75. output(ostream &out) const {
  76. #ifndef NDEBUG //[
  77. out<<"BaseParticleFactory";
  78. #endif //] NDEBUG
  79. }
  80. ////////////////////////////////////////////////////////////////////
  81. // Function : write
  82. // Access : Public
  83. // Description : Write a string representation of this instance to
  84. // <out>.
  85. ////////////////////////////////////////////////////////////////////
  86. void BaseParticleFactory::
  87. write(ostream &out, int indent) const {
  88. #ifndef NDEBUG //[
  89. out.width(indent); out<<""; out<<"BaseParticleFactory:\n";
  90. out.width(indent+2); out<<""; out<<"_lifespan_base "<<_lifespan_base<<"\n";
  91. out.width(indent+2); out<<""; out<<"_lifespan_spread "<<_lifespan_spread<<"\n";
  92. out.width(indent+2); out<<""; out<<"_mass_base "<<_mass_base<<"\n";
  93. out.width(indent+2); out<<""; out<<"_mass_spread "<<_mass_spread<<"\n";
  94. out.width(indent+2); out<<""; out<<"_terminal_velocity_base "<<_terminal_velocity_base<<"\n";
  95. out.width(indent+2); out<<""; out<<"_terminal_velocity_spread "<<_terminal_velocity_spread<<"\n";
  96. //ReferenceCount::write(out, indent+2);
  97. #endif //] NDEBUG
  98. }