add repeat_u, clamp_u, etc.
This commit is contained in:
parent
79cdf6dc36
commit
20f24a7b9d
|
|
@ -348,6 +348,12 @@ describe_input_file() {
|
|||
"the alpha mode. This may be any valid egg alpha mode, e.g. "
|
||||
"blend, binary, ms, or dual.\n\n");
|
||||
|
||||
show_text(" repeat_u, repeat_v, clamp_u, clamp_v", 10,
|
||||
"Explcitly specify whether the source texture should repeat or "
|
||||
"clamp in each direction. Although palette images are always "
|
||||
"clamped, this will affect the pixels that are painted into "
|
||||
"the palette image.\n\n");
|
||||
|
||||
show_text(" (image type)", 10,
|
||||
"A texture may be converted to a particular image type, for "
|
||||
"instance jpg or rgb, by naming the type. If present, this "
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Palettizer *pal = (Palettizer *)NULL;
|
|||
// allows us to easily update egg-palettize to write out additional
|
||||
// information to its pi file, without having it increment the bam
|
||||
// version number for all bam and boo files anywhere in the world.
|
||||
int Palettizer::_pi_version = 16;
|
||||
int Palettizer::_pi_version = 17;
|
||||
// Updated to version 8 on 3/20/03 to remove extensions from texture key names.
|
||||
// Updated to version 9 on 4/13/03 to add a few properties in various places.
|
||||
// Updated to version 10 on 4/15/03 to add _alpha_file_channel.
|
||||
|
|
@ -51,6 +51,7 @@ int Palettizer::_pi_version = 16;
|
|||
// Updated to version 14 on 7/26/05 to add _omit_everything.
|
||||
// Updated to version 15 on 8/01/05 to make TextureImages be case-insensitive.
|
||||
// Updated to version 16 on 4/03/06 to add Palettizer::_cutout_mode et al.
|
||||
// Updated to version 17 on 3/02/07 to add TextureImage::_txa_wrap_u etc.
|
||||
|
||||
int Palettizer::_min_pi_version = 8;
|
||||
// Dropped support for versions 7 and below on 7/14/03.
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ TextureImage() {
|
|||
_forced_grayscale = false;
|
||||
_alpha_bits = 0;
|
||||
_alpha_mode = EggRenderMode::AM_unspecified;
|
||||
_txa_wrap_u = EggTexture::WM_unspecified;
|
||||
_txa_wrap_v = EggTexture::WM_unspecified;
|
||||
_texture_named = false;
|
||||
_got_txa_file = false;
|
||||
}
|
||||
|
|
@ -332,6 +334,22 @@ post_txa_file() {
|
|||
_y_size = _request._y_size;
|
||||
}
|
||||
|
||||
if (_txa_wrap_u != _request._wrap_u ||
|
||||
_txa_wrap_v != _request._wrap_v) {
|
||||
_txa_wrap_u = _request._wrap_u;
|
||||
_txa_wrap_v = _request._wrap_v;
|
||||
|
||||
// If the explicit wrap mode changes, we may need to regenerate
|
||||
// the egg files, and/or refill the palettes.
|
||||
mark_eggs_stale();
|
||||
|
||||
Placement::iterator pi;
|
||||
for (pi = _placement.begin(); pi != _placement.end(); ++pi) {
|
||||
TexturePlacement *placement = (*pi).second;
|
||||
placement->mark_unfilled();
|
||||
}
|
||||
}
|
||||
|
||||
if (_properties.has_num_channels() && !_request._keep_format) {
|
||||
int num_channels = _properties.get_num_channels();
|
||||
// Examine the image to determine if we can downgrade the number
|
||||
|
|
@ -525,6 +543,28 @@ get_alpha_mode() const {
|
|||
return _alpha_mode;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureImage::get_txa_wrap_u
|
||||
// Access: Public
|
||||
// Description: Returns the wrap mode specified in the u direction in
|
||||
// the txa file, or WM_unspecified.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EggTexture::WrapMode TextureImage::
|
||||
get_txa_wrap_u() const {
|
||||
return _txa_wrap_u;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureImage::get_txa_wrap_v
|
||||
// Access: Public
|
||||
// Description: Returns the wrap mode specified in the v direction in
|
||||
// the txa file, or WM_unspecified.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EggTexture::WrapMode TextureImage::
|
||||
get_txa_wrap_v() const {
|
||||
return _txa_wrap_v;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureImage::get_source
|
||||
|
|
@ -1336,6 +1376,8 @@ write_datagram(BamWriter *writer, Datagram &datagram) {
|
|||
datagram.add_int16((int)_alpha_mode);
|
||||
datagram.add_float64(_mid_pixel_ratio);
|
||||
datagram.add_bool(_is_cutout);
|
||||
datagram.add_uint8((int)_txa_wrap_u);
|
||||
datagram.add_uint8((int)_txa_wrap_v);
|
||||
|
||||
// We don't write out _explicitly_assigned_groups; this is re-read
|
||||
// from the .txa file each time.
|
||||
|
|
@ -1460,6 +1502,10 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
_mid_pixel_ratio = 0.0;
|
||||
_is_cutout = false;
|
||||
}
|
||||
if (pal->_read_pi_version >= 17) {
|
||||
_txa_wrap_u = (EggTexture::WrapMode)scan.get_uint8();
|
||||
_txa_wrap_v = (EggTexture::WrapMode)scan.get_uint8();
|
||||
}
|
||||
|
||||
_actual_assigned_groups.fillin(scan, manager);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ public:
|
|||
bool is_used() const;
|
||||
EggRenderMode::AlphaMode get_alpha_mode() const;
|
||||
|
||||
EggTexture::WrapMode get_txa_wrap_u() const;
|
||||
EggTexture::WrapMode get_txa_wrap_v() const;
|
||||
|
||||
SourceTextureImage *get_source(const Filename &filename,
|
||||
const Filename &alpha_filename,
|
||||
int alpha_file_channel);
|
||||
|
|
@ -139,6 +142,7 @@ private:
|
|||
double _mid_pixel_ratio;
|
||||
bool _is_cutout;
|
||||
EggRenderMode::AlphaMode _alpha_mode;
|
||||
EggTexture::WrapMode _txa_wrap_u, _txa_wrap_v;
|
||||
|
||||
PaletteGroups _explicitly_assigned_groups;
|
||||
PaletteGroups _actual_assigned_groups;
|
||||
|
|
|
|||
|
|
@ -282,6 +282,15 @@ determine_size() {
|
|||
}
|
||||
}
|
||||
|
||||
// However, if the user specified an explicit wrap mode, allow it to
|
||||
// apply.
|
||||
if (_texture->get_txa_wrap_u() != EggTexture::WM_unspecified) {
|
||||
_position._wrap_u = _texture->get_txa_wrap_u();
|
||||
}
|
||||
if (_texture->get_txa_wrap_v() != EggTexture::WM_unspecified) {
|
||||
_position._wrap_v = _texture->get_txa_wrap_v();
|
||||
}
|
||||
|
||||
if (!_has_uvs) {
|
||||
force_replace();
|
||||
_omit_reason = OR_unused;
|
||||
|
|
|
|||
|
|
@ -422,10 +422,10 @@ update_egg() {
|
|||
|
||||
nassertv(_placement != (TexturePlacement *)NULL);
|
||||
|
||||
// Make sure the alpha mode is set according to what the texture
|
||||
// image wants.
|
||||
TextureImage *texture = get_texture();
|
||||
if (texture != (TextureImage *)NULL) {
|
||||
// Make sure the alpha mode is set according to what the texture
|
||||
// image wants.
|
||||
if (texture->has_num_channels() &&
|
||||
!_egg_tex->has_alpha_channel(texture->get_num_channels())) {
|
||||
// The egg file doesn't want to use the alpha on the texture;
|
||||
|
|
@ -441,6 +441,14 @@ update_egg() {
|
|||
_egg_tex->set_alpha_mode(am);
|
||||
}
|
||||
}
|
||||
|
||||
// Also make sure the wrap mode is set properly.
|
||||
if (texture->get_txa_wrap_u() != EggTexture::WM_unspecified) {
|
||||
_egg_tex->set_wrap_u(texture->get_txa_wrap_u());
|
||||
}
|
||||
if (texture->get_txa_wrap_v() != EggTexture::WM_unspecified) {
|
||||
_egg_tex->set_wrap_v(texture->get_txa_wrap_v());
|
||||
}
|
||||
}
|
||||
|
||||
// We check for an OmitReason of OR_none, rather than asking
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ TextureRequest() {
|
|||
_magfilter = EggTexture::FT_unspecified;
|
||||
_anisotropic_degree = 0;
|
||||
_alpha_mode = EggRenderMode::AM_unspecified;
|
||||
_wrap_u = EggTexture::WM_unspecified;
|
||||
_wrap_v = EggTexture::WM_unspecified;
|
||||
_omit = false;
|
||||
_margin = 0;
|
||||
_coverage_threshold = 0.0;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public:
|
|||
EggTexture::FilterType _magfilter;
|
||||
int _anisotropic_degree;
|
||||
EggRenderMode::AlphaMode _alpha_mode;
|
||||
EggTexture::WrapMode _wrap_u, _wrap_v;
|
||||
bool _omit;
|
||||
int _margin;
|
||||
double _coverage_threshold;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ TxaLine() {
|
|||
_generic_format = false;
|
||||
_keep_format = false;
|
||||
_alpha_mode = EggRenderMode::AM_unspecified;
|
||||
_wrap_u = EggTexture::WM_unspecified;
|
||||
_wrap_v = EggTexture::WM_unspecified;
|
||||
_got_margin = false;
|
||||
_margin = 0;
|
||||
_got_coverage_threshold = false;
|
||||
|
|
@ -285,6 +287,24 @@ parse(const string &line) {
|
|||
if (am != EggRenderMode::AM_unspecified) {
|
||||
_alpha_mode = am;
|
||||
|
||||
} else if (word.length() > 2 && word[word.length() - 2] == '_' &&
|
||||
strchr("uv", word[word.length() - 1]) != NULL) {
|
||||
// It must be a wrap mode for u or v.
|
||||
string prefix = word.substr(0, word.length() - 2);
|
||||
EggTexture::WrapMode wm = EggTexture::string_wrap_mode(prefix);
|
||||
if (wm == EggTexture::WM_unspecified) {
|
||||
return false;
|
||||
}
|
||||
switch (word[word.length() - 1]) {
|
||||
case 'u':
|
||||
_wrap_u = wm;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
_wrap_v = wm;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Maybe it's an image file request.
|
||||
if (!parse_image_type_request(word, _color_type, _alpha_type)) {
|
||||
|
|
@ -452,6 +472,13 @@ match_texture(TextureImage *texture) const {
|
|||
request._alpha_mode = _alpha_mode;
|
||||
}
|
||||
|
||||
if (_wrap_u != EggTexture::WM_unspecified) {
|
||||
request._wrap_u = _wrap_u;
|
||||
}
|
||||
if (_wrap_v != EggTexture::WM_unspecified) {
|
||||
request._wrap_v = _wrap_v;
|
||||
}
|
||||
|
||||
bool got_cont = false;
|
||||
Keywords::const_iterator ki;
|
||||
for (ki = _keywords.begin(); ki != _keywords.end(); ++ki) {
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ private:
|
|||
bool _generic_format;
|
||||
bool _keep_format;
|
||||
EggRenderMode::AlphaMode _alpha_mode;
|
||||
EggTexture::WrapMode _wrap_u, _wrap_v;
|
||||
|
||||
int _aniso_degree;
|
||||
bool _got_margin;
|
||||
|
|
|
|||
Loading…
Reference in New Issue