Panda3D

modelRoot.h

00001 // Filename: modelRoot.h
00002 // Created by:  drose (16Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef MODELROOT_H
00016 #define MODELROOT_H
00017 
00018 #include "pandabase.h"
00019 #include "referenceCount.h"
00020 #include "modelNode.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : ModelRoot
00024 // Description : A node of this type is created automatically at the
00025 //               root of each model file that is loaded.  It may
00026 //               eventually contain some information about the
00027 //               contents of the model; at the moment, it contains no
00028 //               special information, but can be used as a flag to
00029 //               indicate the presence of a loaded model file.
00030 ////////////////////////////////////////////////////////////////////
00031 class EXPCL_PANDA_PGRAPH ModelRoot : public ModelNode {
00032 PUBLISHED:
00033   INLINE ModelRoot(const string &name);
00034 
00035   INLINE int get_model_ref_count() const;
00036 
00037   INLINE const Filename &get_fullpath() const;
00038   INLINE void set_fullpath(const Filename &fullpath);
00039 
00040   // This class is used to unify references to the same model.
00041   class ModelReference : public ReferenceCount {
00042   PUBLISHED:
00043     INLINE ModelReference();
00044   };
00045 
00046   INLINE ModelReference *get_reference() const;
00047   void set_reference(ModelReference *ref);
00048 
00049 protected:
00050   INLINE ModelRoot(const ModelRoot &copy);
00051 
00052 public:
00053   virtual PandaNode *make_copy() const;
00054 
00055 private:
00056   Filename _fullpath;
00057   PT(ModelReference) _reference;
00058 
00059 public:
00060   static void register_with_read_factory();
00061   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00062 
00063 protected:
00064   static TypedWritable *make_from_bam(const FactoryParams &params);
00065   void fillin(DatagramIterator &scan, BamReader *manager);
00066 
00067 public:
00068   static TypeHandle get_class_type() {
00069     return _type_handle;
00070   }
00071   static void init_type() {
00072     ModelNode::init_type();
00073     register_type(_type_handle, "ModelRoot",
00074                   ModelNode::get_class_type());
00075   }
00076   virtual TypeHandle get_type() const {
00077     return get_class_type();
00078   }
00079   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00080 
00081 private:
00082   static TypeHandle _type_handle;
00083 };
00084 
00085 #include "modelRoot.I"
00086 
00087 #endif
00088 
00089 
 All Classes Functions Variables Enumerations