Panda3D

internalName.I

00001 // Filename: internalName.I
00002 // Created by:  masad (15Jul04)
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 ////////////////////////////////////////////////////////////////////
00016 //     Function: InternalName::make
00017 //       Access: Published, Static
00018 //  Description: The public interface for constructing an InternalName
00019 //               pointer.  This will return a new InternalName
00020 //               representing the indicated name, if this is the first
00021 //               time the particular name has been requested; if the
00022 //               name is already in use, it will return the existing
00023 //               pointer.
00024 //
00025 //               If the string contains the '.' character, the string
00026 //               will be divided at the dots and the so-defined
00027 //               hierarchy of names will be registered.  This is
00028 //               handled transparently.
00029 ////////////////////////////////////////////////////////////////////
00030 INLINE PT(InternalName) InternalName::
00031 make(const string &name) {
00032   return get_root()->append(name);
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: InternalName::get_parent
00037 //       Access: Published
00038 //  Description: Return the parent of this InternalName.  All names
00039 //               have a parent, except the root name.
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE InternalName *InternalName::
00042 get_parent() const {
00043   return _parent;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: InternalName::get_basename
00048 //       Access: Published
00049 //  Description: Return the name represented by just this particular
00050 //               InternalName object, ignoring its parents names.
00051 //               This is everything after the rightmost dot.
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE const string &InternalName::
00054 get_basename() const {
00055   return _basename;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: InternalName::get_root
00060 //       Access: Published, Static
00061 //  Description: Returns the standard root InternalName.  This is the
00062 //               root of all other InternalNames.  It has no name
00063 //               itself, and it is the only InternalName with no
00064 //               parent.
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE PT(InternalName) InternalName::
00067 get_root() {
00068   if (_root == (InternalName *)NULL) {
00069     _root = new InternalName(NULL, "");
00070   }
00071   return _root;
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //     Function: InternalName::get_error
00076 //       Access: Published, Static
00077 //  Description: Returns the standard InternalName "error".
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE PT(InternalName) InternalName::
00080 get_error() {
00081   if (_error == (InternalName *)NULL) {
00082     _error = InternalName::make("error");
00083   }
00084   return _error;
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: InternalName::get_vertex
00089 //       Access: Published, Static
00090 //  Description: Returns the standard InternalName "vertex".  This is
00091 //               the column header for the 3-d or 4-d vertex position
00092 //               information for each vertex.
00093 ////////////////////////////////////////////////////////////////////
00094 INLINE PT(InternalName) InternalName::
00095 get_vertex() {
00096   if (_vertex == (InternalName *)NULL) {
00097     _vertex = InternalName::make("vertex");
00098   }
00099   return _vertex;
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: InternalName::get_normal
00104 //       Access: Published, Static
00105 //  Description: Returns the standard InternalName "normal".  This is
00106 //               the column header for the 3-d lighting normal for
00107 //               each vertex.
00108 ////////////////////////////////////////////////////////////////////
00109 INLINE PT(InternalName) InternalName::
00110 get_normal() {
00111   if (_normal == (InternalName *)NULL) {
00112     _normal = InternalName::make("normal");
00113   }
00114   return _normal;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: InternalName::get_tangent
00119 //       Access: Published, Static
00120 //  Description: Returns the standard InternalName "tangent".  This is
00121 //               the column header for the tangent vector associated
00122 //               with each vertex, which is a unit vector
00123 //               usually perpendicular to the normal and in the
00124 //               direction of the U texture coordinate change.  It is
00125 //               used for deriving bump maps.
00126 ////////////////////////////////////////////////////////////////////
00127 INLINE PT(InternalName) InternalName::
00128 get_tangent() {
00129   if (_tangent == (InternalName *)NULL) {
00130     _tangent = InternalName::make("tangent");
00131   }
00132   return _tangent;
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: InternalName::get_tangent_name
00137 //       Access: Published, Static
00138 //  Description: Returns the InternalName "tangent.name", where name
00139 //               is the supplied string.  This is the column header
00140 //               for the tangent associated with the named texture
00141 //               coordinate set.
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE PT(InternalName) InternalName::
00144 get_tangent_name(const string &name) {
00145   return get_tangent()->append(name);
00146 }
00147 
00148 ////////////////////////////////////////////////////////////////////
00149 //     Function: InternalName::get_binormal
00150 //       Access: Published, Static
00151 //  Description: Returns the standard InternalName "binormal".  This is
00152 //               the column header for the tangent vector associated
00153 //               with each vertex, which is a unit vector
00154 //               usually perpendicular to both the normal and the
00155 //               tangent, and in the direction of the V texture
00156 //               coordinate change.  It is used for deriving bump
00157 //               maps.
00158 ////////////////////////////////////////////////////////////////////
00159 INLINE PT(InternalName) InternalName::
00160 get_binormal() {
00161   if (_binormal == (InternalName *)NULL) {
00162     _binormal = InternalName::make("binormal");
00163   }
00164   return _binormal;
00165 }
00166 
00167 ////////////////////////////////////////////////////////////////////
00168 //     Function: InternalName::get_binormal_name
00169 //       Access: Published, Static
00170 //  Description: Returns the InternalName "binormal.name", where name
00171 //               is the supplied string.  This is the column header
00172 //               for the binormal associated with the named texture
00173 //               coordinate set.
00174 ////////////////////////////////////////////////////////////////////
00175 INLINE PT(InternalName) InternalName::
00176 get_binormal_name(const string &name) {
00177   return get_binormal()->append(name);
00178 }
00179 
00180 ////////////////////////////////////////////////////////////////////
00181 //     Function: InternalName::get_texcoord
00182 //       Access: Published, Static
00183 //  Description: Returns the standard InternalName "texcoord".  This
00184 //               is the column header for the default texture
00185 //               coordinate set for each vertex.  It is also used for
00186 //               identifying the default texture coordinate set in a
00187 //               TextureStage.
00188 ////////////////////////////////////////////////////////////////////
00189 INLINE PT(InternalName) InternalName::
00190 get_texcoord() {
00191   if (_texcoord == (InternalName *)NULL) {
00192     _texcoord = InternalName::make("texcoord");
00193   }
00194   return _texcoord;
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: InternalName::get_texcoord_name
00199 //       Access: Published, Static
00200 //  Description: Returns the InternalName "texcoord.name", where name
00201 //               is the supplied string.  This is the column header
00202 //               for the named texture coordinate set for each vertex.
00203 //               It is also used for identifying the named texture
00204 //               coordinate set in a TextureStage.
00205 ////////////////////////////////////////////////////////////////////
00206 INLINE PT(InternalName) InternalName::
00207 get_texcoord_name(const string &name) {
00208   return get_texcoord()->append(name);
00209 }
00210 
00211 ////////////////////////////////////////////////////////////////////
00212 //     Function: InternalName::get_color
00213 //       Access: Published, Static
00214 //  Description: Returns the standard InternalName "color".  This is
00215 //               the column header for the 4-component color value for
00216 //               each vertex.
00217 ////////////////////////////////////////////////////////////////////
00218 INLINE PT(InternalName) InternalName::
00219 get_color() {
00220   if (_color == (InternalName *)NULL) {
00221     _color = InternalName::make("color");
00222   }
00223   return _color;
00224 }
00225 
00226 ////////////////////////////////////////////////////////////////////
00227 //     Function: InternalName::get_rotate
00228 //       Access: Published, Static
00229 //  Description: Returns the standard InternalName "rotate".  This is
00230 //               the column header for the floating-point rotate
00231 //               value, which represents a number of degrees
00232 //               counter-clockwise to rotate each point or point
00233 //               sprite.
00234 ////////////////////////////////////////////////////////////////////
00235 INLINE PT(InternalName) InternalName::
00236 get_rotate() {
00237   if (_rotate == (InternalName *)NULL) {
00238     _rotate = InternalName::make("rotate");
00239   }
00240   return _rotate;
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: InternalName::get_size
00245 //       Access: Published, Static
00246 //  Description: Returns the standard InternalName "size".  This is
00247 //               the column header for the floating-point size value,
00248 //               which overrides the thickness parameter of the
00249 //               RenderModeAttrib on a per-vertex (e.g. per-point)
00250 //               basis.
00251 ////////////////////////////////////////////////////////////////////
00252 INLINE PT(InternalName) InternalName::
00253 get_size() {
00254   if (_size == (InternalName *)NULL) {
00255     _size = InternalName::make("size");
00256   }
00257   return _size;
00258 }
00259 
00260 ////////////////////////////////////////////////////////////////////
00261 //     Function: InternalName::get_aspect_ratio
00262 //       Access: Published, Static
00263 //  Description: Returns the standard InternalName "aspect_ratio".
00264 //               This is the column header for the floating-point
00265 //               aspect ratio value, which is used to define
00266 //               non-square points.  This number is the ratio x / y,
00267 //               where y is the point size (above).
00268 ////////////////////////////////////////////////////////////////////
00269 INLINE PT(InternalName) InternalName::
00270 get_aspect_ratio() {
00271   if (_aspect_ratio == (InternalName *)NULL) {
00272     _aspect_ratio = InternalName::make("aspect_ratio");
00273   }
00274   return _aspect_ratio;
00275 }
00276 
00277 ////////////////////////////////////////////////////////////////////
00278 //     Function: InternalName::get_transform_blend
00279 //       Access: Published, Static
00280 //  Description: Returns the standard InternalName "transform_blend".
00281 //               This is the column header for the integer
00282 //               transform_blend index, which is used to define vertex
00283 //               animation on the CPU by indexing to a particular
00284 //               vertex weighting from the TransformBlendTable.
00285 ////////////////////////////////////////////////////////////////////
00286 INLINE PT(InternalName) InternalName::
00287 get_transform_blend() {
00288   if (_transform_blend == (InternalName *)NULL) {
00289     _transform_blend = InternalName::make("transform_blend");
00290   }
00291   return _transform_blend;
00292 }
00293 
00294 ////////////////////////////////////////////////////////////////////
00295 //     Function: InternalName::get_transform_weight
00296 //       Access: Published, Static
00297 //  Description: Returns the standard InternalName "transform_weight".
00298 //               This is the column header for the n-component
00299 //               transform_weight value, which is used in conjuntion
00300 //               with "transform_index" to define vertex animation on
00301 //               the graphics card.  The transform_weight value
00302 //               specifies the weight of the nth transform.  By
00303 //               convention, there are 1 fewer weight values than
00304 //               transforms, since the weights are assumed to sum to 1
00305 //               (and the last value is therefore implicit).
00306 ////////////////////////////////////////////////////////////////////
00307 INLINE PT(InternalName) InternalName::
00308 get_transform_weight() {
00309   if (_transform_weight == (InternalName *)NULL) {
00310     _transform_weight = InternalName::make("transform_weight");
00311   }
00312   return _transform_weight;
00313 }
00314 
00315 ////////////////////////////////////////////////////////////////////
00316 //     Function: InternalName::get_transform_index
00317 //       Access: Published, Static
00318 //  Description: Returns the standard InternalName "transform_index".
00319 //               This is the column header for the n-component
00320 //               transform_index value, which is used in conjuntion
00321 //               with "transform_weight" to define vertex animation on
00322 //               the graphics card.  The transform_index value
00323 //               specifies the nth transform, by lookup in the
00324 //               TransformTable.  The transform_index column may be
00325 //               omitted, in which case the nth transform is the nth
00326 //               entry in the table.
00327 ////////////////////////////////////////////////////////////////////
00328 INLINE PT(InternalName) InternalName::
00329 get_transform_index() {
00330   if (_transform_index == (InternalName *)NULL) {
00331     _transform_index = InternalName::make("transform_index");
00332   }
00333   return _transform_index;
00334 }
00335 
00336 ////////////////////////////////////////////////////////////////////
00337 //     Function: InternalName::get_morph
00338 //       Access: Published, Static
00339 //  Description: Returns an InternalName derived from the given base
00340 //               column name and the given slider name, which is the
00341 //               column header for the offset vector that should be
00342 //               applied to the base column name when the named morph
00343 //               slider is engaged.
00344 //
00345 //               Each morph slider requires a set of n morph columns,
00346 //               one for each base column it applies to.
00347 ////////////////////////////////////////////////////////////////////
00348 INLINE PT(InternalName) InternalName::
00349 get_morph(InternalName *column, const string &slider) {
00350   // This actually returns "column.morph.slider", although that's just
00351   // an implementation detail--as long as it returns a consistent,
00352   // unique name for each combination of column and slider, everything
00353   // is good.
00354   return column->append("morph")->append(slider);
00355 }
00356 
00357 ////////////////////////////////////////////////////////////////////
00358 //     Function: InternalName::get_index
00359 //       Access: Published, Static
00360 //  Description: Returns the standard InternalName "index".  This is
00361 //               the column header for the integer vertex index.  It
00362 //               is not used in the vertex data itself, but is used in
00363 //               the GeomPrimitive structure to index into the vertex
00364 //               data.
00365 ////////////////////////////////////////////////////////////////////
00366 INLINE PT(InternalName) InternalName::
00367 get_index() {
00368   if (_index == (InternalName *)NULL) {
00369     _index = InternalName::make("index");
00370   }
00371   return _index;
00372 }
00373 
00374 ////////////////////////////////////////////////////////////////////
00375 //     Function: InternalName::get_world
00376 //       Access: Published, Static
00377 //  Description: Returns the standard InternalName "world".  This is
00378 //               used as a keyword in the shader subsystem.
00379 ////////////////////////////////////////////////////////////////////
00380 INLINE PT(InternalName) InternalName::
00381 get_world() {
00382   if (_world == (InternalName *)NULL) {
00383     _world = InternalName::make("world");
00384   }
00385   return _world;
00386 }
00387 
00388 ////////////////////////////////////////////////////////////////////
00389 //     Function: InternalName::get_camera
00390 //       Access: Published, Static
00391 //  Description: Returns the standard InternalName "camera".  This is
00392 //               used as a keyword in the shader subsystem.
00393 ////////////////////////////////////////////////////////////////////
00394 INLINE PT(InternalName) InternalName::
00395 get_camera() {
00396   if (_camera == (InternalName *)NULL) {
00397     _camera = InternalName::make("camera");
00398   }
00399   return _camera;
00400 }
00401 
00402 ////////////////////////////////////////////////////////////////////
00403 //     Function: InternalName::get_model
00404 //       Access: Published, Static
00405 //  Description: Returns the standard InternalName "model".  This is
00406 //               used as a keyword in the shader subsystem.
00407 ////////////////////////////////////////////////////////////////////
00408 INLINE PT(InternalName) InternalName::
00409 get_model() {
00410   if (_model == (InternalName *)NULL) {
00411     _model = InternalName::make("model");
00412   }
00413   return _model;
00414 }
00415 
00416 ////////////////////////////////////////////////////////////////////
00417 //     Function: InternalName::get_view
00418 //       Access: Published, Static
00419 //  Description: Returns the standard InternalName "view".  This is
00420 //               used as a keyword in the shader subsystem.
00421 ////////////////////////////////////////////////////////////////////
00422 INLINE PT(InternalName) InternalName::
00423 get_view() {
00424   if (_view == (InternalName *)NULL) {
00425     _view = InternalName::make("view");
00426   }
00427   return _view;
00428 }
00429 
00430 ////////////////////////////////////////////////////////////////////
00431 //     Function: InternalName::output operator
00432 //       Access: Public
00433 //  Description: 
00434 ////////////////////////////////////////////////////////////////////
00435 INLINE ostream &
00436 operator << (ostream &out, const InternalName &tcn) {
00437   tcn.output(out);
00438   return out;
00439 }
 All Classes Functions Variables Enumerations