00001 // Filename: nurbsVertex.cxx 00002 // Created by: drose (04Dec02) 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 #include "nurbsVertex.h" 00016 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: NurbsVertex::set_extended_vertex 00020 // Access: Public 00021 // Description: Sets an n-dimensional vertex value. This allows 00022 // definition of a NURBS surface or curve in a sparse 00023 // n-dimensional space, typically used for associating 00024 // additional properties (like color or joint 00025 // membership) with each vertex of a surface. 00026 // 00027 // The value d is an arbitrary integer value and 00028 // specifies the dimension of question for this 00029 // particular vertex. Any number of dimensions may be 00030 // specified, and they need not be consecutive. If a 00031 // value for a given dimension is not specified, is it 00032 // implicitly 0.0. 00033 // 00034 // The value is implicitly scaled by the homogenous 00035 // weight value--that is, the fourth component of the 00036 // value passed to set_vertex(). This means the 00037 // ordinary vertex must be set first, before the 00038 // extended vertices can be set. 00039 //////////////////////////////////////////////////////////////////// 00040 void NurbsVertex:: 00041 set_extended_vertex(int d, PN_stdfloat value) { 00042 _extended[d] = value * _vertex[3]; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: NurbsVertex::get_extended_vertex 00047 // Access: Public 00048 // Description: Returns an n-dimensional vertex value. See 00049 // set_extended_vertex(). This returns the value set 00050 // for the indicated dimension, or 0.0 if nothing has 00051 // been set. 00052 //////////////////////////////////////////////////////////////////// 00053 PN_stdfloat NurbsVertex:: 00054 get_extended_vertex(int d) const { 00055 Extended::const_iterator ei; 00056 ei = _extended.find(d); 00057 if (ei == _extended.end()) { 00058 return 0.0f; 00059 } 00060 return (*ei).second; 00061 }