eggSwitchCondition.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Filename: eggSwitchCondition.h
  2. // Created by: drose (08Feb99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef EGGSWITCHCONDITION
  19. #define EGGSWITCHCONDITION
  20. #include "pandabase.h"
  21. #include "eggObject.h"
  22. #include "luse.h"
  23. ////////////////////////////////////////////////////////////////////
  24. // Class : EggSwitchCondition
  25. // Description : This corresponds to a <SwitchCondition> entry within
  26. // a group. It indicates the condition at which a
  27. // level-of-detail is switched in or out. This is
  28. // actually an abstract base class for potentially any
  29. // number of specific different kinds of switching
  30. // conditions; presently, only a <Distance> type is
  31. // actually supported.
  32. ////////////////////////////////////////////////////////////////////
  33. class EXPCL_PANDAEGG EggSwitchCondition : public EggObject {
  34. PUBLISHED:
  35. virtual EggSwitchCondition *make_copy() const=0;
  36. virtual void write(ostream &out, int indent_level) const=0;
  37. virtual void transform(const LMatrix4d &mat)=0;
  38. public:
  39. static TypeHandle get_class_type() {
  40. return _type_handle;
  41. }
  42. static void init_type() {
  43. EggObject::init_type();
  44. register_type(_type_handle, "EggSwitchCondition",
  45. EggObject::get_class_type());
  46. }
  47. virtual TypeHandle get_type() const {
  48. return get_class_type();
  49. }
  50. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  51. private:
  52. static TypeHandle _type_handle;
  53. };
  54. ////////////////////////////////////////////////////////////////////
  55. // Class : EggSwitchConditionDistance
  56. // Description : A SwitchCondition that switches the levels-of-detail
  57. // based on distance from the camera's eyepoint.
  58. ////////////////////////////////////////////////////////////////////
  59. class EXPCL_PANDAEGG EggSwitchConditionDistance : public EggSwitchCondition {
  60. public:
  61. EggSwitchConditionDistance(double switch_in, double switch_out,
  62. const LPoint3d &center, double fade = 0.0);
  63. virtual EggSwitchCondition *make_copy() const;
  64. virtual void write(ostream &out, int indent_level) const;
  65. virtual void transform(const LMatrix4d &mat);
  66. double _switch_in, _switch_out, _fade;
  67. LPoint3d _center;
  68. public:
  69. static TypeHandle get_class_type() {
  70. return _type_handle;
  71. }
  72. static void init_type() {
  73. EggSwitchCondition::init_type();
  74. register_type(_type_handle, "EggSwitchConditionDistance",
  75. EggSwitchCondition::get_class_type());
  76. }
  77. virtual TypeHandle get_type() const {
  78. return get_class_type();
  79. }
  80. private:
  81. static TypeHandle _type_handle;
  82. };
  83. #endif