texGenAttrib.I 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // Filename: texGenAttrib.I
  2. // Created by: masad (21Jun04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: TexGenAttrib::Constructor
  20. // Access: Protected
  21. // Description: Use TexGenAttrib::make() to construct a new
  22. // TexGenAttrib object.
  23. ////////////////////////////////////////////////////////////////////
  24. INLINE TexGenAttrib::
  25. TexGenAttrib() :
  26. _num_point_sprites(0),
  27. _num_light_vectors(0),
  28. _point_geom_rendering(0),
  29. _geom_rendering(0)
  30. {
  31. }
  32. ////////////////////////////////////////////////////////////////////
  33. // Function: TexGenAttrib::Copy Constructor
  34. // Access: Protected
  35. // Description: Use TexGenAttrib::make() to construct a new
  36. // TexGenAttrib object.
  37. ////////////////////////////////////////////////////////////////////
  38. INLINE TexGenAttrib::
  39. TexGenAttrib(const TexGenAttrib &copy) :
  40. _stages(copy._stages),
  41. _no_texcoords(copy._no_texcoords),
  42. _num_point_sprites(copy._num_point_sprites),
  43. _num_light_vectors(copy._num_light_vectors),
  44. _point_geom_rendering(copy._point_geom_rendering),
  45. _geom_rendering(copy._geom_rendering)
  46. {
  47. }
  48. ////////////////////////////////////////////////////////////////////
  49. // Function: TexGenAttrib::get_geom_rendering
  50. // Access: Published
  51. // Description: Returns the union of the Geom::GeomRendering bits
  52. // that will be required once this TexGenAttrib is
  53. // applied to a geom which includes the indicated
  54. // geom_rendering bits.
  55. ////////////////////////////////////////////////////////////////////
  56. INLINE int TexGenAttrib::
  57. get_geom_rendering(int geom_rendering) const {
  58. if ((geom_rendering & Geom::GR_point) != 0) {
  59. geom_rendering |= _point_geom_rendering;
  60. }
  61. return geom_rendering | _geom_rendering;
  62. }
  63. ////////////////////////////////////////////////////////////////////
  64. // Function: TexGenAttrib::get_no_texcoords
  65. // Access: Public
  66. // Description: Returns the set of TextureStages that have texture
  67. // coordinates computed for them, and hence do not need
  68. // to have texture coordinates sent from the Geom. This
  69. // is, of course, the set of TextureStages that is
  70. // listed in the attrib (except for those listed with M_off).
  71. ////////////////////////////////////////////////////////////////////
  72. INLINE const Geom::NoTexCoordStages &TexGenAttrib::
  73. get_no_texcoords() const {
  74. return _no_texcoords;
  75. }
  76. ////////////////////////////////////////////////////////////////////
  77. // Function: TexGenAttrib::get_light_vectors
  78. // Access: Public
  79. // Description: Returns the set of TextureStages that have
  80. // M_light_vector in effect, as well as the associated
  81. // Lights.
  82. ////////////////////////////////////////////////////////////////////
  83. INLINE const TexGenAttrib::LightVectors &TexGenAttrib::
  84. get_light_vectors() const {
  85. return _light_vectors;
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: TexGenAttrib::ModeDef::Constructor
  89. // Access: Public
  90. // Description:
  91. ////////////////////////////////////////////////////////////////////
  92. INLINE TexGenAttrib::ModeDef::
  93. ModeDef() :
  94. _mode(M_off)
  95. {
  96. }
  97. ////////////////////////////////////////////////////////////////////
  98. // Function: TexGenAttrib::ModeDef::compare_to
  99. // Access: Public
  100. // Description:
  101. ////////////////////////////////////////////////////////////////////
  102. INLINE int TexGenAttrib::ModeDef::
  103. compare_to(const TexGenAttrib::ModeDef &other) const {
  104. if (_mode != other._mode) {
  105. return (int)_mode < (int)other._mode ? -1 : 1;
  106. }
  107. int compare = _light.compare_to(other._light);
  108. if (compare != 0) {
  109. return compare;
  110. }
  111. return strcmp(_source_name.c_str(), other._source_name.c_str());
  112. }