Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg/eggTexture.I

Go to the documentation of this file.
00001 // Filename: eggTexture.I
00002 // Created by:  drose (18Jan99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: EggTexture::set_format
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE void EggTexture::
00026 set_format(Format format) {
00027   _format = format;
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: EggTexture::get_format
00032 //       Access: Public
00033 //  Description:
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE EggTexture::Format EggTexture::
00036 get_format() const {
00037   return _format;
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: EggTexture::set_wrap_mode
00042 //       Access: Public
00043 //  Description:
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE void EggTexture::
00046 set_wrap_mode(WrapMode mode) {
00047   _wrap_mode = mode;
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: EggTexture::get_wrap_mode
00052 //       Access: Public
00053 //  Description:
00054 ////////////////////////////////////////////////////////////////////
00055 INLINE EggTexture::WrapMode EggTexture::
00056 get_wrap_mode() const {
00057   return _wrap_mode;
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: EggTexture::set_wrap_u
00062 //       Access: Public
00063 //  Description:
00064 ////////////////////////////////////////////////////////////////////
00065 INLINE void EggTexture::
00066 set_wrap_u(WrapMode mode) {
00067   _wrap_u = mode;
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: EggTexture::get_wrap_u
00072 //       Access: Public
00073 //  Description: Returns the amount specified for U wrap.  This may be
00074 //               unspecified, even if there is an overall wrap value.
00075 ////////////////////////////////////////////////////////////////////
00076 INLINE EggTexture::WrapMode EggTexture::
00077 get_wrap_u() const {
00078   return _wrap_u;
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: EggTexture::determine_wrap_u
00083 //       Access: Public
00084 //  Description: Determines the appropriate wrap in the U direction.
00085 //               This is different from get_wrap_u() in that if the U
00086 //               wrap is unspecified, it returns the overall wrap
00087 //               value.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE EggTexture::WrapMode EggTexture::
00090 determine_wrap_u() const {
00091   return (_wrap_u == WM_unspecified) ? get_wrap_mode() : get_wrap_u();
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: EggTexture::set_wrap_v
00096 //       Access: Public
00097 //  Description:
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE void EggTexture::
00100 set_wrap_v(WrapMode mode) {
00101   _wrap_v = mode;
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: EggTexture::get_wrap_v
00106 //       Access: Public
00107 //  Description: Returns the amount specified for V wrap.  This may be
00108 //               unspecified, even if there is an overall wrap value.
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE EggTexture::WrapMode EggTexture::
00111 get_wrap_v() const {
00112   return _wrap_v;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: EggTexture::determine_wrap_v
00117 //       Access: Public
00118 //  Description: Determines the appropriate wrap in the V direction.
00119 //               This is different from get_wrap_v() in that if the U
00120 //               wrap is unspecified, it returns the overall wrap
00121 //               value.
00122 ////////////////////////////////////////////////////////////////////
00123 INLINE EggTexture::WrapMode EggTexture::
00124 determine_wrap_v() const {
00125   return (_wrap_v == WM_unspecified) ? get_wrap_mode() : get_wrap_v();
00126 }
00127 
00128 ////////////////////////////////////////////////////////////////////
00129 //     Function: EggTexture::set_minfilter
00130 //       Access: Public
00131 //  Description:
00132 ////////////////////////////////////////////////////////////////////
00133 INLINE void EggTexture::
00134 set_minfilter(FilterType type) {
00135   _minfilter = type;
00136 }
00137 
00138 ////////////////////////////////////////////////////////////////////
00139 //     Function: EggTexture::get_minfilter
00140 //       Access: Public
00141 //  Description:
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE EggTexture::FilterType EggTexture::
00144 get_minfilter() const {
00145   return _minfilter;
00146 }
00147 
00148 ////////////////////////////////////////////////////////////////////
00149 //     Function: EggTexture::set_magfilter
00150 //       Access: Public
00151 //  Description:
00152 ////////////////////////////////////////////////////////////////////
00153 INLINE void EggTexture::
00154 set_magfilter(FilterType type) {
00155   _magfilter = type;
00156 }
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: EggTexture::get_magfilter
00160 //       Access: Public
00161 //  Description:
00162 ////////////////////////////////////////////////////////////////////
00163 INLINE EggTexture::FilterType EggTexture::
00164 get_magfilter() const {
00165   return _magfilter;
00166 }
00167 
00168 ////////////////////////////////////////////////////////////////////
00169 //     Function: EggTexture::set_anisotropic_degree
00170 //       Access: Public
00171 //  Description: Sets the degree of anisotropic filtering for this
00172 //               texture.  1 is off; higher levels indicate filtering
00173 //               in effect.
00174 ////////////////////////////////////////////////////////////////////
00175 INLINE void EggTexture::
00176 set_anisotropic_degree(int anisotropic_degree) {
00177   _anisotropic_degree = anisotropic_degree;
00178   _flags |= F_has_anisotropic_degree;
00179 }
00180 
00181 ////////////////////////////////////////////////////////////////////
00182 //     Function: EggTexture::clear_anisotropic_degree
00183 //       Access: Public
00184 //  Description: Removes the specification of anisotropic filtering
00185 //               from the texture.
00186 ////////////////////////////////////////////////////////////////////
00187 INLINE void EggTexture::
00188 clear_anisotropic_degree() {
00189   _anisotropic_degree = 0;
00190   _flags &= ~F_has_anisotropic_degree;
00191 }
00192 
00193 ////////////////////////////////////////////////////////////////////
00194 //     Function: EggTexture::has_anisotropic_degree
00195 //       Access: Public
00196 //  Description: Returns true if a value for the anisotropic filtering
00197 //               degree has been specified for this texture, false
00198 //               otherwise.
00199 ////////////////////////////////////////////////////////////////////
00200 INLINE bool EggTexture::
00201 has_anisotropic_degree() const {
00202   return (_flags & F_has_anisotropic_degree) != 0;
00203 }
00204 
00205 ////////////////////////////////////////////////////////////////////
00206 //     Function: EggTexture::get_anisotropic_degree
00207 //       Access: Public
00208 //  Description: Returns the anisotropic filtering degree that has
00209 //               been specified for this texture, or 0 if nothing has
00210 //               been specified.
00211 ////////////////////////////////////////////////////////////////////
00212 INLINE int EggTexture::
00213 get_anisotropic_degree() const {
00214   // note: _anisotropic_degree of 0 and 1 are equivalent (no
00215   // anisotropic filtering to be done by gsg)
00216   return _anisotropic_degree;
00217 }
00218 
00219 ////////////////////////////////////////////////////////////////////
00220 //     Function: EggTexture::set_env_type
00221 //       Access: Public
00222 //  Description:
00223 ////////////////////////////////////////////////////////////////////
00224 INLINE void EggTexture::
00225 set_env_type(EnvType type) {
00226   _env_type = type;
00227 }
00228 
00229 ////////////////////////////////////////////////////////////////////
00230 //     Function: EggTexture::get_env_type
00231 //       Access: Public
00232 //  Description:
00233 ////////////////////////////////////////////////////////////////////
00234 INLINE EggTexture::EnvType EggTexture::
00235 get_env_type() const {
00236   return _env_type;
00237 }
00238 
00239 
00240 ////////////////////////////////////////////////////////////////////
00241 //     Function: EggTexture::set_transform
00242 //       Access: Public
00243 //  Description:
00244 ////////////////////////////////////////////////////////////////////
00245 INLINE void EggTexture::
00246 set_transform(const LMatrix3d &transform) {
00247   _transform = transform;
00248   _flags |= F_has_transform;
00249 }
00250 
00251 ////////////////////////////////////////////////////////////////////
00252 //     Function: EggTexture::clear_transform
00253 //       Access: Public
00254 //  Description:
00255 ////////////////////////////////////////////////////////////////////
00256 INLINE void EggTexture::
00257 clear_transform() {
00258   _transform = LMatrix3d::ident_mat();
00259   _flags &= ~F_has_transform;
00260 }
00261 
00262 ////////////////////////////////////////////////////////////////////
00263 //     Function: EggTexture::has_transform
00264 //       Access: Public
00265 //  Description: Returns true if a texture matrix transform has been
00266 //               specified for the texture (even if the transform is
00267 //               identity).
00268 ////////////////////////////////////////////////////////////////////
00269 INLINE bool EggTexture::
00270 has_transform() const {
00271   return (_flags & F_has_transform) != 0;
00272 }
00273 
00274 ////////////////////////////////////////////////////////////////////
00275 //     Function: EggTexture::get_transform
00276 //       Access: Public
00277 //  Description: Returns the texture matrix transform if one has been
00278 //               specified, or identity matrix otherwise.
00279 ////////////////////////////////////////////////////////////////////
00280 INLINE const LMatrix3d &EggTexture::
00281 get_transform() const {
00282   return _transform;
00283 }
00284 
00285 ////////////////////////////////////////////////////////////////////
00286 //     Function: EggTexture::transform_is_identity()
00287 //       Access: Public
00288 //  Description: Returns true if no texture matrix transform has been
00289 //               specified, or if the one specified is the identity
00290 //               transform.  Returns false only if a nonidentity
00291 //               transform has been applied.
00292 ////////////////////////////////////////////////////////////////////
00293 INLINE bool EggTexture::
00294 transform_is_identity() const {
00295   return (!has_transform() ||
00296           _transform.almost_equal(LMatrix3d::ident_mat(), 0.0001));
00297 }
00298 
00299 ////////////////////////////////////////////////////////////////////
00300 //     Function: EggTexture::set_alpha_filename
00301 //       Access: Public
00302 //  Description: Specifies a separate file that will be loaded in with
00303 //               the 1- or 3-component texture and applied as the
00304 //               alpha channel.  This is useful when loading textures
00305 //               from file formats that do not support alpha, for
00306 //               instance jpg.
00307 ////////////////////////////////////////////////////////////////////
00308 INLINE void EggTexture::
00309 set_alpha_filename(const Filename &alpha_filename) {
00310   _alpha_filename = alpha_filename;
00311   _alpha_fullpath = alpha_filename;
00312   _flags |= F_has_alpha_filename;
00313 }
00314 
00315 ////////////////////////////////////////////////////////////////////
00316 //     Function: EggTexture::clear_alpha_filename
00317 //       Access: Public
00318 //  Description:
00319 ////////////////////////////////////////////////////////////////////
00320 INLINE void EggTexture::
00321 clear_alpha_filename() {
00322   _alpha_filename = Filename();
00323   _alpha_fullpath = Filename();
00324   _flags &= ~F_has_alpha_filename;
00325 }
00326 
00327 ////////////////////////////////////////////////////////////////////
00328 //     Function: EggTexture::has_alpha_filename
00329 //       Access: Public
00330 //  Description: Returns true if a separate file for the alpha
00331 //               component has been applied, false otherwise.  See
00332 //               set_alpha_filename().
00333 ////////////////////////////////////////////////////////////////////
00334 INLINE bool EggTexture::
00335 has_alpha_filename() const {
00336   return (_flags & F_has_alpha_filename) != 0;
00337 }
00338 
00339 ////////////////////////////////////////////////////////////////////
00340 //     Function: EggTexture::get_alpha_filename
00341 //       Access: Public
00342 //  Description: Returns the separate file assigned for the alpha
00343 //               channel.  It is an error to call this unless
00344 //               has_alpha_filename() returns true.  See set_alpha_filename().
00345 ////////////////////////////////////////////////////////////////////
00346 INLINE const Filename &EggTexture::
00347 get_alpha_filename() const {
00348   nassertr(has_alpha_filename(), _alpha_filename);
00349   return _alpha_filename;
00350 }
00351 
00352 ////////////////////////////////////////////////////////////////////
00353 //     Function: EggTexture::get_alpha_fullpath
00354 //       Access: Public
00355 //  Description: Returns the full pathname to the alpha file, if it is
00356 //               known; otherwise, returns the same thing as
00357 //               get_alpha_filename().
00358 //
00359 //               This function simply returns whatever was set by the
00360 //               last call to set_alpha_fullpath().  This string is
00361 //               not written to the egg file; its main purpose is to
00362 //               record the full path to the alpha filename if it is
00363 //               known, for egg structures that are generated
00364 //               in-memory and then immediately converted to a scene
00365 //               graph.
00366 ////////////////////////////////////////////////////////////////////
00367 INLINE const Filename &EggTexture::
00368 get_alpha_fullpath() const {
00369   return _alpha_fullpath;
00370 }
00371 
00372 ////////////////////////////////////////////////////////////////////
00373 //     Function: EggTexture::set_alpha_fullpath
00374 //       Access: Public
00375 //  Description: Records the full pathname to the file, for the
00376 //               benefit of get_alpha_fullpath().
00377 ////////////////////////////////////////////////////////////////////
00378 INLINE void EggTexture::
00379 set_alpha_fullpath(const Filename &alpha_fullpath) {
00380   _alpha_fullpath = alpha_fullpath;
00381 }
00382 
00383 ////////////////////////////////////////////////////////////////////
00384 //     Function: EggTexture::set_alpha_file_channel
00385 //       Access: Public
00386 //  Description: If a separate alpha-file is specified, this indicates
00387 //               which channel number should be extracted from this
00388 //               file to derive the alpha channel for the final image.
00389 //               The default is 0, which means the grayscale
00390 //               combination of r, g, b.  Otherwise, this should be
00391 //               the 1-based channel number, for instance 1, 2, or 3
00392 //               for r, g, or b, respectively, or 4 for the alpha
00393 //               channel of a four-component image.
00394 ////////////////////////////////////////////////////////////////////
00395 INLINE void EggTexture::
00396 set_alpha_file_channel(int alpha_file_channel) {
00397   _alpha_file_channel = alpha_file_channel;
00398   _flags |= F_has_alpha_file_channel;
00399 }
00400 
00401 ////////////////////////////////////////////////////////////////////
00402 //     Function: EggTexture::clear_alpha_file_channel
00403 //       Access: Public
00404 //  Description: Removes the specification of a particular channel to
00405 //               use from the alpha-file image.
00406 ////////////////////////////////////////////////////////////////////
00407 INLINE void EggTexture::
00408 clear_alpha_file_channel() {
00409   _alpha_file_channel = 0;
00410   _flags &= ~F_has_alpha_file_channel;
00411 }
00412 
00413 ////////////////////////////////////////////////////////////////////
00414 //     Function: EggTexture::has_alpha_file_channel
00415 //       Access: Public
00416 //  Description: Returns true if a particular channel has been
00417 //               specified for the alpha-file image, false otherwise.
00418 ////////////////////////////////////////////////////////////////////
00419 INLINE bool EggTexture::
00420 has_alpha_file_channel() const {
00421   return (_flags & F_has_alpha_file_channel) != 0;
00422 }
00423 
00424 ////////////////////////////////////////////////////////////////////
00425 //     Function: EggTexture::get_alpha_file_channel
00426 //       Access: Public
00427 //  Description: Returns the particular channel that has been
00428 //               specified for the alpha-file image, or 0 if no
00429 //               channel has been specified.  See
00430 //               set_alpha_file_channel().
00431 ////////////////////////////////////////////////////////////////////
00432 INLINE int EggTexture::
00433 get_alpha_file_channel() const {
00434   return _alpha_file_channel;
00435 }
00436 
00437 ////////////////////////////////////////////////////////////////////
00438 //     Function: UniqueEggTextures::Constructor
00439 //       Access: Public
00440 //  Description:
00441 ////////////////////////////////////////////////////////////////////
00442 INLINE UniqueEggTextures::
00443 UniqueEggTextures(int eq) : _eq(eq) {
00444 }
00445 
00446 ////////////////////////////////////////////////////////////////////
00447 //     Function: UniqueEggTextures::Function operator
00448 //       Access: Public
00449 //  Description:
00450 ////////////////////////////////////////////////////////////////////
00451 INLINE bool UniqueEggTextures::
00452 operator ()(const EggTexture *t1, const EggTexture *t2) const {
00453   return t1->sorts_less_than(*t2, _eq);
00454 }
00455 

Generated on Fri May 2 00:38:00 2003 for Panda by doxygen1.3