sheetNode.I 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Filename: sheetNode.I
  2. // Created by: drose (11Oct03)
  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. // Function: SheetNode::CData::Constructor
  16. // Access: Public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE SheetNode::CData::
  20. CData() {
  21. _surface = new NurbsSurfaceEvaluator;
  22. _use_vertex_color = false;
  23. _num_u_subdiv = 2;
  24. _num_v_subdiv = 2;
  25. }
  26. ////////////////////////////////////////////////////////////////////
  27. // Function: SheetNode::CData::Copy Constructor
  28. // Access: Public
  29. // Description:
  30. ////////////////////////////////////////////////////////////////////
  31. INLINE SheetNode::CData::
  32. CData(const SheetNode::CData &copy) :
  33. _surface(copy._surface),
  34. _use_vertex_color(copy._use_vertex_color),
  35. _num_u_subdiv(copy._num_u_subdiv),
  36. _num_v_subdiv(copy._num_v_subdiv)
  37. {
  38. }
  39. ////////////////////////////////////////////////////////////////////
  40. // Function: set_surface
  41. // Access: Public
  42. // Description: Sets the particular surface represented by the
  43. // SheetNode.
  44. ////////////////////////////////////////////////////////////////////
  45. INLINE void SheetNode::
  46. set_surface(NurbsSurfaceEvaluator *surface) {
  47. CDWriter cdata(_cycler);
  48. cdata->_surface = surface;
  49. }
  50. ////////////////////////////////////////////////////////////////////
  51. // Function: get_surface
  52. // Access: Public
  53. // Description: Returns the surface represented by the SheetNode.
  54. ////////////////////////////////////////////////////////////////////
  55. INLINE NurbsSurfaceEvaluator *SheetNode::
  56. get_surface() const {
  57. CDReader cdata(_cycler);
  58. return cdata->_surface;
  59. }
  60. ////////////////////////////////////////////////////////////////////
  61. // Function: set_use_vertex_color
  62. // Access: Public
  63. // Description: Sets the "use vertex color" flag. When this is true,
  64. // the R, G, B, A vertex color is assumed to be stored
  65. // as the dimensions 0, 1, 2, 3, respectively, of the
  66. // extended vertex values. Use
  67. // NurbsCurveEvaluator::set_extended_vertex() to set
  68. // these values.
  69. ////////////////////////////////////////////////////////////////////
  70. INLINE void SheetNode::
  71. set_use_vertex_color(bool flag) {
  72. CDWriter cdata(_cycler);
  73. cdata->_use_vertex_color = flag;
  74. }
  75. ////////////////////////////////////////////////////////////////////
  76. // Function: get_use_vertex_color
  77. // Access: Public
  78. // Description: Returns the "use vertex color" flag. See
  79. // set_use_vertex_color().
  80. ////////////////////////////////////////////////////////////////////
  81. INLINE bool SheetNode::
  82. get_use_vertex_color() const {
  83. CDReader cdata(_cycler);
  84. return cdata->_use_vertex_color;
  85. }
  86. ////////////////////////////////////////////////////////////////////
  87. // Function: set_num_u_subdiv
  88. // Access: Public
  89. // Description: Specifies the number of subdivisions per cubic
  90. // segment (that is, per unique knot value) to draw in a
  91. // fixed uniform tesselation of the surface in the U
  92. // direction.
  93. ////////////////////////////////////////////////////////////////////
  94. INLINE void SheetNode::
  95. set_num_u_subdiv(int num_u_subdiv) {
  96. nassertv(num_u_subdiv >= 0);
  97. CDWriter cdata(_cycler);
  98. cdata->_num_u_subdiv = num_u_subdiv;
  99. }
  100. ////////////////////////////////////////////////////////////////////
  101. // Function: get_num_u_subdiv
  102. // Access: Public
  103. // Description: Returns the number of subdivisions per cubic segment
  104. // to draw in the U direction. See set_num_u_subdiv().
  105. ////////////////////////////////////////////////////////////////////
  106. INLINE int SheetNode::
  107. get_num_u_subdiv() const {
  108. CDReader cdata(_cycler);
  109. return cdata->_num_u_subdiv;
  110. }
  111. ////////////////////////////////////////////////////////////////////
  112. // Function: set_num_v_subdiv
  113. // Access: Public
  114. // Description: Specifies the number of subdivisions per cubic
  115. // segment (that is, per unique knot value) to draw in a
  116. // fixed uniform tesselation of the surface in the V
  117. // direction.
  118. ////////////////////////////////////////////////////////////////////
  119. INLINE void SheetNode::
  120. set_num_v_subdiv(int num_v_subdiv) {
  121. nassertv(num_v_subdiv >= 0);
  122. CDWriter cdata(_cycler);
  123. cdata->_num_v_subdiv = num_v_subdiv;
  124. }
  125. ////////////////////////////////////////////////////////////////////
  126. // Function: get_num_v_subdiv
  127. // Access: Public
  128. // Description: Returns the number of subdivisions per cubic segment
  129. // to draw in the V direction. See set_num_v_subdiv().
  130. ////////////////////////////////////////////////////////////////////
  131. INLINE int SheetNode::
  132. get_num_v_subdiv() const {
  133. CDReader cdata(_cycler);
  134. return cdata->_num_v_subdiv;
  135. }