Panda3D
nurbsCurveInterface.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 nurbsCurveInterface.I
10  * @author drose
11  * @date 2001-03-02
12  */
13 
14 /**
15  *
16  */
17 INLINE int NurbsCurveInterface::
18 append_cv(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
19  return append_cv(LVecBase3(x, y, z));
20 }
21 
22 /**
23  *
24  */
25 INLINE int NurbsCurveInterface::
26 append_cv(const LVecBase3 &v) {
27  return append_cv(LVecBase4(v[0], v[1], v[2], 1.0f));
28 }
29 
30 /**
31  *
32  */
33 INLINE int NurbsCurveInterface::
34 append_cv(const LVecBase4 &v) {
35  return append_cv_impl(v);
36 }
37 
38 /**
39  * Repositions the indicated CV. Returns true if successful, false otherwise.
40  */
41 INLINE bool NurbsCurveInterface::
42 set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
43  return set_cv_point(n, LVecBase3(x, y, z));
44 }
45 
46 /**
47  * Repositions the indicated CV. Returns true if successful, false otherwise.
48  */
49 INLINE bool NurbsCurveInterface::
50 set_cv_point(int n, const LVecBase3 &v) {
51  nassertr(n >= 0 && n < get_num_cvs(), false);
52  return set_cv(n, LVecBase4(v[0], v[1], v[2], 1.0f) * get_cv_weight(n));
53 }
54 
55 /**
56  * Returns the position of the indicated CV.
57  */
58 INLINE LVecBase3 NurbsCurveInterface::
59 get_cv_point(int n) const {
60  nassertr(n >= 0 && n < get_num_cvs(), LVecBase3::zero());
61  LVecBase4 p = get_cv(n);
62  nassertr(p[3] != 0.0f, LVecBase3::zero());
63  return LVecBase3(p[0], p[1], p[2]) / p[3];
64 }
65 
66 /**
67  * Returns the weight of the indicated CV.
68  */
69 INLINE PN_stdfloat NurbsCurveInterface::
70 get_cv_weight(int n) const {
71  return get_cv(n)[3];
72 }
PN_stdfloat get_cv_weight(int n) const
Returns the weight of the indicated CV.
bool set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Repositions the indicated CV.
LVecBase3 get_cv_point(int n) const
Returns the position of the indicated CV.