modelNode.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Filename: modelNode.h
  2. // Created by: drose (16Mar02)
  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. #ifndef MODELNODE_H
  15. #define MODELNODE_H
  16. #include "pandabase.h"
  17. #include "pandaNode.h"
  18. ////////////////////////////////////////////////////////////////////
  19. // Class : ModelNode
  20. // Description : This node is placed at key points within the scene
  21. // graph to indicate the roots of "models": subtrees
  22. // that are conceptually to be treated as a single unit,
  23. // like a car or a room, for instance. It doesn't
  24. // affect rendering or any other operations; it's
  25. // primarily useful as a high-level model indication.
  26. //
  27. // ModelNodes are created in response to a <Model> { 1 }
  28. // flag within an egg file.
  29. ////////////////////////////////////////////////////////////////////
  30. class EXPCL_PANDA_PGRAPH ModelNode : public PandaNode {
  31. PUBLISHED:
  32. INLINE ModelNode(const string &name);
  33. protected:
  34. INLINE ModelNode(const ModelNode &copy);
  35. public:
  36. virtual PandaNode *make_copy() const;
  37. virtual PandaNode *combine_with(PandaNode *other);
  38. virtual bool safe_to_flatten() const;
  39. virtual bool safe_to_flatten_below() const;
  40. virtual bool safe_to_transform() const;
  41. virtual bool safe_to_modify_transform() const;
  42. virtual bool safe_to_combine() const;
  43. virtual bool preserve_name() const;
  44. virtual int get_unsafe_to_apply_attribs() const;
  45. PUBLISHED:
  46. enum PreserveTransform {
  47. PT_none,
  48. PT_local,
  49. PT_net,
  50. PT_drop_node,
  51. PT_no_touch,
  52. };
  53. INLINE void set_preserve_transform(PreserveTransform preserve_transform);
  54. INLINE PreserveTransform get_preserve_transform() const;
  55. INLINE void set_preserve_attributes(int attrib_mask);
  56. INLINE int get_preserve_attributes() const;
  57. void set_transform_limit(float limit) { _transform_limit = limit; };
  58. private:
  59. PreserveTransform _preserve_transform;
  60. int _preserve_attributes;
  61. public:
  62. static void register_with_read_factory();
  63. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  64. protected:
  65. static TypedWritable *make_from_bam(const FactoryParams &params);
  66. void fillin(DatagramIterator &scan, BamReader *manager);
  67. virtual void transform_changed();
  68. void test_transform(const TransformState *ts) const;
  69. float _transform_limit;
  70. public:
  71. static TypeHandle get_class_type() {
  72. return _type_handle;
  73. }
  74. static void init_type() {
  75. PandaNode::init_type();
  76. register_type(_type_handle, "ModelNode",
  77. PandaNode::get_class_type());
  78. }
  79. virtual TypeHandle get_type() const {
  80. return get_class_type();
  81. }
  82. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  83. private:
  84. static TypeHandle _type_handle;
  85. };
  86. #include "modelNode.I"
  87. #endif