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