Panda3D
nurbsVertex.cxx
1 // Filename: nurbsVertex.cxx
2 // Created by: drose (04Dec02)
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 #include "nurbsVertex.h"
16 
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: NurbsVertex::set_extended_vertex
20 // Access: Public
21 // Description: Sets an n-dimensional vertex value. This allows
22 // definition of a NURBS surface or curve in a sparse
23 // n-dimensional space, typically used for associating
24 // additional properties (like color or joint
25 // membership) with each vertex of a surface.
26 //
27 // The value d is an arbitrary integer value and
28 // specifies the dimension of question for this
29 // particular vertex. Any number of dimensions may be
30 // specified, and they need not be consecutive. If a
31 // value for a given dimension is not specified, is it
32 // implicitly 0.0.
33 //
34 // The value is implicitly scaled by the homogenous
35 // weight value--that is, the fourth component of the
36 // value passed to set_vertex(). This means the
37 // ordinary vertex must be set first, before the
38 // extended vertices can be set.
39 ////////////////////////////////////////////////////////////////////
40 void NurbsVertex::
41 set_extended_vertex(int d, PN_stdfloat value) {
42  _extended[d] = value * _vertex[3];
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: NurbsVertex::get_extended_vertex
47 // Access: Public
48 // Description: Returns an n-dimensional vertex value. See
49 // set_extended_vertex(). This returns the value set
50 // for the indicated dimension, or 0.0 if nothing has
51 // been set.
52 ////////////////////////////////////////////////////////////////////
53 PN_stdfloat NurbsVertex::
54 get_extended_vertex(int d) const {
55  Extended::const_iterator ei;
56  ei = _extended.find(d);
57  if (ei == _extended.end()) {
58  return 0.0f;
59  }
60  return (*ei).second;
61 }
PN_stdfloat get_extended_vertex(int d) const
Returns an n-dimensional vertex value.
Definition: nurbsVertex.cxx:54
void set_extended_vertex(int d, PN_stdfloat value)
Sets an n-dimensional vertex value.
Definition: nurbsVertex.cxx:41