fltGeometry.I 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 fltGeometry.I
  10. * @author drose
  11. * @date 2001-02-28
  12. */
  13. /**
  14. * Returns true if the face has a texture applied, false otherwise.
  15. */
  16. INLINE bool FltGeometry::
  17. has_texture() const {
  18. return (_texture_index >= 0 && _header->has_texture(_texture_index));
  19. }
  20. /**
  21. * Returns the texture applied to this face, or NULL if no texture was
  22. * applied.
  23. */
  24. INLINE FltTexture *FltGeometry::
  25. get_texture() const {
  26. return _header->get_texture(_texture_index);
  27. }
  28. /**
  29. * Applies the indicated texture to this face, or if the texture is NULL,
  30. * clears it.
  31. */
  32. INLINE void FltGeometry::
  33. set_texture(FltTexture *texture) {
  34. if (texture == nullptr) {
  35. _texture_index = -1;
  36. } else {
  37. _header->add_texture(texture);
  38. _texture_index = texture->_pattern_index;
  39. }
  40. }
  41. /**
  42. * Returns true if the face has a material applied, false otherwise.
  43. */
  44. INLINE bool FltGeometry::
  45. has_material() const {
  46. return (_material_index >= 0 && _header->has_material(_material_index));
  47. }
  48. /**
  49. * Returns the material applied to this face, or NULL if no material was
  50. * applied.
  51. */
  52. INLINE FltMaterial *FltGeometry::
  53. get_material() const {
  54. return _header->get_material(_material_index);
  55. }
  56. /**
  57. * Applies the indicated material to this face, or if the material is NULL,
  58. * clears it.
  59. */
  60. INLINE void FltGeometry::
  61. set_material(FltMaterial *material) {
  62. if (material == nullptr) {
  63. _material_index = -1;
  64. } else {
  65. _header->add_material(material);
  66. _material_index = material->_material_index;
  67. }
  68. }
  69. /**
  70. * Returns true if the face has a primary color indicated, false otherwise.
  71. */
  72. INLINE bool FltGeometry::
  73. has_color() const {
  74. // Even if the no_color bit is not set, if the color_index is -1, the face
  75. // doesn't have a color (unless we've got packed color). On the other hand,
  76. // if we have a material than we always have color.
  77. return ((_flags & F_no_color) == 0 &&
  78. (_color_index != -1 || ((_flags & F_packed_color) != 0)))
  79. || has_material();
  80. }