Panda3D
Loading...
Searching...
No Matches
modelRoot.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file modelRoot.I
10 * @author drose
11 * @date 2002-03-16
12 */
13
14/**
15 *
16 */
17INLINE ModelRoot::
18ModelRoot(const std::string &name) :
19 ModelNode(name),
20 _fullpath(name),
21 _timestamp(0),
22 _reference(new ModelRoot::ModelReference)
23{
24}
25
26/**
27 *
28 */
29INLINE ModelRoot::
30ModelRoot(const Filename &fullpath, time_t timestamp) :
31 ModelNode(fullpath.get_basename()),
32 _fullpath(fullpath),
33 _timestamp(timestamp),
34 _reference(new ModelRoot::ModelReference)
35{
36}
37
38/**
39 * Returns the number of copies that exist of this particular ModelRoot node.
40 * Each time ModelRoot::copy_subgraph() or make_copy() is called (or some
41 * other copying mechanism, such as NodePath.copy_to(), is used), this count
42 * will increment by one in all copies; when one of the copies is destructed,
43 * this count will decrement.
44 */
45INLINE int ModelRoot::
46get_model_ref_count() const {
47 return _reference->get_ref_count();
48}
49
50/**
51 * Returns the full pathname of the model represented by this node, as found
52 * on disk. This is mainly useful for reference purposes, but is also used to
53 * index the ModelRoot into the ModelPool.
54 */
55INLINE const Filename &ModelRoot::
56get_fullpath() const {
57 return _fullpath;
58}
59
60/**
61 * Sets the full pathname of the model represented by this node, as found on
62 * disk. This is mainly useful for reference purposes, but is also used to
63 * index the ModelRoot into the ModelPool.
64 *
65 * This is normally set automatically when a model is loaded, and should not
66 * be set directly by the user. If you change this on a loaded model, then
67 * ModelPool::release_model() may fail.
68 */
69INLINE void ModelRoot::
70set_fullpath(const Filename &fullpath) {
71 _fullpath = fullpath;
72}
73
74/**
75 * Returns the timestamp of the file on disk that was read for this model, at
76 * the time it was read, if it is known. Returns 0 if the timestamp is not
77 * known or could not be provided. This can be used as a quick (but fallible)
78 * check to verify whether the file might have changed since the model was
79 * read.
80 */
81INLINE time_t ModelRoot::
82get_timestamp() const {
83 return _timestamp;
84}
85
86/**
87 * Sets the timestamp of the file on disk that was read for this model. This
88 * is normally set automatically when a model is loaded, and should not be set
89 * directly by the user.
90 */
91INLINE void ModelRoot::
92set_timestamp(time_t timestamp) {
93 _timestamp = timestamp;
94}
95
96/**
97 * Returns the pointer that represents the object shared between all copies of
98 * this ModelRoot. Since there's not much associated with this object other
99 * than a reference count, normally there's not much reason to get the pointer
100 * (though it may be compared pointerwise with other ModelRoot objects).
101 */
103get_reference() const {
104 return _reference;
105}
106
107/**
108 * Changes the pointer that represents the object shared between all copies of
109 * this ModelRoot. This will disassociate this ModelRoot from all of its
110 * copies. Normally, there's no reason to do this.
111 */
112INLINE void ModelRoot::
114 _reference = ref;
115}
116
117/**
118 *
119 */
120INLINE ModelRoot::
121ModelRoot(const ModelRoot &copy) :
122 ModelNode(copy),
123 _fullpath(copy._fullpath),
124 _timestamp(copy._timestamp),
125 _reference(copy._reference)
126{
127}
128
129/**
130 *
131 */
132INLINE ModelRoot::ModelReference::
133ModelReference() {
134}
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
Definition modelNode.h:31
A node of this type is created automatically at the root of each model file that is loaded.
Definition modelRoot.h:27
set_fullpath
Sets the full pathname of the model represented by this node, as found on disk.
Definition modelRoot.h:37
set_timestamp
Sets the timestamp of the file on disk that was read for this model.
Definition modelRoot.h:41
get_timestamp
Returns the timestamp of the file on disk that was read for this model, at the time it was read,...
Definition modelRoot.h:41
get_reference
Returns the pointer that represents the object shared between all copies of this ModelRoot.
Definition modelRoot.h:51
get_fullpath
Returns the full pathname of the model represented by this node, as found on disk.
Definition modelRoot.h:37
set_reference
Changes the pointer that represents the object shared between all copies of this ModelRoot.
Definition modelRoot.h:51
get_model_ref_count
Returns the number of copies that exist of this particular ModelRoot node.
Definition modelRoot.h:33
void ref() const
Explicitly increments the reference count.