EggTexture

class EggTexture

Bases: EggFilenameNode, EggRenderMode, EggTransform

Defines a texture map that may be applied to geometry.

Inheritance diagram

Inheritance diagram of EggTexture

enum CombineChannel
enumerator CC_rgb = 0
enumerator CC_alpha = 1
enumerator CC_num_channels = 2
enum CombineIndex
enumerator CI_num_indices = 3
enum CombineMode
enumerator CM_unspecified = 0
enumerator CM_replace = 1
enumerator CM_modulate = 2
enumerator CM_add = 3
enumerator CM_add_signed = 4
enumerator CM_interpolate = 5
enumerator CM_subtract = 6
enumerator CM_dot3_rgb = 7
enumerator CM_dot3_rgba = 8
enum CombineOperand
enumerator CO_unspecified = 0
enumerator CO_src_color = 1
enumerator CO_one_minus_src_color = 2
enumerator CO_src_alpha = 3
enumerator CO_one_minus_src_alpha = 4
enum CombineSource
enumerator CS_unspecified = 0
enumerator CS_texture = 1
enumerator CS_constant = 2
enumerator CS_primary_color = 3
enumerator CS_previous = 4
enumerator CS_constant_color_scale = 5
enumerator CS_last_saved_result = 6
enum CompressionMode
enumerator CM_default = 0
enumerator CM_off = 1
enumerator CM_on = 2
enumerator CM_fxt1 = 3
enumerator CM_dxt1 = 4
enumerator CM_dxt2 = 5
enumerator CM_dxt3 = 6
enumerator CM_dxt4 = 7
enumerator CM_dxt5 = 8
enum EnvType
enumerator ET_unspecified = 0
enumerator ET_modulate = 1
enumerator ET_decal = 2
enumerator ET_blend = 3
enumerator ET_replace = 4
enumerator ET_add = 5
enumerator ET_blend_color_scale = 6
enumerator ET_modulate_glow = 7
enumerator ET_modulate_gloss = 8
enumerator ET_normal = 9
enumerator ET_normal_height = 10
enumerator ET_glow = 11
enumerator ET_gloss = 12
enumerator ET_height = 13
enumerator ET_selector = 14
enumerator ET_normal_gloss = 15
enumerator ET_emission = 16
enum Equivalence
enumerator E_basename = 1
enumerator E_extension = 2
enumerator E_dirname = 4
enumerator E_complete_filename = 7
enumerator E_transform = 8
enumerator E_attributes = 16
enumerator E_tref_name = 32
enum FilterType
enumerator FT_unspecified = 0

Note that these type values match up, name-for-name, with a similar enumerated type in Panda’s Texture object. However, they do not match up numerically. You must convert between them using a switch statement.

enumerator FT_nearest = 1

Mag Filter and Min Filter

enumerator FT_linear = 2
enumerator FT_nearest_mipmap_nearest = 3

“mipmap point”

enumerator FT_linear_mipmap_nearest = 4

“mipmap linear”

enumerator FT_nearest_mipmap_linear = 5

“mipmap bilinear”

enumerator FT_linear_mipmap_linear = 6

“mipmap trilinear”

enum Format
enumerator F_unspecified = 0
enumerator F_rgba = 1
enumerator F_rgbm = 2
enumerator F_rgba12 = 3
enumerator F_rgba8 = 4
enumerator F_rgba4 = 5
enumerator F_rgba5 = 6
enumerator F_rgb = 7
enumerator F_rgb12 = 8
enumerator F_rgb8 = 9
enumerator F_rgb5 = 10
enumerator F_rgb332 = 11
enumerator F_red = 12
enumerator F_green = 13
enumerator F_blue = 14
enumerator F_alpha = 15
enumerator F_luminance = 16
enumerator F_luminance_alpha = 17
enumerator F_luminance_alphamask = 18
enumerator F_srgb = 19

Only for compatibility with .bam, use is discouraged!

enumerator F_srgb_alpha = 20

Only for compatibility with .bam, use is discouraged!

enum QualityLevel
enumerator QL_unspecified = 0
enumerator QL_default = 1
enumerator QL_fastest = 2
enumerator QL_normal = 3
enumerator QL_best = 4
enum TexGen
enumerator TG_unspecified = 0
enumerator TG_eye_sphere_map = 1
enumerator TG_world_cube_map = 2
enumerator TG_eye_cube_map = 3
enumerator TG_world_normal = 4
enumerator TG_eye_normal = 5
enumerator TG_world_position = 6
enumerator TG_eye_position = 7
enumerator TG_point_sprite = 8
enum TextureType
enumerator TT_unspecified = 0
enumerator TT_1d_texture = 1
enumerator TT_2d_texture = 2
enumerator TT_3d_texture = 3
enumerator TT_cube_map = 4
enum WrapMode
enumerator WM_unspecified = 0
enumerator WM_clamp = 1
enumerator WM_repeat = 2
enumerator WM_mirror = 3
enumerator WM_mirror_once = 4
enumerator WM_border_color = 5
explicit EggTexture(std::string const &tref_name, Filename const &filename)
EggTexture(EggTexture const &copy)
bool affects_polygon_alpha(void) const

Returns true if this texture’s environment type or combine mode allows the texture to have an effect on the polygon’s alpha values, false otherwise.

void clear_alpha_file_channel(void)

Removes the specification of a particular channel to use from the alpha- file image.

void clear_alpha_filename(void)
void clear_alpha_scale(void)

Removes the alpha_scale from the texture and restores it to the default value of 1.

void clear_anisotropic_degree(void)

Removes the specification of anisotropic filtering from the texture.

void clear_border_color(void)
void clear_color(void)
void clear_lod_bias(void)

Removes the specification of a maximum mipmap level from the texture.

void clear_max_lod(void)

Removes the specification of a maximum mipmap level from the texture.

void clear_min_lod(void)

Removes the specification of a minimum mipmap level from the texture.

void clear_multitexture(void)

Resets the multitexture flags set by multitexture_over(). After this call, get_multitexture() will return false, and get_multitexture_sort() will return 0.

void clear_num_views(void)

Removes the specification of the number of views for a 3-D multiview texture.

void clear_priority(void)

Removes the specification of multitexture priority from the texture. The default priority value is 0.

void clear_rgb_scale(void)

Removes the rgb_scale from the texture and restores it to the default value of 1.

void clear_stage_name(void)

Removes the named TextureStage specification.

void clear_uv_name(void)

Removes the restriction to a particular named set of texture coordinates and restores the texture to using the default texture coordinates.

WrapMode determine_wrap_u(void) const

Determines the appropriate wrap in the U direction. This is different from get_wrap_u() in that if the U wrap is unspecified, it returns the overall wrap value.

WrapMode determine_wrap_v(void) const

Determines the appropriate wrap in the V direction. This is different from get_wrap_v() in that if the V wrap is unspecified, it returns the overall wrap value.

WrapMode determine_wrap_w(void) const

Determines the appropriate wrap in the W direction. This is different from get_wrap_w() in that if the W wrap is unspecified, it returns the overall wrap value.

int get_alpha_file_channel(void) const

Returns the particular channel that has been specified for the alpha-file image, or 0 if no channel has been specified. See set_alpha_file_channel().

Filename const &get_alpha_filename(void) const

Returns the separate file assigned for the alpha channel. It is an error to call this unless has_alpha_filename() returns true. See set_alpha_filename().

Filename const &get_alpha_fullpath(void) const

Returns the full pathname to the alpha file, if it is known; otherwise, returns the same thing as get_alpha_filename().

This function simply returns whatever was set by the last call to set_alpha_fullpath(). This string is not written to the egg file; its main purpose is to record the full path to the alpha filename if it is known, for egg structures that are generated in-memory and then immediately converted to a scene graph.

int get_alpha_scale(void) const

Returns the alpha_scale value that has been specified for the texture, or 1 if no alpha_scale value has been specified.

int get_anisotropic_degree(void) const

Returns the anisotropic filtering degree that has been specified for this texture, or 0 if nothing has been specified.

LColor const &get_border_color(void) const

Returns the border color if one has been specified, or (0, 0, 0, 1) otherwise.

static TypeHandle get_class_type(void)
LColor const &get_color(void) const

Returns the blend color if one has been specified, or (0, 0, 0, 1) otherwise.

CombineMode get_combine_mode(EggTexture::CombineChannel channel) const
CombineOperand get_combine_operand(EggTexture::CombineChannel channel, int n) const
CombineSource get_combine_source(EggTexture::CombineChannel channel, int n) const
CompressionMode get_compression_mode(void) const
EnvType get_env_type(void) const
Format get_format(void) const
double get_lod_bias(void) const

Returns the maximum mipmap level that has been specified for this texture.

FilterType get_magfilter(void) const
double get_max_lod(void) const

Returns the maximum mipmap level that has been specified for this texture.

double get_min_lod(void) const

Returns the minimum mipmap level that has been specified for this texture.

FilterType get_minfilter(void) const
int get_multitexture_sort(void) const

Returns an integer that represents the depth to which this texture is layered on all other textures in the egg file. In general, if texture A is layered over texture B, then sort(A) > sort(B). If texture A is never layered over any other texture, then sort(A) == 0. More than that is difficult to guarantee.

bool get_multiview(void) const

Returns the current setting of the multiview flag. See set_multiview().

int get_num_views(void) const

Returns the specified number of views specified for the 3-D multiview texture. See set_num_views().

int get_priority(void) const

Returns the multitexture importance value that has been specified for the texture, or 0 if no priority value has been specified.

QualityLevel get_quality_level(void) const
bool get_read_mipmaps(void) const

Returns the current setting of the read_mipmaps flag. See set_read_mipmaps().

int get_rgb_scale(void) const

Returns the rgb_scale value that has been specified for the texture, or 1 if no rgb_scale value has been specified.

bool get_saved_result(void) const

Returns the current setting of the saved_result flag. See set_saved_result().

std::string const &get_stage_name(void) const

Returns the stage name that has been specified for this texture, or the tref name if no texture stage has explicitly been specified.

TexGen get_tex_gen(void) const
TextureType get_texture_type(void) const
std::string const &get_uv_name(void) const

Returns the texcoord name that has been specified for this texture, or the empty string if no texcoord name has explicitly been specified.

WrapMode get_wrap_mode(void) const
WrapMode get_wrap_u(void) const

Returns the amount specified for U wrap. This may be unspecified, even if there is an overall wrap value.

WrapMode get_wrap_v(void) const

Returns the amount specified for V wrap. This may be unspecified, even if there is an overall wrap value.

WrapMode get_wrap_w(void) const

Returns the amount specified for W wrap. This may be unspecified, even if there is an overall wrap value.

bool has_alpha_channel(int num_components) const

Given the number of color components (channels) in the image file as actually read from the disk, return true if this texture seems to have an alpha channel or not. This depends on the EggTexture’s format as well as the number of channels.

bool has_alpha_file_channel(void) const

Returns true if a particular channel has been specified for the alpha-file image, false otherwise.

bool has_alpha_filename(void) const

Returns true if a separate file for the alpha component has been applied, false otherwise. See set_alpha_filename().

bool has_alpha_scale(void) const

Returns true if an alpha_scale has been specified for the texture, false otherwise.

bool has_anisotropic_degree(void) const

Returns true if a value for the anisotropic filtering degree has been specified for this texture, false otherwise.

bool has_border_color(void) const

Returns true if a border color has been specified for the texture.

bool has_color(void) const

Returns true if a blend color has been specified for the texture.

bool has_lod_bias(void) const

Returns true if a value for the maximum mipmap level has been specified for this texture, false otherwise.

bool has_max_lod(void) const

Returns true if a value for the maximum mipmap level has been specified for this texture, false otherwise.

bool has_min_lod(void) const

Returns true if a value for the minimum mipmap level has been specified for this texture, false otherwise.

bool has_num_views(void) const

Returns true if the number of views has been specified for the 3-D multiview texture, false otherwise.

bool has_priority(void) const

Returns true if a priority value for multitexture importance has been specified for the texture, false otherwise.

bool has_rgb_scale(void) const

Returns true if an rgb_scale has been specified for the texture, false otherwise.

bool has_stage_name(void) const

Returns true if a stage name has been explicitly specified for this texture, false otherwise.

bool has_uv_name(void) const

Returns true if a texcoord name has been explicitly specified for this texture, false otherwise.

bool is_equivalent_to(EggTexture const &other, int eq) const

Returns true if the two textures are equivalent in all relevant properties (according to eq), false otherwise.

The Equivalence parameter, eq, should be set to the bitwise OR of the following properties, according to what you consider relevant:

EggTexture::E_basename: The basename part of the texture filename, without the directory prefix or the filename extension.

EggTexture::E_extension: The extension part of the texture filename.

EggTexture::E_dirname: The directory prefix of the texture filename.

EggTexture::E_complete_filename: The union of the above three; that is, the complete filename, with directory, basename, and extension.

EggTexture::E_transform: The texture matrix.

EggTexture::E_attributes: All remaining texture attributes (mode, mipmap, etc.) except TRef name.

EggTexture::E_tref_name: The TRef name.

bool multitexture_over(EggTexture *other)

Indicates that this texture should be layered on top of the other texture. This will guarantee that this->get_multitexture_sort() > other->get_multitexture_sort(), at least until clear_multitexture() is called on either one.

The return value is true if successful, or false if there is a failure because the other texture was already layered on top of this one (or there is a three- or more-way cycle).

void set_alpha_file_channel(int alpha_file_channel)

If a separate alpha-file is specified, this indicates which channel number should be extracted from this file to derive the alpha channel for the final image. The default is 0, which means the grayscale combination of r, g, b. Otherwise, this should be the 1-based channel number, for instance 1, 2, or 3 for r, g, or b, respectively, or 4 for the alpha channel of a four-component image.

void set_alpha_filename(Filename const &filename)

Specifies a separate file that will be loaded in with the 1- or 3-component texture and applied as the alpha channel. This is useful when loading textures from file formats that do not support alpha, for instance jpg.

void set_alpha_fullpath(Filename const &fullpath)

Records the full pathname to the file, for the benefit of get_alpha_fullpath().

void set_alpha_scale(int alpha_scale)

Sets an additional factor that will scale the alpha component after the texture has been applied. This is used only when a combine mode is in effect.

The only legal values are 1, 2, or 4.

void set_anisotropic_degree(int anisotropic_degree)

Sets the degree of anisotropic filtering for this texture. 1 is off; higher levels indicate filtering in effect.

void set_border_color(LColor const &border_color)
void set_color(LColor const &color)
void set_combine_mode(EggTexture::CombineChannel channel, CombineMode cm)
void set_combine_operand(EggTexture::CombineChannel channel, int n, CombineOperand co)
void set_combine_source(EggTexture::CombineChannel channel, int n, CombineSource cs)
void set_compression_mode(EggTexture::CompressionMode mode)
void set_env_type(EggTexture::EnvType type)
void set_format(EggTexture::Format format)
void set_lod_bias(double lod_bias)

Sets the mipmap level bias that is added to the mipmap level to be sampled.

void set_magfilter(EggTexture::FilterType type)
void set_max_lod(double max_lod)

Sets the maximum mipmap level that may be sampled.

void set_min_lod(double min_lod)

Sets the minimum mipmap level that may be sampled.

void set_minfilter(EggTexture::FilterType type)
void set_multiview(bool multiview)

Sets the multiview flag.

If multiview is true, the filename should contain a hash mark (‘#’), which will be filled in with the view number; and a multiview texture will be defined with a series of images, one for each view.

A multiview texture is most often used for stereo textures, but other uses are also possible, such as for texture animation.

void set_num_views(int num_views)

When loading a 3-D multiview texture, this parameter is necessary to specify how many views will be expected. The z size is determined implicitly from the number of images loaded.

void set_priority(int priority)

Sets the importance of this texture with respect to other textures also applied on the same geometry. This is only meaningful in the presence of multitexturing.

void set_quality_level(EggTexture::QualityLevel quality_level)
void set_read_mipmaps(bool read_mipmaps)

Sets the read_mipmaps flag.

If read_mipmaps is true, the filename should contain a hash mark (‘#’), which will be filled in with the mipmap level number; and the texture will be defined with a series of images, one for each mipmap level.

If the filename is of a type that already requires a hash mark, such as a cube map or a 3-d texture, then the filename should now require two hash marks, and the first one indicates the mipmap level number, while the second indicates the face number or 3-d level number.

void set_rgb_scale(int rgb_scale)

Sets an additional factor that will scale all three r, g, b components after the texture has been applied. This is used only when a combine mode is in effect.

The only legal values are 1, 2, or 4.

void set_saved_result(bool saved_result)

Sets the saved_result flag. When this is true, the output of this stage is not part of the normal pipeline–that is, it will not be supplied as the “previous” source for the next texture stage–but it will instead be supplied as the “last_saved_result” source for any future stages, until the next TextureStage with a saved_result set true is encountered.

This can be used to reuse the results of this texture stage as input to more than one stage later in the pipeline.

The last texture in the pipeline (the one with the highest sort value) should not have this flag set.

void set_stage_name(std::string const &stage_name)

Specifies the particular TextureStage this texture will be rendered on by name. If this is omitted, the texture will be rendered on the default TextureStage, unless some other stage-specific property is specificied, in which case the texture will be rendered on a TextureStage with the same name as the tref. This is in support of multitexturing.

Each different TextureStage in the world must be uniquely named.

void set_tex_gen(EggTexture::TexGen tex_gen)
void set_texture_type(EggTexture::TextureType texture_type)
void set_uv_name(std::string const &uv_name)

Specifies the named set of texture coordinates that this texture will use when it is applied to geometry. Geometry may have multiple sets of texture coordinates defined, by name.

If this is not specified for a particular texture, the default set of texture coordinates will be used.

void set_wrap_mode(EggTexture::WrapMode mode)
void set_wrap_u(EggTexture::WrapMode mode)
void set_wrap_v(EggTexture::WrapMode mode)
void set_wrap_w(EggTexture::WrapMode mode)
bool sorts_less_than(EggTexture const &other, int eq) const

An ordering operator to compare two textures for sorting order. This imposes an arbitrary ordering useful to identify unique textures, according to the indicated Equivalence factor. See is_equivalent_to().

static CombineMode string_combine_mode(std::string const &string)

Returns the CombineMode value associated with the given string representation, or CM_unspecified if the string does not match any known CombineMode value.

static CombineOperand string_combine_operand(std::string const &string)

Returns the CombineOperand value associated with the given string representation, or CO_unspecified if the string does not match any known CombineOperand value.

static CombineSource string_combine_source(std::string const &string)

Returns the CombineSource value associated with the given string representation, or CS_unspecified if the string does not match any known CombineSource value.

static CompressionMode string_compression_mode(std::string const &string)

Returns the CompressionMode value associated with the given string representation, or CM_default if the string does not match any known CompressionMode value.

static EnvType string_env_type(std::string const &string)

Returns the EnvType value associated with the given string representation, or ET_unspecified if the string does not match any known EnvType value.

static FilterType string_filter_type(std::string const &string)

Returns the FilterType value associated with the given string representation, or FT_unspecified if the string does not match any known FilterType value.

static Format string_format(std::string const &string)

Returns the Format value associated with the given string representation, or F_unspecified if the string does not match any known Format value.

static QualityLevel string_quality_level(std::string const &string)

Returns the TexGen value associated with the given string representation, or ET_unspecified if the string does not match any known TexGen value.

static TexGen string_tex_gen(std::string const &string)

Returns the TexGen value associated with the given string representation, or ET_unspecified if the string does not match any known TexGen value.

static TextureType string_texture_type(std::string const &string)

Returns the Texture_ype value associated with the given string representation, or TT_unspecified if the string does not match any known TextureType value.

static WrapMode string_wrap_mode(std::string const &string)

Returns the WrapMode value associated with the given string representation, or WM_unspecified if the string does not match any known WrapMode value.

virtual void write(std::ostream &out, int indent_level) const

Writes the texture definition to the indicated output stream in Egg format.