Panda3D
 All Classes Functions Variables Enumerations
modelRoot.h
1 // Filename: modelRoot.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 MODELROOT_H
16 #define MODELROOT_H
17 
18 #include "pandabase.h"
19 #include "referenceCount.h"
20 #include "modelNode.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ModelRoot
24 // Description : A node of this type is created automatically at the
25 // root of each model file that is loaded. It may
26 // eventually contain some information about the
27 // contents of the model; at the moment, it contains no
28 // special information, but can be used as a flag to
29 // indicate the presence of a loaded model file.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PGRAPH ModelRoot : public ModelNode {
32 PUBLISHED:
33  INLINE ModelRoot(const string &name);
34  INLINE ModelRoot(const Filename &fulllpath, time_t timestamp);
35 
36  INLINE int get_model_ref_count() const;
37 
38  INLINE const Filename &get_fullpath() const;
39  INLINE void set_fullpath(const Filename &fullpath);
40 
41  INLINE time_t get_timestamp() const;
42  INLINE void set_timestamp(time_t timestamp);
43 
44  // This class is used to unify references to the same model.
45  class ModelReference : public ReferenceCount {
46  PUBLISHED:
47  INLINE ModelReference();
48  };
49 
50  INLINE ModelReference *get_reference() const;
51  void set_reference(ModelReference *ref);
52 
53 protected:
54  INLINE ModelRoot(const ModelRoot &copy);
55 
56 public:
57  virtual PandaNode *make_copy() const;
58 
59 private:
60  Filename _fullpath;
61  time_t _timestamp;
62  PT(ModelReference) _reference;
63 
64 public:
65  static void register_with_read_factory();
66  virtual void write_datagram(BamWriter *manager, Datagram &dg);
67 
68 protected:
69  static TypedWritable *make_from_bam(const FactoryParams &params);
70  void fillin(DatagramIterator &scan, BamReader *manager);
71 
72 public:
73  static TypeHandle get_class_type() {
74  return _type_handle;
75  }
76  static void init_type() {
77  ModelNode::init_type();
78  register_type(_type_handle, "ModelRoot",
79  ModelNode::get_class_type());
80  }
81  virtual TypeHandle get_type() const {
82  return get_class_type();
83  }
84  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85 
86 private:
87  static TypeHandle _type_handle;
88 };
89 
90 #include "modelRoot.I"
91 
92 #endif
93 
94 
A node of this type is created automatically at the root of each model file that is loaded...
Definition: modelRoot.h:31
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
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
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: modelNode.cxx:33
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
Definition: modelNode.h:34
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
A base class for all things that want to be reference-counted.
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
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43