Panda3D
modelNode.h
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 
15 #ifndef MODELNODE_H
16 #define MODELNODE_H
17 
18 #include "pandabase.h"
19 
20 #include "pandaNode.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ModelNode
24 // Description : This node is placed at key points within the scene
25 // graph to indicate the roots of "models": subtrees
26 // that are conceptually to be treated as a single unit,
27 // like a car or a room, for instance. It doesn't
28 // affect rendering or any other operations; it's
29 // primarily useful as a high-level model indication.
30 //
31 // ModelNodes are created in response to a <Model> { 1 }
32 // flag within an egg file.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_PGRAPH ModelNode : public PandaNode {
35 PUBLISHED:
36  INLINE ModelNode(const string &name);
37 
38 protected:
39  INLINE ModelNode(const ModelNode &copy);
40 
41 public:
42  virtual PandaNode *make_copy() const;
43 
44  virtual PandaNode *combine_with(PandaNode *other);
45  virtual bool safe_to_flatten() const;
46  virtual bool safe_to_flatten_below() const;
47  virtual bool safe_to_transform() const;
48  virtual bool safe_to_modify_transform() const;
49  virtual bool safe_to_combine() const;
50  virtual bool preserve_name() const;
51  virtual int get_unsafe_to_apply_attribs() const;
52 
53 PUBLISHED:
54  enum PreserveTransform {
55  PT_none,
56  PT_local,
57  PT_net,
58  PT_drop_node,
59  PT_no_touch,
60  };
61 
62  INLINE void set_preserve_transform(PreserveTransform preserve_transform);
63  INLINE PreserveTransform get_preserve_transform() const;
64 
65  INLINE void set_preserve_attributes(int attrib_mask);
66  INLINE int get_preserve_attributes() const;
67 
68  void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; };
69 
70 private:
71  PreserveTransform _preserve_transform;
72  int _preserve_attributes;
73 
74 public:
75  static void register_with_read_factory();
76  virtual void write_datagram(BamWriter *manager, Datagram &dg);
77 
78 protected:
79  static TypedWritable *make_from_bam(const FactoryParams &params);
80  void fillin(DatagramIterator &scan, BamReader *manager);
81 
82  virtual void transform_changed();
83  void test_transform(const TransformState *ts) const;
84 
85  PN_stdfloat _transform_limit;
86 
87 
88 
89 public:
90  static TypeHandle get_class_type() {
91  return _type_handle;
92  }
93  static void init_type() {
94  PandaNode::init_type();
95  register_type(_type_handle, "ModelNode",
96  PandaNode::get_class_type());
97  }
98  virtual TypeHandle get_type() const {
99  return get_class_type();
100  }
101  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
102 
103 private:
104  static TypeHandle _type_handle;
105 };
106 
107 #include "modelNode.I"
108 
109 #endif
110 
111 
virtual bool preserve_name() const
Returns true if the node&#39;s name has extrinsic meaning and must be preserved across a flatten operatio...
Definition: pandaNode.cxx:319
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: pandaNode.cxx:4164
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
virtual bool safe_to_modify_transform() const
Returns true if it is safe to automatically adjust the transform on this kind of node.
Definition: pandaNode.cxx:266
virtual PandaNode * combine_with(PandaNode *other)
Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined...
Definition: pandaNode.cxx:397
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:4153
virtual bool safe_to_combine() const
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of...
Definition: pandaNode.cxx:281
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
Definition: modelNode.h:34
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual bool safe_to_flatten_below() const
Returns true if a flatten operation may safely continue past this node, or false if nodes below this ...
Definition: pandaNode.cxx:307
virtual int get_unsafe_to_apply_attribs() const
Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applie...
Definition: pandaNode.cxx:335
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of PandaNode by calling the xf...
Definition: pandaNode.cxx:249
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating ...
Definition: pandaNode.cxx:237