mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
*** empty log message ***
This commit is contained in:
parent
97244bf9bd
commit
174bdd8807
@ -222,9 +222,9 @@ $[target] : $[sources]
|
||||
#define target $[pal_egg_dir]/$[egg]
|
||||
$[target] : $[source] $[pt]
|
||||
#if $[PHASE]
|
||||
egg-palettize-new -C -dm $[install_dir]/%s/maps -g phase_$[PHASE] -gdir phase_$[PHASE] -P256,256 -2 -o $[target] $[texattrib_file] $[source]
|
||||
egg-palettize-new $[PALETTIZE_OPTS] -C -dr $[install_dir] -dm $[install_dir]/%s/maps -g phase_$[PHASE] -gdir phase_$[PHASE] -P256,256 -2 -o $[target] $[texattrib_file] $[source]
|
||||
#else
|
||||
egg-palettize-new -C -dm $[install_dir]/maps -P256,256 -2 -o $[target] $[texattrib_file] $[source]
|
||||
egg-palettize-new $[PALETTIZE_OPTS] -C -dr $[install_dir] -dm $[install_dir]/maps -P256,256 -2 -o $[target] $[texattrib_file] $[source]
|
||||
#endif
|
||||
|
||||
$[pt] :
|
||||
@ -350,10 +350,10 @@ install-misc : $[subdirs:%=install-misc-%]
|
||||
install : egg $[subdirs:%=install-%]
|
||||
uninstall : $[subdirs:%=uninstall-%]
|
||||
|
||||
optimize-palettes : regen-palettes pal
|
||||
optimize-palettes : regen-palettes install
|
||||
|
||||
regen-palettes :
|
||||
egg-palettize-new -C -fRt $[texattrib_file]
|
||||
egg-palettize-new $[PALETTIZE_OPTS] -C -fRt $[texattrib_file]
|
||||
|
||||
// Somehow, something in the cttools confuses some shells, so that
|
||||
// when we are attached, 'cd foo' doesn't work, but 'cd ./foo' does.
|
||||
|
@ -15,7 +15,7 @@
|
||||
load_egg_file.h loaderFileTypeEgg.cxx loaderFileTypeEgg.h
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
load_egg_file.h
|
||||
load_egg_file.h config_egg2sg.h
|
||||
|
||||
#end lib_target
|
||||
|
||||
|
@ -13,31 +13,40 @@
|
||||
ConfigureDef(config_egg2sg);
|
||||
NotifyCategoryDef(egg2sg, "");
|
||||
|
||||
const bool egg_mesh = config_egg2sg.GetBool("egg-mesh", true);
|
||||
const bool egg_retesselate_coplanar = config_egg2sg.GetBool("egg-retesselate-coplanar", true);
|
||||
const bool egg_unroll_fans = config_egg2sg.GetBool("egg-unroll-fans", true);
|
||||
const bool egg_show_tstrips = config_egg2sg.GetBool("egg-show-tstrips", false);
|
||||
const bool egg_show_qsheets = config_egg2sg.GetBool("egg-show-qsheets", false);
|
||||
const bool egg_show_quads = config_egg2sg.GetBool("egg-show-quads", false);
|
||||
const bool egg_false_color = (egg_show_tstrips | egg_show_qsheets | egg_show_quads);
|
||||
const bool egg_show_normals = config_egg2sg.GetBool("egg-show-normals", false);
|
||||
const double egg_normal_scale = config_egg2sg.GetDouble("egg-normal-scale", 1.0);
|
||||
const bool egg_subdivide_polys = config_egg2sg.GetBool("egg-subdivide-polys", true);
|
||||
const bool egg_consider_fans = config_egg2sg.GetBool("egg-consider-fans", true);
|
||||
const double egg_max_tfan_angle = config_egg2sg.GetDouble("egg-max-tfan-angle", 40.0);
|
||||
const int egg_min_tfan_tris = config_egg2sg.GetInt("egg-min-tfan-tris", 4);
|
||||
const double egg_coplanar_threshold = config_egg2sg.GetDouble("egg-coplanar-threshold", 0.01);
|
||||
const bool egg_ignore_mipmaps = config_egg2sg.GetBool("egg-ignore-mipmaps", false);
|
||||
const bool egg_ignore_filters = config_egg2sg.GetBool("egg-ignore-filters", false);
|
||||
const bool egg_ignore_clamp = config_egg2sg.GetBool("egg-ignore-clamp", false);
|
||||
const bool egg_always_decal_textures = config_egg2sg.GetBool("egg-always-decal-textures", false);
|
||||
const bool egg_ignore_decals = config_egg2sg.GetBool("egg-ignore-decals", false);
|
||||
const bool egg_flatten = config_egg2sg.GetBool("egg-flatten", true);
|
||||
bool egg_mesh = config_egg2sg.GetBool("egg-mesh", true);
|
||||
bool egg_retesselate_coplanar = config_egg2sg.GetBool("egg-retesselate-coplanar", true);
|
||||
bool egg_unroll_fans = config_egg2sg.GetBool("egg-unroll-fans", true);
|
||||
bool egg_show_tstrips = config_egg2sg.GetBool("egg-show-tstrips", false);
|
||||
bool egg_show_qsheets = config_egg2sg.GetBool("egg-show-qsheets", false);
|
||||
bool egg_show_quads = config_egg2sg.GetBool("egg-show-quads", false);
|
||||
bool egg_false_color = (egg_show_tstrips | egg_show_qsheets | egg_show_quads);
|
||||
bool egg_show_normals = config_egg2sg.GetBool("egg-show-normals", false);
|
||||
double egg_normal_scale = config_egg2sg.GetDouble("egg-normal-scale", 1.0);
|
||||
bool egg_subdivide_polys = config_egg2sg.GetBool("egg-subdivide-polys", true);
|
||||
bool egg_consider_fans = config_egg2sg.GetBool("egg-consider-fans", true);
|
||||
double egg_max_tfan_angle = config_egg2sg.GetDouble("egg-max-tfan-angle", 40.0);
|
||||
int egg_min_tfan_tris = config_egg2sg.GetInt("egg-min-tfan-tris", 4);
|
||||
double egg_coplanar_threshold = config_egg2sg.GetDouble("egg-coplanar-threshold", 0.01);
|
||||
bool egg_ignore_mipmaps = config_egg2sg.GetBool("egg-ignore-mipmaps", false);
|
||||
bool egg_ignore_filters = config_egg2sg.GetBool("egg-ignore-filters", false);
|
||||
bool egg_ignore_clamp = config_egg2sg.GetBool("egg-ignore-clamp", false);
|
||||
bool egg_always_decal_textures = config_egg2sg.GetBool("egg-always-decal-textures", false);
|
||||
bool egg_ignore_decals = config_egg2sg.GetBool("egg-ignore-decals", false);
|
||||
bool egg_flatten = config_egg2sg.GetBool("egg-flatten", true);
|
||||
|
||||
// It is almost always a bad idea to set this true.
|
||||
const bool egg_flatten_siblings = config_egg2sg.GetBool("egg-flatten-siblings", false);
|
||||
bool egg_flatten_siblings = config_egg2sg.GetBool("egg-flatten-siblings", false);
|
||||
|
||||
const bool egg_show_collision_solids = config_egg2sg.GetBool("egg-show-collision-solids", false);
|
||||
bool egg_show_collision_solids = config_egg2sg.GetBool("egg-show-collision-solids", false);
|
||||
|
||||
// When this is true, keep texture pathnames exactly the same as they
|
||||
// appeared in the egg file, in particular leaving them as relative
|
||||
// paths, rather than letting them reflect the full path at which they
|
||||
// were found. This is particularly useful when generating bam files.
|
||||
// However, if the same texture is named by two different relative
|
||||
// paths, these will still be collapsed into one texture (using one of
|
||||
// the relative paths, chosen arbitrarily).
|
||||
bool egg_keep_texture_pathnames = config_egg2sg.GetBool("egg-keep-texture-pathnames", false);
|
||||
|
||||
CoordinateSystem egg_coordinate_system;
|
||||
|
||||
|
@ -16,29 +16,30 @@
|
||||
ConfigureDecl(config_egg2sg, EXPCL_PANDAEGG, EXPTP_PANDAEGG);
|
||||
NotifyCategoryDecl(egg2sg, EXPCL_PANDAEGG, EXPTP_PANDAEGG);
|
||||
|
||||
extern const bool egg_mesh;
|
||||
extern const bool egg_retesselate_coplanar;
|
||||
extern const bool egg_unroll_fans;
|
||||
extern const bool egg_show_tstrips;
|
||||
extern const bool egg_show_qsheets;
|
||||
extern const bool egg_show_quads;
|
||||
extern const bool egg_false_color;
|
||||
extern const bool egg_show_normals;
|
||||
extern const double egg_normal_scale;
|
||||
extern const bool egg_subdivide_polys;
|
||||
extern const bool egg_consider_fans;
|
||||
extern const double egg_max_tfan_angle;
|
||||
extern const int egg_min_tfan_tris;
|
||||
extern const double egg_coplanar_threshold;
|
||||
extern CoordinateSystem egg_coordinate_system;
|
||||
extern const bool egg_ignore_mipmaps;
|
||||
extern const bool egg_ignore_filters;
|
||||
extern const bool egg_ignore_clamp;
|
||||
extern const bool egg_always_decal_textures;
|
||||
extern const bool egg_ignore_decals;
|
||||
extern const bool egg_flatten;
|
||||
extern const bool egg_flatten_siblings;
|
||||
extern const bool egg_show_collision_solids;
|
||||
extern EXPCL_PANDAEGG bool egg_mesh;
|
||||
extern EXPCL_PANDAEGG bool egg_retesselate_coplanar;
|
||||
extern EXPCL_PANDAEGG bool egg_unroll_fans;
|
||||
extern EXPCL_PANDAEGG bool egg_show_tstrips;
|
||||
extern EXPCL_PANDAEGG bool egg_show_qsheets;
|
||||
extern EXPCL_PANDAEGG bool egg_show_quads;
|
||||
extern EXPCL_PANDAEGG bool egg_false_color;
|
||||
extern EXPCL_PANDAEGG bool egg_show_normals;
|
||||
extern EXPCL_PANDAEGG double egg_normal_scale;
|
||||
extern EXPCL_PANDAEGG bool egg_subdivide_polys;
|
||||
extern EXPCL_PANDAEGG bool egg_consider_fans;
|
||||
extern EXPCL_PANDAEGG double egg_max_tfan_angle;
|
||||
extern EXPCL_PANDAEGG int egg_min_tfan_tris;
|
||||
extern EXPCL_PANDAEGG double egg_coplanar_threshold;
|
||||
extern EXPCL_PANDAEGG CoordinateSystem egg_coordinate_system;
|
||||
extern EXPCL_PANDAEGG bool egg_ignore_mipmaps;
|
||||
extern EXPCL_PANDAEGG bool egg_ignore_filters;
|
||||
extern EXPCL_PANDAEGG bool egg_ignore_clamp;
|
||||
extern EXPCL_PANDAEGG bool egg_always_decal_textures;
|
||||
extern EXPCL_PANDAEGG bool egg_ignore_decals;
|
||||
extern EXPCL_PANDAEGG bool egg_flatten;
|
||||
extern EXPCL_PANDAEGG bool egg_flatten_siblings;
|
||||
extern EXPCL_PANDAEGG bool egg_show_collision_solids;
|
||||
extern EXPCL_PANDAEGG bool egg_keep_texture_pathnames;
|
||||
|
||||
|
||||
|
||||
|
@ -515,6 +515,16 @@ load_texture(TextureDef &def, const EggTexture *egg_tex) {
|
||||
if (tex == (Texture *)NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (egg_keep_texture_pathnames) {
|
||||
tex->set_name(egg_tex->get_filename());
|
||||
if (egg_tex->has_alpha_file()) {
|
||||
tex->set_alpha_name(egg_tex->get_alpha_file());
|
||||
} else {
|
||||
tex->clear_alpha_name();
|
||||
}
|
||||
}
|
||||
|
||||
PT(TextureApplyTransition) apply =
|
||||
new TextureApplyTransition(TextureApplyProperty::M_modulate);
|
||||
|
||||
|
@ -12,7 +12,8 @@
|
||||
geomPoint.cxx geomPoint.h geomPolygon.cxx geomPolygon.h \
|
||||
geomQuad.cxx geomQuad.h geomSphere.cxx geomSphere.h geomSprite.I \
|
||||
geomSprite.cxx geomSprite.h geomTri.cxx geomTri.h geomTrifan.cxx \
|
||||
geomTrifan.h geomTristrip.cxx geomTristrip.h imageBuffer.cxx \
|
||||
geomTrifan.h geomTristrip.cxx geomTristrip.h \
|
||||
imageBuffer.I imageBuffer.cxx \
|
||||
imageBuffer.h material.I material.cxx material.h orthoProjection.I \
|
||||
orthoProjection.cxx orthoProjection.h perspectiveProjection.I \
|
||||
perspectiveProjection.cxx perspectiveProjection.h pixelBuffer.I \
|
||||
@ -21,10 +22,11 @@
|
||||
texturePool.I texturePool.cxx texturePool.h
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
LOD.I LOD.h drawable.h fog.I fog.h geom.I geom.h geomLine.h \
|
||||
LOD.I LOD.h config_gobj.h \
|
||||
drawable.h fog.I fog.h geom.I geom.h geomLine.h \
|
||||
geomLinestrip.h geomPoint.h geomPolygon.h geomQuad.h geomSphere.h \
|
||||
geomSprite.I geomSprite.h geomTri.h geomTrifan.h geomTristrip.h \
|
||||
geomprimitives.h imageBuffer.h material.I material.h \
|
||||
geomprimitives.h imageBuffer.I imageBuffer.h material.I material.h \
|
||||
orthoProjection.I orthoProjection.h perspectiveProjection.I \
|
||||
perspectiveProjection.h pixelBuffer.I pixelBuffer.h projection.h \
|
||||
texture.I texture.h texturePool.I texturePool.h
|
||||
|
@ -12,14 +12,14 @@
|
||||
NotifyCategoryDecl(gobj, EXPCL_PANDA, EXPTP_PANDA);
|
||||
|
||||
// Configure variables for gobj package.
|
||||
extern const int max_texture_dimension;
|
||||
extern EXPCL_PANDA const int max_texture_dimension;
|
||||
|
||||
enum BamTextureMode {
|
||||
BTM_fullpath,
|
||||
BTM_relative,
|
||||
BTM_basename
|
||||
};
|
||||
extern BamTextureMode bam_texture_mode;
|
||||
extern EXPCL_PANDA BamTextureMode bam_texture_mode;
|
||||
|
||||
#endif
|
||||
|
||||
|
61
panda/src/gobj/imageBuffer.I
Normal file
61
panda/src/gobj/imageBuffer.I
Normal file
@ -0,0 +1,61 @@
|
||||
// Filename: imageBuffer.I
|
||||
// Created by: drose (21Nov00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageBuffer::set_alpha_name
|
||||
// Access: Public
|
||||
// Description: Sets the name of the file that contains the image's
|
||||
// alpha channel contents. Normally, this is set
|
||||
// automatically when the image is loaded, for instance
|
||||
// via Texture::read().
|
||||
//
|
||||
// The ImageBuffer's get_name() function, by convention,
|
||||
// returns the name of the image file that was loaded
|
||||
// into the buffer. In the case where a texture
|
||||
// specified two separate files to load, a 1- or
|
||||
// 3-channel color image and a 1-channel alpha image,
|
||||
// this string is update to contain the name of the
|
||||
// image file that was loaded into the buffer's alpha
|
||||
// channel.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ImageBuffer::
|
||||
set_alpha_name(const string &alpha_name) {
|
||||
_alpha_name = alpha_name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageBuffer::clear_alpha_name
|
||||
// Access: Public
|
||||
// Description: Removes the alpha filename, if it was previously set.
|
||||
// See set_alpha_name().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ImageBuffer::
|
||||
clear_alpha_name() {
|
||||
_alpha_name = string();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageBuffer::has_alpha_name
|
||||
// Access: Public
|
||||
// Description: Returns true if the alpha_name has been set and
|
||||
// is available. See set_alpha_name().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ImageBuffer::
|
||||
has_alpha_name() const {
|
||||
return !_alpha_name.empty();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageBuffer::get_alpha_name
|
||||
// Access: Public
|
||||
// Description: Returns the alpha_name that has been set. Use
|
||||
// this in conjunction with get_name() to get the names
|
||||
// of the file(s) that were loaded into the buffer. See
|
||||
// set_alpha_name().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const string &ImageBuffer::
|
||||
get_alpha_name() const {
|
||||
return _alpha_name;
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <datagram.h>
|
||||
#include <datagramIterator.h>
|
||||
#include <bamReader.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Static variables
|
||||
@ -30,6 +31,7 @@ void ImageBuffer::
|
||||
write_datagram(BamWriter *, Datagram &me)
|
||||
{
|
||||
Filename filename = get_name();
|
||||
Filename alpha_filename = get_alpha_name();
|
||||
|
||||
switch (bam_texture_mode) {
|
||||
case BTM_fullpath:
|
||||
@ -42,10 +44,17 @@ write_datagram(BamWriter *, Datagram &me)
|
||||
gobj_cat.debug()
|
||||
<< "Texture file " << get_name() << " found as " << filename << "\n";
|
||||
}
|
||||
alpha_filename.find_on_searchpath(get_texture_path());
|
||||
alpha_filename.find_on_searchpath(get_model_path());
|
||||
if (gobj_cat.is_debug()) {
|
||||
gobj_cat.debug()
|
||||
<< "Alpha image " << get_alpha_name() << " found as " << alpha_filename << "\n";
|
||||
}
|
||||
break;
|
||||
|
||||
case BTM_basename:
|
||||
filename = filename.get_basename();
|
||||
alpha_filename = alpha_filename.get_basename();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -54,6 +63,7 @@ write_datagram(BamWriter *, Datagram &me)
|
||||
}
|
||||
|
||||
me.add_string(filename);
|
||||
me.add_string(alpha_filename);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -65,7 +75,12 @@ write_datagram(BamWriter *, Datagram &me)
|
||||
// place
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ImageBuffer::
|
||||
fillin(DatagramIterator& scan, BamReader*)
|
||||
{
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
set_name(scan.get_string());
|
||||
|
||||
if (manager->get_file_minor_ver() >= 3) {
|
||||
set_alpha_name(scan.get_string());
|
||||
} else {
|
||||
clear_alpha_name();
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,20 @@ public:
|
||||
|
||||
virtual void copy(GraphicsStateGuardianBase *, const DisplayRegion *)=0;
|
||||
virtual void copy(GraphicsStateGuardianBase *, const DisplayRegion *,
|
||||
const RenderBuffer &rb)=0;
|
||||
const RenderBuffer &rb)=0;
|
||||
virtual void draw(GraphicsStateGuardianBase *)=0;
|
||||
virtual void draw(GraphicsStateGuardianBase *, const DisplayRegion *)=0;
|
||||
virtual void draw(GraphicsStateGuardianBase *, const DisplayRegion *,
|
||||
const RenderBuffer &rb)=0;
|
||||
|
||||
INLINE void set_alpha_name(const string &alpha_name);
|
||||
INLINE void clear_alpha_name();
|
||||
INLINE bool has_alpha_name() const;
|
||||
INLINE const string &get_alpha_name() const;
|
||||
|
||||
private:
|
||||
string _alpha_name;
|
||||
|
||||
public:
|
||||
//Abstract class, so no factory methods for Reading and Writing
|
||||
virtual void write_datagram(BamWriter* manager, Datagram &me);
|
||||
@ -76,6 +84,8 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "imageBuffer.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -40,6 +40,7 @@ bool PixelBuffer::read(const string& name)
|
||||
}
|
||||
|
||||
set_name(name);
|
||||
clear_alpha_name();
|
||||
return load(pnmimage);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ bool Texture::read(const string& name)
|
||||
}
|
||||
|
||||
set_name(name);
|
||||
clear_alpha_name();
|
||||
return load(pnmimage);
|
||||
}
|
||||
|
||||
@ -161,6 +162,7 @@ bool Texture::read(const string &name, const string &gray) {
|
||||
}
|
||||
|
||||
set_name(name);
|
||||
set_alpha_name(gray);
|
||||
return load(pnmimage);
|
||||
}
|
||||
|
||||
@ -425,7 +427,19 @@ make_Texture(const FactoryParams ¶ms)
|
||||
DatagramIterator scan(packet);
|
||||
|
||||
string name = scan.get_string();
|
||||
PT(Texture) me = TexturePool::load_texture(name);
|
||||
string alpha_name;
|
||||
if (manager->get_file_minor_ver() >= 3) {
|
||||
alpha_name = scan.get_string();
|
||||
}
|
||||
|
||||
PT(Texture) me;
|
||||
|
||||
if (alpha_name.empty()) {
|
||||
me = TexturePool::load_texture(name);
|
||||
} else {
|
||||
me = TexturePool::load_texture(name, alpha_name);
|
||||
}
|
||||
|
||||
if (me == (Texture *)NULL) {
|
||||
// Oops, we couldn't load the texture; we'll just return NULL.
|
||||
// But we do need a dummy texture to read in and ignore all of the
|
||||
|
@ -5,7 +5,8 @@
|
||||
#define TARGET putil
|
||||
|
||||
#define SOURCES \
|
||||
bamReader.I bamReader.N bamReader.cxx bamReader.h bamReaderParam.I \
|
||||
bam.h bamReader.I bamReader.N bamReader.cxx \
|
||||
bamReader.h bamReaderParam.I \
|
||||
bamReaderParam.cxx bamReaderParam.h bamWriter.I bamWriter.cxx \
|
||||
bamWriter.h bitMask.I bitMask.cxx bitMask.h buttonEvent.I \
|
||||
buttonEvent.cxx buttonEvent.h buttonHandle.I buttonHandle.cxx \
|
||||
|
@ -9,15 +9,18 @@
|
||||
#ifndef _BAM_H
|
||||
#define _BAM_H
|
||||
|
||||
#include <pandabase.h>
|
||||
|
||||
//The magic number for a BAM file and a carriage return and newline
|
||||
//for detecting files damaged due to ASCII/Binary conversion
|
||||
static const string _bam_header = string("pbj\0\n\r", 6);
|
||||
|
||||
static const unsigned short _bam_major_ver = 2;
|
||||
// Bumped to major version 2 on 7/6/00 due to major changes in Character.
|
||||
static const unsigned short _bam_minor_ver = 2;
|
||||
static const unsigned short _bam_minor_ver = 3;
|
||||
// Bumped to minor version 1 on 7/19/00 to quantize channel files.
|
||||
// Bumped to minor version 2 on 8/21/00 for CollisionNode::_collide_geom.
|
||||
// Bumped to minor version 3 on 11/21/00 for dual-image textures.
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <config_util.h>
|
||||
#include <bamFile.h>
|
||||
#include <load_egg_file.h>
|
||||
#include <config_egg2sg.h>
|
||||
#include <config_gobj.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggToBam::Constructor
|
||||
@ -28,6 +30,13 @@ EggToBam() :
|
||||
"option may also be repeated to add multiple paths.",
|
||||
&EggToBam::dispatch_search_path, NULL, &get_texture_path());
|
||||
|
||||
add_option
|
||||
("kp", "", 0,
|
||||
"Keep the texture paths exactly as they are specified in the egg file, "
|
||||
"as relative paths, rather than storing them as full paths or as "
|
||||
"whatever is specified by the bam-texture-mode Configrc variable.",
|
||||
&EggToBam::dispatch_none, &_keep_paths);
|
||||
|
||||
redescribe_option
|
||||
("cs",
|
||||
"Specify the coordinate system of the resulting " + _format_name +
|
||||
@ -43,6 +52,13 @@ EggToBam() :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void EggToBam::
|
||||
run() {
|
||||
if (_keep_paths) {
|
||||
// If the user specified -kp, we need to set a couple of Configrc
|
||||
// variables directly to achieve this.
|
||||
egg_keep_texture_pathnames = true;
|
||||
bam_texture_mode = BTM_fullpath;
|
||||
}
|
||||
|
||||
if (!_got_coordinate_system) {
|
||||
// If the user didn't specify otherwise, ensure the coordinate
|
||||
// system is Z-up.
|
||||
|
@ -19,6 +19,8 @@ public:
|
||||
EggToBam();
|
||||
|
||||
void run();
|
||||
|
||||
bool _keep_paths;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,6 +30,11 @@
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AttribFile::
|
||||
AttribFile(const Filename &filename) {
|
||||
_name = filename.get_basename_wo_extension();
|
||||
@ -61,11 +66,24 @@ AttribFile(const Filename &filename) {
|
||||
_alpha_type = (PNMFileType *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::get_name
|
||||
// Access: Public
|
||||
// Description: Returns the name of the AttribFile. This is derived
|
||||
// from, but is not equivalent to, the filename.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string AttribFile::
|
||||
get_name() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::open_and_lock
|
||||
// Access: Public
|
||||
// Description: Opens the .txa file and simultaneously locks it (if
|
||||
// lock is true) for exclusive read/write access.
|
||||
// Returns true if successful, false on failure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AttribFile::
|
||||
open_and_lock(bool lock) {
|
||||
if (!_txa_filename.exists()) {
|
||||
@ -135,6 +153,12 @@ open_and_lock(bool lock) {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::close_and_unlock
|
||||
// Access: Public
|
||||
// Description: Simultaneously closes the .txa file and releases the
|
||||
// lock.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AttribFile::
|
||||
close_and_unlock() {
|
||||
// Closing the fstream will close the fd, and thus release all the
|
||||
@ -145,45 +169,71 @@ close_and_unlock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::rewind_and_truncate
|
||||
// Access: Public
|
||||
// Description: Rewinds the .txa file to the beginning and truncates
|
||||
// it in preparation for rewriting it, without releasing
|
||||
// the lock.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AttribFile::
|
||||
rewind_and_truncate() {
|
||||
#ifdef WIN32_VC
|
||||
// In Windows, since we're not implementing file locking right now,
|
||||
// we might as well just close and reopen the file. Which is good
|
||||
// since I don't know how to truncate an already-opened file in
|
||||
// Windows.
|
||||
_txa_fstrm.close();
|
||||
_txa_filename.unlink();
|
||||
_txa_filename.open_read_write(_txa_fstrm);
|
||||
#else
|
||||
// In Unix, we need to keep the file open so we don't lose the lock,
|
||||
// so we just rewind and then explicitly truncate the file with a
|
||||
// system call.
|
||||
_txa_fstrm.clear();
|
||||
_txa_fstrm.seekp(0, ios::beg);
|
||||
ftruncate(_txa_fd, 0);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::read
|
||||
// Access: Public
|
||||
// Description: Reads the .txa and .pi files.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AttribFile::
|
||||
read(bool force_redo_all) {
|
||||
bool okflag = true;
|
||||
|
||||
okflag = read_txa(_txa_fstrm);
|
||||
|
||||
{
|
||||
if (!_pi_filename.exists()) {
|
||||
nout << "Palette information file " << _pi_filename << " does not exist.\n";
|
||||
} else {
|
||||
ifstream infile;
|
||||
if (!_pi_filename.open_read(infile)) {
|
||||
nout << "Palette information file " << _pi_filename << " exists, but cannot be read.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
okflag = read_pi(infile, force_redo_all);
|
||||
if (!_pi_filename.exists()) {
|
||||
nout << "Palette information file " << _pi_filename << " does not exist.\n";
|
||||
} else {
|
||||
ifstream infile;
|
||||
if (!_pi_filename.open_read(infile)) {
|
||||
nout << "Palette information file " << _pi_filename << " exists, but cannot be read.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
okflag = read_pi(infile, force_redo_all);
|
||||
}
|
||||
|
||||
return okflag;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::write
|
||||
// Access: Public
|
||||
// Description: Rewrites the .txa and .pi files, if necessary.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AttribFile::
|
||||
write() {
|
||||
bool okflag = true;
|
||||
|
||||
if (_txa_needs_rewrite) {
|
||||
// Rewind and truncate the file for writing.
|
||||
#ifdef WIN32_VC
|
||||
_txa_fstrm.close();
|
||||
_txa_filename.unlink();
|
||||
_txa_filename.open_read_write(_txa_fstrm);
|
||||
#else
|
||||
_txa_fstrm.clear();
|
||||
_txa_fstrm.seekp(0, ios::beg);
|
||||
ftruncate(_txa_fd, 0);
|
||||
#endif
|
||||
|
||||
rewind_and_truncate();
|
||||
okflag = write_txa(_txa_fstrm) && okflag;
|
||||
_txa_fstrm << flush;
|
||||
}
|
||||
@ -243,6 +293,13 @@ write_egg_filename(Filename filename) const {
|
||||
return filename;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::update_params
|
||||
// Access: Public
|
||||
// Description: Reads the program parameters from the command line
|
||||
// (if they were specified), overriding whatever was
|
||||
// read from the .pi file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
update_params(EggPalettize *prog) {
|
||||
if (prog->_got_map_dirname) {
|
||||
@ -384,9 +441,14 @@ get_size_requests() {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the unused flags on all textures to accurately reflect
|
||||
// those that are unused by any egg files. Omit unused textures
|
||||
// from the palettizing set.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::update_texture_flags
|
||||
// Access: Public
|
||||
// Description: Update the unused flags on all textures to accurately
|
||||
// reflect those that are unused by any egg files. Omit
|
||||
// unused textures from the palettizing set.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
update_texture_flags() {
|
||||
// First, clear all the flags.
|
||||
@ -418,9 +480,14 @@ update_texture_flags() {
|
||||
}
|
||||
}
|
||||
|
||||
// Clear out all the old packing order and start again from the top.
|
||||
// This should get as nearly optimal a packing as this poor little
|
||||
// algorithm can manage.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::repack_all_textures
|
||||
// Access: Public
|
||||
// Description: Clear out all the old packing order and start again
|
||||
// from the top. This should get as nearly optimal a
|
||||
// packing as this poor little algorithm can manage.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
repack_all_textures() {
|
||||
// First, empty all the existing palette groups.
|
||||
@ -447,10 +514,15 @@ repack_all_textures() {
|
||||
_optimal = true;
|
||||
}
|
||||
|
||||
// Add new textures into the palettes without disturbing whatever was
|
||||
// already there. This won't generate an optimal palette, but it
|
||||
// won't require rebuilding every egg file that already uses this
|
||||
// palette.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::repack_some_textures
|
||||
// Access: Public
|
||||
// Description: Add new textures into the palettes without disturbing
|
||||
// whatever was already there. This won't generate an
|
||||
// optimal palette, but it won't require rebuilding
|
||||
// every egg file that already uses this palette.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
repack_some_textures() {
|
||||
bool empty_before = _groups.empty();
|
||||
@ -473,6 +545,11 @@ repack_some_textures() {
|
||||
_optimal = (empty_before || !any_added);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::optimal_resize
|
||||
// Access: Public
|
||||
// Description: Resizes each palette texture as small as it can be.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
optimal_resize() {
|
||||
Groups::iterator gi;
|
||||
@ -481,6 +558,12 @@ optimal_resize() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::finalize_palettes
|
||||
// Access: Public
|
||||
// Description: Sets up some final state on each palette, necessary
|
||||
// before writing them out.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
finalize_palettes() {
|
||||
Groups::iterator gi;
|
||||
@ -489,6 +572,14 @@ finalize_palettes() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::remove_unused_lines
|
||||
// Access: Public
|
||||
// Description: Removes any lines from the .txa file that weren't
|
||||
// used by any texture, presumably in response to -k on
|
||||
// the command line and in preparation for rewriting the
|
||||
// .txa file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
remove_unused_lines() {
|
||||
UserLines::iterator read, write;
|
||||
@ -541,11 +632,15 @@ prepare_repack(bool force_optimal) {
|
||||
return needs_repack;
|
||||
}
|
||||
|
||||
|
||||
// Updates the timestamp on each egg file that will need to be
|
||||
// rebuilt, so that a future make process will pick it up. This is
|
||||
// only necessary to update egg files that may not have been included
|
||||
// on the command line, and which we don't have direct access to.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::touch_dirty_egg_files
|
||||
// Access: Public
|
||||
// Description: Updates the timestamp on each egg file that will need
|
||||
// to be rebuilt, so that a future make process will
|
||||
// pick it up. This is only necessary to update egg
|
||||
// files that may not have been included on the command
|
||||
// line, and which we don't have direct access to.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AttribFile::
|
||||
touch_dirty_egg_files(bool force_redo_all,
|
||||
bool eggs_include_images) {
|
||||
@ -564,7 +659,14 @@ touch_dirty_egg_files(bool force_redo_all,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AttribFile::get_texture
|
||||
// Access: Public
|
||||
// Description: Returns a pointer to the particular texture with the
|
||||
// indicated name. If the named PTexture does not exist
|
||||
// in the AttribFile structure, creates one and returns
|
||||
// it.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PTexture *AttribFile::
|
||||
get_texture(const string &name) {
|
||||
PTextures::iterator ti;
|
||||
|
@ -26,7 +26,10 @@ class PNMFileType;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : AttribFile
|
||||
// Description :
|
||||
// Description : The primary driving object behind egg-palettize, this
|
||||
// class represents both a .txa file and its associated
|
||||
// .pi file, as well as containing pointers to all the
|
||||
// textures, palettes, and egg files referenced.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class AttribFile {
|
||||
public:
|
||||
@ -36,6 +39,7 @@ public:
|
||||
|
||||
bool open_and_lock(bool lock);
|
||||
bool close_and_unlock();
|
||||
bool rewind_and_truncate();
|
||||
|
||||
bool read(bool force_redo_all);
|
||||
bool write();
|
||||
|
@ -302,6 +302,11 @@ update_trefs() {
|
||||
Palette *palette = packing->get_palette();
|
||||
|
||||
eggtex->set_filename(_attrib_file->write_egg_filename(palette->get_filename()));
|
||||
if (palette->has_alpha_filename()) {
|
||||
eggtex->set_alpha_file(_attrib_file->write_egg_filename(palette->get_alpha_filename()));
|
||||
} else {
|
||||
eggtex->clear_alpha_file();
|
||||
}
|
||||
|
||||
// Set the texture attributes to be uniform across all palettes.
|
||||
eggtex->set_minfilter(EggTexture::FT_mipmap_trilinear);
|
||||
|
@ -63,7 +63,7 @@ require_groups(PaletteGroup *preferred, const PaletteGroups &groups) {
|
||||
|
||||
// For now, we arbitrarily pick the preferred group. Later, maybe
|
||||
// we'll try to be smart about this and do some kind of graph
|
||||
// minimization to choose the group the leads to the least redundant
|
||||
// packing.
|
||||
// minimization to choose the group that leads to the least
|
||||
// redundant packing.
|
||||
_packing = _texture->add_to_group(preferred);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class EggTexture;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : TextureEggRef
|
||||
// Description : This associates a texture with the egg files it is
|
||||
// placed on, and also associated an egg file with the
|
||||
// placed on, and also associates an egg file with the
|
||||
// various textures it contains.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class TextureEggRef {
|
||||
|
@ -38,10 +38,10 @@ EggMultiFilter(bool allow_empty) : _allow_empty(allow_empty) {
|
||||
|
||||
add_option
|
||||
("inplace", "", 50,
|
||||
"If this option is given, the input files will be rewritten in place with "
|
||||
"the results. This obviates the need to specify -d for an output "
|
||||
"directory; however, it's risky because the original input "
|
||||
"files are lost.",
|
||||
"If this option is given, the input egg files will be rewritten in "
|
||||
"place with the results. This obviates the need to specify -d "
|
||||
"for an output directory; however, it's risky because the original "
|
||||
"input egg files are lost.",
|
||||
&EggMultiFilter::dispatch_none, &_inplace);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user