Panda3D
|
00001 // Filename: fltGeometry.I 00002 // Created by: drose (28Feb01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: FltGeometry::has_texture 00018 // Access: Public 00019 // Description: Returns true if the face has a texture applied, false 00020 // otherwise. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE bool FltGeometry:: 00023 has_texture() const { 00024 return (_texture_index >= 0 && _header->has_texture(_texture_index)); 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: FltGeometry::get_texture 00029 // Access: Public 00030 // Description: Returns the texture applied to this face, or NULL if 00031 // no texture was applied. 00032 //////////////////////////////////////////////////////////////////// 00033 INLINE FltTexture *FltGeometry:: 00034 get_texture() const { 00035 return _header->get_texture(_texture_index); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: FltGeometry::set_texture 00040 // Access: Public 00041 // Description: Applies the indicated texture to this face, or if the 00042 // texture is NULL, clears it. 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE void FltGeometry:: 00045 set_texture(FltTexture *texture) { 00046 if (texture == (FltTexture *)NULL) { 00047 _texture_index = -1; 00048 } else { 00049 _header->add_texture(texture); 00050 _texture_index = texture->_pattern_index; 00051 } 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function: FltGeometry::has_material 00056 // Access: Public 00057 // Description: Returns true if the face has a material applied, false 00058 // otherwise. 00059 //////////////////////////////////////////////////////////////////// 00060 INLINE bool FltGeometry:: 00061 has_material() const { 00062 return (_material_index >= 0 && _header->has_material(_material_index)); 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: FltGeometry::get_material 00067 // Access: Public 00068 // Description: Returns the material applied to this face, or NULL if 00069 // no material was applied. 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE FltMaterial *FltGeometry:: 00072 get_material() const { 00073 return _header->get_material(_material_index); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: FltGeometry::set_material 00078 // Access: Public 00079 // Description: Applies the indicated material to this face, or if the 00080 // material is NULL, clears it. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE void FltGeometry:: 00083 set_material(FltMaterial *material) { 00084 if (material == (FltMaterial *)NULL) { 00085 _material_index = -1; 00086 } else { 00087 _header->add_material(material); 00088 _material_index = material->_material_index; 00089 } 00090 } 00091 00092 //////////////////////////////////////////////////////////////////// 00093 // Function: FltGeometry::has_color 00094 // Access: Public 00095 // Description: Returns true if the face has a primary color 00096 // indicated, false otherwise. 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE bool FltGeometry:: 00099 has_color() const { 00100 // Even if the no_color bit is not set, if the color_index is -1, 00101 // the face doesn't have a color (unless we've got packed color). 00102 // On the other hand, if we have a material than we always have 00103 // color. 00104 return ((_flags & F_no_color) == 0 && 00105 (_color_index != -1 || ((_flags & F_packed_color) != 0))) 00106 || has_material(); 00107 }