Panda3D
fltGeometry.I
1 // Filename: fltGeometry.I
2 // Created by: drose (28Feb01)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: FltGeometry::has_texture
18 // Access: Public
19 // Description: Returns true if the face has a texture applied, false
20 // otherwise.
21 ////////////////////////////////////////////////////////////////////
22 INLINE bool FltGeometry::
23 has_texture() const {
24  return (_texture_index >= 0 && _header->has_texture(_texture_index));
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: FltGeometry::get_texture
29 // Access: Public
30 // Description: Returns the texture applied to this face, or NULL if
31 // no texture was applied.
32 ////////////////////////////////////////////////////////////////////
34 get_texture() const {
35  return _header->get_texture(_texture_index);
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: FltGeometry::set_texture
40 // Access: Public
41 // Description: Applies the indicated texture to this face, or if the
42 // texture is NULL, clears it.
43 ////////////////////////////////////////////////////////////////////
44 INLINE void FltGeometry::
46  if (texture == (FltTexture *)NULL) {
47  _texture_index = -1;
48  } else {
49  _header->add_texture(texture);
50  _texture_index = texture->_pattern_index;
51  }
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: FltGeometry::has_material
56 // Access: Public
57 // Description: Returns true if the face has a material applied, false
58 // otherwise.
59 ////////////////////////////////////////////////////////////////////
60 INLINE bool FltGeometry::
61 has_material() const {
62  return (_material_index >= 0 && _header->has_material(_material_index));
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: FltGeometry::get_material
67 // Access: Public
68 // Description: Returns the material applied to this face, or NULL if
69 // no material was applied.
70 ////////////////////////////////////////////////////////////////////
72 get_material() const {
73  return _header->get_material(_material_index);
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: FltGeometry::set_material
78 // Access: Public
79 // Description: Applies the indicated material to this face, or if the
80 // material is NULL, clears it.
81 ////////////////////////////////////////////////////////////////////
82 INLINE void FltGeometry::
84  if (material == (FltMaterial *)NULL) {
85  _material_index = -1;
86  } else {
87  _header->add_material(material);
88  _material_index = material->_material_index;
89  }
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: FltGeometry::has_color
94 // Access: Public
95 // Description: Returns true if the face has a primary color
96 // indicated, false otherwise.
97 ////////////////////////////////////////////////////////////////////
98 INLINE bool FltGeometry::
99 has_color() const {
100  // Even if the no_color bit is not set, if the color_index is -1,
101  // the face doesn't have a color (unless we've got packed color).
102  // On the other hand, if we have a material than we always have
103  // color.
104  return ((_flags & F_no_color) == 0 &&
105  (_color_index != -1 || ((_flags & F_packed_color) != 0)))
106  || has_material();
107 }
Represents a single material in the material palette.
Definition: fltMaterial.h:30
FltMaterial * get_material() const
Returns the material applied to this face, or NULL if no material was applied.
Definition: fltGeometry.I:72
bool has_material() const
Returns true if the face has a material applied, false otherwise.
Definition: fltGeometry.I:61
bool has_color() const
Returns true if the face has a primary color indicated, false otherwise.
Definition: fltGeometry.I:99
void set_material(FltMaterial *material)
Applies the indicated material to this face, or if the material is NULL, clears it.
Definition: fltGeometry.I:83
Represents a single texture in the texture palette.
Definition: fltTexture.h:29
bool has_texture() const
Returns true if the face has a texture applied, false otherwise.
Definition: fltGeometry.I:23
void set_texture(FltTexture *texture)
Applies the indicated texture to this face, or if the texture is NULL, clears it. ...
Definition: fltGeometry.I:45
FltTexture * get_texture() const
Returns the texture applied to this face, or NULL if no texture was applied.
Definition: fltGeometry.I:34