builderVertex.I 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. // Filename: builderVertex.I
  2. // Created by: drose (18Sep97)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #include <notify.h>
  6. ////////////////////////////////////////////////////////////////////
  7. // Function: BuilderVertex::set_coord_value
  8. // Access: Public
  9. // Description: Reassigns the vertex coordinate, without knowing
  10. // whether the vertex is indexed or nonindexed. A
  11. // nonindexed vertex will look up the index in the array
  12. // and store the resulting value, while an indexed
  13. // vertex will just store the index number (which
  14. // assumes the array is the same one it's indexing on).
  15. ////////////////////////////////////////////////////////////////////
  16. INLINE void BuilderVertex::
  17. set_coord_value(const BuilderV *array, ushort index) {
  18. set_coord(array[index]);
  19. }
  20. ////////////////////////////////////////////////////////////////////
  21. // Function: BuilderVertex::set_normal_value
  22. // Access: Public
  23. // Description: Reassigns the vertex normal, without knowing whether
  24. // the vertex is indexed or nonindexed. A nonindexed
  25. // vertex will look up the index in the array and store
  26. // the resulting value, while an indexed vertex will
  27. // just store the index number (which assumes the array
  28. // is the same one it's indexing on).
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE void BuilderVertex::
  31. set_normal_value(const BuilderN *array, ushort index) {
  32. set_normal(array[index]);
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: BuilderVertex::set_texcoord_value
  36. // Access: Public
  37. // Description: Reassigns the vertex texture coordinate, without
  38. // knowing whether the vertex is indexed or nonindexed.
  39. // A nonindexed vertex will look up the index in the
  40. // array and store the resulting value, while an indexed
  41. // vertex will just store the index number (which
  42. // assumes the array is the same one it's indexing on).
  43. ////////////////////////////////////////////////////////////////////
  44. INLINE void BuilderVertex::
  45. set_texcoord_value(const BuilderTC *array, ushort index) {
  46. set_texcoord(array[index]);
  47. }
  48. ////////////////////////////////////////////////////////////////////
  49. // Function: BuilderVertex::set_color_value
  50. // Access: Public
  51. // Description: Reassigns the vertex color, without knowing whether
  52. // the vertex is indexed or nonindexed. A nonindexed
  53. // vertex will look up the index in the array and store
  54. // the resulting value, while an indexed vertex will
  55. // just store the index number (which assumes the array
  56. // is the same one it's indexing on).
  57. ////////////////////////////////////////////////////////////////////
  58. INLINE void BuilderVertex::
  59. set_color_value(const BuilderC *array, ushort index) {
  60. set_color(array[index]);
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: BuilderVertex::get_coord_value
  64. // Access: Public
  65. // Description: Returns the actual coordinate value of the vertex,
  66. // whether it is indexed or nonindexed. Normally, the
  67. // value returned by get_coord(), which will be either a
  68. // BuilderV or a ushort, is sufficient, but there are
  69. // occasional times when it is necessary to get the
  70. // actual location in space of the vertex position (for
  71. // instance, to subdivide a concave polygon).
  72. //
  73. // This function returns the actual coordinate value.
  74. // For a nonindexed vertex, its return value is the same
  75. // as get_coord(); for an indexed vertex, it looks up
  76. // the vertex's index in the bucket's coord array, and
  77. // returns that value.
  78. //
  79. // Note that this makes some perhaps unwarranted
  80. // assumptions about indexed geometry; specifically,
  81. // that its value is valid at creation time, and that it
  82. // won't change too drastically during runtime.
  83. ////////////////////////////////////////////////////////////////////
  84. INLINE BuilderV BuilderVertex::
  85. get_coord_value(const BuilderBucket &) const {
  86. return get_coord();
  87. }
  88. ////////////////////////////////////////////////////////////////////
  89. // Function: BuilderVertex::get_normal_value
  90. // Access: Public
  91. // Description: Returns the actual normal value of the vertex,
  92. // whether it is indexed or nonindexed. See
  93. // get_coord_value().
  94. ////////////////////////////////////////////////////////////////////
  95. INLINE BuilderN BuilderVertex::
  96. get_normal_value(const BuilderBucket &) const {
  97. return get_normal();
  98. }
  99. ////////////////////////////////////////////////////////////////////
  100. // Function: BuilderVertex::get_texcoord_value
  101. // Access: Public
  102. // Description: Returns the actual texture coordinate value of the
  103. // vertex, whether it is indexed or nonindexed. See
  104. // get_coord_value().
  105. ////////////////////////////////////////////////////////////////////
  106. INLINE BuilderTC BuilderVertex::
  107. get_texcoord_value(const BuilderBucket &) const {
  108. return get_texcoord();
  109. }
  110. ////////////////////////////////////////////////////////////////////
  111. // Function: BuilderVertex::get_color_value
  112. // Access: Public
  113. // Description: Returns the actual color value of the vertex,
  114. // whether it is indexed or nonindexed. See
  115. // get_coord_value().
  116. ////////////////////////////////////////////////////////////////////
  117. INLINE BuilderC BuilderVertex::
  118. get_color_value(const BuilderBucket &) const {
  119. return get_color();
  120. }
  121. ////////////////////////////////////////////////////////////////////
  122. // Function: BuilderVertex::set_coord_value
  123. // Access: Public
  124. // Description: Reassigns the vertex coordinate, without knowing
  125. // whether the vertex is indexed or nonindexed. A
  126. // nonindexed vertex will look up the index in the array
  127. // and store the resulting value, while an indexed
  128. // vertex will just store the index number (which
  129. // assumes the array is the same one it's indexing on).
  130. ////////////////////////////////////////////////////////////////////
  131. INLINE void BuilderVertexI::
  132. set_coord_value(const BuilderV *, ushort index) {
  133. set_coord(index);
  134. }
  135. ////////////////////////////////////////////////////////////////////
  136. // Function: BuilderVertex::set_normal_value
  137. // Access: Public
  138. // Description: Reassigns the vertex normal, without knowing whether
  139. // the vertex is indexed or nonindexed. A nonindexed
  140. // vertex will look up the index in the array and store
  141. // the resulting value, while an indexed vertex will
  142. // just store the index number (which assumes the array
  143. // is the same one it's indexing on).
  144. ////////////////////////////////////////////////////////////////////
  145. INLINE void BuilderVertexI::
  146. set_normal_value(const BuilderN *, ushort index) {
  147. set_normal(index);
  148. }
  149. ////////////////////////////////////////////////////////////////////
  150. // Function: BuilderVertex::set_texcoord_value
  151. // Access: Public
  152. // Description: Reassigns the vertex texture coordinate, without
  153. // knowing whether the vertex is indexed or nonindexed.
  154. // A nonindexed vertex will look up the index in the
  155. // array and store the resulting value, while an indexed
  156. // vertex will just store the index number (which
  157. // assumes the array is the same one it's indexing on).
  158. ////////////////////////////////////////////////////////////////////
  159. INLINE void BuilderVertexI::
  160. set_texcoord_value(const BuilderTC *, ushort index) {
  161. set_texcoord(index);
  162. }
  163. ////////////////////////////////////////////////////////////////////
  164. // Function: BuilderVertex::set_color_value
  165. // Access: Public
  166. // Description: Reassigns the vertex color, without knowing whether
  167. // the vertex is indexed or nonindexed. A nonindexed
  168. // vertex will look up the index in the array and store
  169. // the resulting value, while an indexed vertex will
  170. // just store the index number (which assumes the array
  171. // is the same one it's indexing on).
  172. ////////////////////////////////////////////////////////////////////
  173. INLINE void BuilderVertexI::
  174. set_color_value(const BuilderC *, ushort index) {
  175. set_color(index);
  176. }
  177. ////////////////////////////////////////////////////////////////////
  178. // Function: BuilderVertex::get_coord_value
  179. // Access: Public
  180. // Description: Returns the actual coordinate value of the vertex,
  181. // whether it is indexed or nonindexed. Normally, the
  182. // value returned by get_coord(), which will be either a
  183. // BuilderV or a ushort, is sufficient, but there are
  184. // occasional times when it is necessary to get the
  185. // actual location in space of the vertex position (for
  186. // instance, to subdivide a concave polygon).
  187. //
  188. // This function returns the actual coordinate value.
  189. // For a nonindexed vertex, its return value is the same
  190. // as get_coord(); for an indexed vertex, it looks up
  191. // the vertex's index in the bucket's coord array, and
  192. // returns that value.
  193. //
  194. // Note that this makes some perhaps unwarranted
  195. // assumptions about indexed geometry; specifically,
  196. // that its value is valid at creation time, and that it
  197. // won't change too drastically during runtime.
  198. ////////////////////////////////////////////////////////////////////
  199. INLINE BuilderV BuilderVertexI::
  200. get_coord_value(const BuilderBucket &bucket) const {
  201. nassertr(bucket.get_coords() != (Vertexf *)NULL, BuilderV());
  202. return bucket.get_coords()[get_coord()];
  203. }
  204. ////////////////////////////////////////////////////////////////////
  205. // Function: BuilderVertex::get_normal_value
  206. // Access: Public
  207. // Description: Returns the actual normal value of the vertex,
  208. // whether it is indexed or nonindexed. See
  209. // get_coord_value().
  210. ////////////////////////////////////////////////////////////////////
  211. INLINE BuilderN BuilderVertexI::
  212. get_normal_value(const BuilderBucket &bucket) const {
  213. nassertr(bucket.get_normals() != (Normalf *)NULL, BuilderN());
  214. return bucket.get_normals()[get_normal()];
  215. }
  216. ////////////////////////////////////////////////////////////////////
  217. // Function: BuilderVertex::get_texcoord_value
  218. // Access: Public
  219. // Description: Returns the actual texture coordinate value of the
  220. // vertex, whether it is indexed or nonindexed. See
  221. // get_coord_value().
  222. ////////////////////////////////////////////////////////////////////
  223. INLINE BuilderTC BuilderVertexI::
  224. get_texcoord_value(const BuilderBucket &bucket) const {
  225. nassertr(bucket.get_texcoords() != (TexCoordf *)NULL, BuilderTC());
  226. return bucket.get_texcoords()[get_texcoord()];
  227. }
  228. ////////////////////////////////////////////////////////////////////
  229. // Function: BuilderVertex::get_color_value
  230. // Access: Public
  231. // Description: Returns the actual color value of the vertex,
  232. // whether it is indexed or nonindexed. See
  233. // get_coord_value().
  234. ////////////////////////////////////////////////////////////////////
  235. INLINE BuilderC BuilderVertexI::
  236. get_color_value(const BuilderBucket &bucket) const {
  237. nassertr(bucket.get_colors() != (Colorf *)NULL, BuilderC());
  238. return bucket.get_colors()[get_color()];
  239. }