*** empty log message ***

This commit is contained in:
David Rose 2001-04-26 21:42:52 +00:00
parent fcdafa6e98
commit ca73e4b415
30 changed files with 632 additions and 153 deletions

View File

@ -0,0 +1,19 @@
#begin ss_lib_target
#define TARGET converter
#define LOCAL_LIBS pandatoolbase
#define OTHER_LIBS \
egg:c pandaegg:m \
mathutil:c linmath:c putil:c express:c panda:m dtoolconfig dtool
#define UNIX_SYS_LIBS \
m
#define SOURCES \
distanceUnit.cxx distanceUnit.h \
somethingToEggConverter.I somethingToEggConverter.cxx \
somethingToEggConverter.h
#define INSTALL_HEADERS \
distanceUnit.h \
somethingToEggConverter.I somethingToEggConverter.h
#end ss_lib_target

View File

@ -0,0 +1,74 @@
// Filename: somethingToEggConverter.I
// Created by: drose (26Apr01)
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::set_texture_path_convert
// Access: Public
// Description: Sets the mode for converting texture paths extracted
// from the source file. The following options are
// defined:
//
// PC_relative - texture pathnames are made relative
// to the indicated tpc_directory.
//
// PC_absolute - textures are looked up along the
// search path and then converted to absolute
// filenames. tpc_directory is ignored.
//
// PC_rel_abs - as above, but the resulting filename
// is guaranteed to be relative to tpc_directory, and
// may include a number of ../ paths to guarantee
// this, if necessary.
//
// PC_strip - pathname components are stripped from
// the texture names, and only the base filename is
// retained.
//
// PC_unchanged - texture pathnames are left exactly
// as they appear in the source file.
////////////////////////////////////////////////////////////////////
INLINE void SomethingToEggConverter::
set_texture_path_convert(PathConvert tpc,
const Filename &tpc_directory) {
_tpc = tpc;
_tpc_directory = tpc_directory;
}
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::set_model_path_convert
// Access: Public
// Description: Sets the mode for converting model paths extracted
// from the source file. These are typically for
// external references. See set_texture_path_convert
// for a complete list of PathConvert values and their
// interpretations.
////////////////////////////////////////////////////////////////////
INLINE void SomethingToEggConverter::
set_model_path_convert(PathConvert mpc,
const Filename &mpc_directory) {
_mpc = mpc;
_mpc_directory = mpc_directory;
}
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::clear_egg_data
// Access: Public
// Description: Sets the EggData to NULL and makes the converter
// invalid.
////////////////////////////////////////////////////////////////////
INLINE void SomethingToEggConverter::
clear_egg_data() {
set_egg_data((EggData *)NULL, false);
}
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::get_egg_data
// Access: Public
// Description: Returns the EggData structure.
////////////////////////////////////////////////////////////////////
INLINE EggData &SomethingToEggConverter::
get_egg_data() {
return *_egg_data;
}

View File

@ -0,0 +1,51 @@
// Filename: somethingToEggConverter.cxx
// Created by: drose (26Apr01)
//
////////////////////////////////////////////////////////////////////
#include "somethingToEggConverter.h"
#include <eggData.h>
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
SomethingToEggConverter::
SomethingToEggConverter() {
_egg_data = (EggData *)NULL;
_owns_egg_data = false;
_tpc = PC_unchanged;
_mpc = PC_unchanged;
_error = false;
}
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
SomethingToEggConverter::
~SomethingToEggConverter() {
clear_egg_data();
}
////////////////////////////////////////////////////////////////////
// Function: SomethingToEggConverter::set_egg_data
// Access: Public
// Description: Sets the egg data that will be filled in when
// convert_file() is called. This must be called before
// convert_file(). If owns_egg_data is true, the
// egg_data will be deleted when the converter
// destructs. (We don't use the reference counting on
// EggData, to allow static EggDatas to be passed in.)
////////////////////////////////////////////////////////////////////
void SomethingToEggConverter::
set_egg_data(EggData *egg_data, bool owns_egg_data) {
if (_owns_egg_data) {
delete _egg_data;
}
_egg_data = egg_data;
_owns_egg_data = owns_egg_data;
}

View File

@ -0,0 +1,67 @@
// Filename: somethingToEggConverter.h
// Created by: drose (17Apr01)
//
////////////////////////////////////////////////////////////////////
#ifndef SOMETHINGTOEGGCONVERTER_H
#define SOMETHINGTOEGGCONVERTER_H
#include <pandatoolbase.h>
#include <filename.h>
class EggData;
////////////////////////////////////////////////////////////////////
// Class : SomethingToEggConverter
// Description : This is a base class for a family of converter
// classes that manage a conversion from some file type
// to egg format.
//
// Classes of this type can be used to implement xxx2egg
// converter programs, as well as LoaderFileTypeXXX
// run-time loaders.
////////////////////////////////////////////////////////////////////
class SomethingToEggConverter {
public:
SomethingToEggConverter();
virtual ~SomethingToEggConverter();
enum PathConvert {
PC_relative,
PC_absolute,
PC_rel_abs,
PC_strip,
PC_unchanged
};
INLINE void set_texture_path_convert(PathConvert tpc,
const Filename &tpc_directory = Filename());
INLINE void set_model_path_convert(PathConvert mpc,
const Filename &mpc_directory = Filename());
void set_egg_data(EggData *egg_data, bool owns_egg_data);
INLINE void clear_egg_data();
INLINE EggData &get_egg_data();
virtual string get_name() const=0;
virtual string get_extension() const=0;
virtual bool convert_file(const Filename &filename)=0;
protected:
PathConvert _tpc;
Filename _tpc_directory;
PathConvert _mpc;
Filename _mpc_directory;
EggData *_egg_data;
bool _owns_egg_data;
bool _error;
};
#include "somethingToEggConverter.I"
#endif

View File

@ -1,5 +1,5 @@
#define LOCAL_LIBS \
eggbase progbase
converter eggbase progbase
#define OTHER_LIBS \
egg:c linmath:c putil:c express:c pandaegg:m panda:m pandaexpress:m \
dtoolutil:c dconfig:c dtoolconfig:m dtool:m pystub

View File

@ -50,42 +50,16 @@ LwoToEgg() :
////////////////////////////////////////////////////////////////////
void LwoToEgg::
run() {
LwoInputFile in;
nout << "Reading " << _input_filename << "\n";
if (!in.open_read(_input_filename)) {
nout << "Unable to open " << _input_filename << "\n";
exit(1);
}
PT(IffChunk) chunk = in.get_chunk();
if (chunk == (IffChunk *)NULL) {
nout << "Unable to read " << _input_filename << "\n";
exit(1);
}
if (!chunk->is_of_type(LwoHeader::get_class_type())) {
nout << "File " << _input_filename << " is not a Lightwave Object file.\n";
exit(1);
}
LwoHeader *header = DCAST(LwoHeader, chunk);
if (!header->is_valid()) {
nout << "File " << _input_filename
<< " is not recognized as a Lightwave Object file. "
<< "Perhaps the version is too recent.\n";
exit(1);
}
_data.set_coordinate_system(_coordinate_system);
if (_input_units == DU_invalid) {
_input_units = DU_meters;
}
LwoToEggConverter converter(_data);
LwoToEggConverter converter;
converter.set_egg_data(&_data, false);
if (!converter.convert_lwo(header)) {
if (!converter.convert_file(_input_filename)) {
nout << "Errors in conversion.\n";
exit(1);
}

View File

@ -1,6 +1,6 @@
#begin ss_lib_target
#define TARGET flt
#define LOCAL_LIBS progbase pandatoolbase
#define LOCAL_LIBS converter pandatoolbase
#define OTHER_LIBS \
mathutil:c linmath:c putil:c express:c panda:m dtoolconfig dtool
#define UNIX_SYS_LIBS \

View File

@ -1,6 +1,6 @@
#begin ss_lib_target
#define TARGET fltegg
#define LOCAL_LIBS pandatoolbase progbase flt
#define LOCAL_LIBS converter flt pandatoolbase
#define OTHER_LIBS \
egg:c pandaegg:m \
mathutil:c linmath:c putil:c express:c panda:m dtoolconfig dtool

View File

@ -3,48 +3,3 @@
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: FltToEggConverter::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE FltToEggConverter::
~FltToEggConverter() {
}
////////////////////////////////////////////////////////////////////
// Function: FltToEggConverter::set_texture_path_convert
// Access: Public
// Description: Sets the mode for converting texture paths extracted
// from the flt file. If this is PC_relative, the
// texture paths are made relative to the indicated
// directory; if it is PC_absolute, they are made
// absolute to the indicated directory. PC_unchanged
// leaves them alone (and the directory, if specified,
// is ignored).
////////////////////////////////////////////////////////////////////
INLINE void FltToEggConverter::
set_texture_path_convert(PathConvert tpc,
const Filename &tpc_directory) {
_tpc = tpc;
_tpc_directory = tpc_directory;
}
////////////////////////////////////////////////////////////////////
// Function: FltToEggConverter::set_model_path_convert
// Access: Public
// Description: Sets the mode for converting model paths extracted
// from the flt file. If this is PC_relative, the
// model paths are made relative to the indicated
// directory; if it is PC_absolute, they are made
// absolute to the indicated directory. PC_unchanged
// leaves them alone (and the directory, if specified,
// is ignored).
////////////////////////////////////////////////////////////////////
INLINE void FltToEggConverter::
set_model_path_convert(PathConvert mpc,
const Filename &mpc_directory) {
_mpc = mpc;
_mpc_directory = mpc_directory;
}

View File

@ -15,6 +15,7 @@
#include <fltVertex.h>
#include <fltVertexList.h>
#include <fltExternalReference.h>
#include <eggData.h>
#include <eggGroup.h>
#include <eggSwitchCondition.h>
#include <eggPrimitive.h>
@ -32,10 +33,57 @@
// Description:
////////////////////////////////////////////////////////////////////
FltToEggConverter::
FltToEggConverter(EggData &egg_data) : _egg_data(egg_data) {
_tpc = PC_unchanged;
_mpc = PC_unchanged;
_error = false;
FltToEggConverter() {
}
////////////////////////////////////////////////////////////////////
// Function: FltToEggConverter::get_name
// Access: Public, Virtual
// Description: Returns the English name of the file type this
// converter supports.
////////////////////////////////////////////////////////////////////
string FltToEggConverter::
get_name() const {
return "MultiGen";
}
////////////////////////////////////////////////////////////////////
// Function: FltToEggConverter::get_extension
// Access: Public, Virtual
// Description: Returns the common extension of the file type this
// converter supports.
////////////////////////////////////////////////////////////////////
string FltToEggConverter::
get_extension() const {
return "flt";
}
////////////////////////////////////////////////////////////////////
// Function: FltToEggConverter::convert_file
// Access: Public, Virtual
// Description: Handles the reading of the input file and converting
// it to egg. Returns true if successful, false
// otherwise.
//
// This is designed to be as generic as possible,
// generally in support of run-time loading.
// Command-line converters may choose to use
// convert_flt() instead, as it provides more control.
////////////////////////////////////////////////////////////////////
bool FltToEggConverter::
convert_file(const Filename &filename) {
PT(FltHeader) header = new FltHeader;
nout << "Reading " << filename << "\n";
FltError result = header->read_flt(filename);
if (result != FE_ok) {
nout << "Unable to read: " << result << "\n";
return false;
}
header->check_version();
return convert_flt(header);
}
////////////////////////////////////////////////////////////////////
@ -46,12 +94,16 @@ FltToEggConverter(EggData &egg_data) : _egg_data(egg_data) {
////////////////////////////////////////////////////////////////////
bool FltToEggConverter::
convert_flt(const FltHeader *flt_header) {
if (_egg_data->get_coordinate_system() == CS_default) {
_egg_data->set_coordinate_system(CS_zup_right);
}
_error = false;
_flt_header = flt_header;
// Generate a default vertex pool.
_main_egg_vpool = new EggVertexPool("vpool");
_egg_data.add_child(_main_egg_vpool);
_egg_data->add_child(_main_egg_vpool);
// We could populate the vertex pool right away, but it's better to
// defer each vertex until we encounter it, since some of the
@ -60,13 +112,13 @@ convert_flt(const FltHeader *flt_header) {
// something).
FltToEggLevelState state;
state._egg_parent = &_egg_data;
state._egg_parent = _egg_data;
convert_record(_flt_header, state);
if (_main_egg_vpool->empty()) {
// If we didn't get any global vertices, remove the vertex pool
// just for cleanliness.
_egg_data.remove_child(_main_egg_vpool);
_egg_data->remove_child(_main_egg_vpool);
}
return !_error;
@ -641,6 +693,9 @@ convert_path(const Filename &orig_filename, const Filename &as_found,
result = Filename(rel_dir, result);
return result;
case PC_strip:
return orig_filename.get_basename();
case PC_unchanged:
return orig_filename;
}

View File

@ -10,10 +10,8 @@
#include "fltToEggLevelState.h"
#include <distanceUnit.h>
#include <somethingToEggConverter.h>
#include <fltHeader.h>
#include <eggData.h>
#include <eggVertex.h>
#include <eggTexture.h>
#include <pointerTo.h>
@ -40,22 +38,14 @@ class EggVertexPool;
// Reading and writing the egg and flt structures is
// left to the user.
////////////////////////////////////////////////////////////////////
class FltToEggConverter {
class FltToEggConverter : public SomethingToEggConverter {
public:
FltToEggConverter(EggData &egg_data);
INLINE ~FltToEggConverter();
FltToEggConverter();
enum PathConvert {
PC_relative,
PC_absolute,
PC_rel_abs,
PC_unchanged
};
INLINE void set_texture_path_convert(PathConvert tpc,
const Filename &tpc_directory = Filename());
INLINE void set_model_path_convert(PathConvert mpc,
const Filename &mpc_directory = Filename());
virtual string get_name() const;
virtual string get_extension() const;
virtual bool convert_file(const Filename &filename);
bool convert_flt(const FltHeader *flt_header);
private:
@ -92,20 +82,12 @@ private:
PT(EggVertex) make_egg_vertex(const FltVertex *flt_vertex);
PT(EggTexture) make_egg_texture(const FltTexture *flt_texture);
PathConvert _tpc;
Filename _tpc_directory;
PathConvert _mpc;
Filename _mpc_directory;
EggData &_egg_data;
CPT(FltHeader) _flt_header;
EggVertexPool *_main_egg_vpool;
typedef map<const FltTexture *, PT(EggTexture) > Textures;
Textures _textures;
bool _error;
};
#include "fltToEggConverter.I"

View File

@ -131,7 +131,8 @@ run() {
_input_units = header->get_units();
}
FltToEggConverter converter(_data);
FltToEggConverter converter;
converter.set_egg_data(&_data, false);
converter.set_texture_path_convert(_texture_path_convert, _make_rel_dir);
converter.set_model_path_convert(_model_path_convert, _make_rel_dir);

View File

@ -1,6 +1,6 @@
#begin ss_lib_target
#define TARGET lwoegg
#define LOCAL_LIBS pandatoolbase lwo
#define LOCAL_LIBS converter lwo pandatoolbase
#define OTHER_LIBS \
egg:c pandaegg:m \
mathutil:c linmath:c putil:c express:c panda:m dtoolconfig dtool

View File

@ -6,6 +6,8 @@
#include "cLwoLayer.h"
#include "lwoToEggConverter.h"
#include <eggData.h>
////////////////////////////////////////////////////////////////////
// Function: CLwoLayer::make_egg
@ -44,6 +46,6 @@ connect_egg() {
<< "; cannot parent layer " << _layer->_number << " properly.\n";
}
_converter->get_egg_root()->add_child(_egg_group.p());
_converter->get_egg_data().add_child(_egg_group.p());
}

View File

@ -11,6 +11,7 @@
#include <lwoPolygonTags.h>
#include <lwoTags.h>
#include <eggData.h>
#include <eggPolygon.h>
#include <eggPoint.h>
#include <deg_2_rad.h>

View File

@ -2,25 +2,3 @@
// Created by: drose (25Apr01)
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::get_egg_root
// Access: Public
// Description: Returns a root node suitable for parenting egg
// structures to.
////////////////////////////////////////////////////////////////////
INLINE EggGroupNode *LwoToEggConverter::
get_egg_root() const {
return &_egg_data;
}
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::get_egg_data
// Access: Public
// Description: Returns the EggData structure.
////////////////////////////////////////////////////////////////////
INLINE EggData &LwoToEggConverter::
get_egg_data() {
return _egg_data;
}

View File

@ -9,6 +9,7 @@
#include "cLwoPolygons.h"
#include "cLwoSurface.h"
#include <eggData.h>
#include <lwoHeader.h>
#include <lwoLayer.h>
#include <lwoPoints.h>
@ -16,6 +17,7 @@
#include <lwoVertexMap.h>
#include <lwoTags.h>
#include <lwoPolygonTags.h>
#include <lwoInputFile.h>
////////////////////////////////////////////////////////////////////
@ -24,14 +26,13 @@
// Description:
////////////////////////////////////////////////////////////////////
LwoToEggConverter::
LwoToEggConverter(EggData &egg_data) : _egg_data(egg_data) {
LwoToEggConverter() {
_generic_layer = (CLwoLayer *)NULL;
_error = false;
}
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::Destructor
// Access: Public
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
LwoToEggConverter::
@ -67,6 +68,72 @@ LwoToEggConverter::
}
}
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::get_name
// Access: Public, Virtual
// Description: Returns the English name of the file type this
// converter supports.
////////////////////////////////////////////////////////////////////
string LwoToEggConverter::
get_name() const {
return "Lightwave";
}
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::get_extension
// Access: Public, Virtual
// Description: Returns the common extension of the file type this
// converter supports.
////////////////////////////////////////////////////////////////////
string LwoToEggConverter::
get_extension() const {
return "lwo";
}
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::convert_file
// Access: Public, Virtual
// Description: Handles the reading of the input file and converting
// it to egg. Returns true if successful, false
// otherwise.
//
// This is designed to be as generic as possible,
// generally in support of run-time loading.
// Command-line converters may choose to use
// convert_lwo() instead, as it provides more control.
////////////////////////////////////////////////////////////////////
bool LwoToEggConverter::
convert_file(const Filename &filename) {
LwoInputFile in;
nout << "Reading " << filename << "\n";
if (!in.open_read(filename)) {
nout << "Unable to open " << filename << "\n";
return false;
}
PT(IffChunk) chunk = in.get_chunk();
if (chunk == (IffChunk *)NULL) {
nout << "Unable to read " << filename << "\n";
return false;
}
if (!chunk->is_of_type(LwoHeader::get_class_type())) {
nout << "File " << filename << " is not a Lightwave Object file.\n";
return false;
}
LwoHeader *header = DCAST(LwoHeader, chunk);
if (!header->is_valid()) {
nout << "File " << filename
<< " is not recognized as a Lightwave Object file. "
<< "Perhaps the version is too recent.\n";
return false;
}
return convert_lwo(header);
}
////////////////////////////////////////////////////////////////////
// Function: LwoToEggConverter::convert_lwo
// Access: Public
@ -75,13 +142,18 @@ LwoToEggConverter::
////////////////////////////////////////////////////////////////////
bool LwoToEggConverter::
convert_lwo(const LwoHeader *lwo_header) {
if (_egg_data->get_coordinate_system() == CS_default) {
_egg_data->set_coordinate_system(CS_yup_left);
}
_error = false;
_lwo_header = lwo_header;
collect_lwo();
make_egg();
connect_egg();
_egg_data.remove_unused_vertices();
_egg_data->remove_unused_vertices();
return !_error;
}

View File

@ -8,8 +8,8 @@
#include <pandatoolbase.h>
#include <somethingToEggConverter.h>
#include <lwoHeader.h>
#include <eggData.h>
#include <pointerTo.h>
#include <vector>
@ -27,15 +27,17 @@ class CLwoSurface;
// Reading and writing the egg and lwo structures is
// left to the user.
////////////////////////////////////////////////////////////////////
class LwoToEggConverter {
class LwoToEggConverter : public SomethingToEggConverter {
public:
LwoToEggConverter(EggData &egg_data);
~LwoToEggConverter();
LwoToEggConverter();
virtual ~LwoToEggConverter();
virtual string get_name() const;
virtual string get_extension() const;
virtual bool convert_file(const Filename &filename);
bool convert_lwo(const LwoHeader *lwo_header);
INLINE EggGroupNode *get_egg_root() const;
INLINE EggData &get_egg_data();
CLwoLayer *get_layer(int number) const;
CLwoSurface *get_surface(const string &name) const;
@ -48,7 +50,6 @@ private:
void slot_layer(int number);
CLwoLayer *make_generic_layer();
EggData &_egg_data;
CPT(LwoHeader) _lwo_header;
CLwoLayer *_generic_layer;
@ -63,8 +64,6 @@ private:
typedef map<string, CLwoSurface *> Surfaces;
Surfaces _surfaces;
bool _error;
};
#include "lwoToEggConverter.I"

View File

@ -2,9 +2,9 @@
#define TARGET pandatoolbase
#define SOURCES \
pandatoolbase.cxx pandatoolbase.h
pandatoolbase.cxx pandatoolbase.h pandatoolsymbols.h
#define INSTALL_HEADERS \
pandatoolbase.h
pandatoolbase.h pandatoolsymbols.h
#end ss_lib_target

View File

@ -12,6 +12,7 @@
#define PANDATOOLBASE_H
#include <pandabase.h>
#include "pandatoolsymbols.h"
#endif

View File

@ -0,0 +1,30 @@
/*
// Filename: pandatoolsymbols.h
// Created by: drose (26Apr01)
//
////////////////////////////////////////////////////////////////////
*/
#ifndef PANDATOOLSYMBOLS_H
#define PANDATOOLSYMBOLS_H
/* See dtoolsymbols.h for a rant on the purpose of this file. */
#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC)
#ifdef BUILDING_PTLOADER
#define EXPCL_PTLOADER __declspec(dllexport)
#define EXPTP_PTLOADER
#else
#define EXPCL_PTLOADER __declspec(dllimport)
#define EXPTP_PTLOADER extern
#endif
#else /* !WIN32_VC */
#define EXPCL_PTLOADER
#define EXPTP_PTLOADER
#endif /* WIN32_VC */
#endif

View File

@ -1,12 +1,11 @@
#begin ss_lib_target
#define TARGET progbase
#define LOCAL_LIBS \
pandatoolbase
converter pandatoolbase
#define OTHER_LIBS \
linmath:c putil:c express:c panda:m pystub dtool
#define SOURCES \
distanceUnit.cxx distanceUnit.h \
programBase.I programBase.cxx programBase.h \
withOutputFile.cxx withOutputFile.h \
wordWrapStream.cxx \
@ -14,7 +13,6 @@
wordWrapStreamBuf.h
#define INSTALL_HEADERS \
distanceUnit.h \
programBase.I programBase.h \
withOutputFile.h \
wordWrapStream.h wordWrapStreamBuf.I \

View File

@ -8,8 +8,7 @@
#include <pandatoolbase.h>
#include "distanceUnit.h"
#include <distanceUnit.h>
#include <filename.h>
#include <vector_string.h>

View File

@ -0,0 +1,18 @@
#begin lib_target
#define TARGET ptloader
#define BUILDING_DLL BUILDING_PTLOADER
#define LOCAL_LIBS fltegg flt lwoegg lwo converter pandatoolbase
#define OTHER_LIBS \
egg2sg:c builder:c egg:c pandaegg:m \
mathutil:c linmath:c putil:c express:c panda:m dtoolconfig dtool
#define UNIX_SYS_LIBS \
m
#define SOURCES \
config_ptloader.cxx config_ptloader.h \
loaderFileTypePandatool.cxx loaderFileTypePandatool.h
#define INSTALL_HEADERS \
config_ptloader.h loaderFileTypePandatool.h
#end lib_target

View File

@ -0,0 +1,47 @@
// Filename: config_ptloader.cxx
// Created by: drose (26Apr01)
//
////////////////////////////////////////////////////////////////////
#include "config_ptloader.h"
#include "loaderFileTypePandatool.h"
#include <fltToEggConverter.h>
#include <lwoToEggConverter.h>
#include <dconfig.h>
#include <loaderFileTypeRegistry.h>
#include <eggData.h>
ConfigureDef(config_ptloader);
ConfigureFn(config_ptloader) {
init_libptloader();
}
////////////////////////////////////////////////////////////////////
// Function: init_libptloader
// Description: Initializes the library. This must be called at
// least once before any of the functions or classes in
// this library can be used. Normally it will be
// called by the static initializers and need not be
// called explicitly, but special cases exist.
////////////////////////////////////////////////////////////////////
void
init_libptloader() {
static bool initialized = false;
if (initialized) {
return;
}
initialized = true;
LoaderFileTypePandatool::init_type();
LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_ptr();
FltToEggConverter *flt = new FltToEggConverter;
reg->register_type(new LoaderFileTypePandatool(flt));
LwoToEggConverter *lwo = new LwoToEggConverter;
reg->register_type(new LoaderFileTypePandatool(lwo));
}

View File

@ -0,0 +1,17 @@
// Filename: config_ptloader.h
// Created by: drose (26Apr01)
//
////////////////////////////////////////////////////////////////////
#ifndef CONFIG_PTLOADER_H
#define CONFIG_PTLOADER_H
#include <pandatoolbase.h>
#include <dconfig.h>
ConfigureDecl(config_ptloader, EXPCL_PANDAEGG, EXPTP_PANDAEGG);
extern EXPCL_PTLOADER void init_libptloader();
#endif

View File

@ -0,0 +1,84 @@
// Filename: loaderFileTypePandatool.cxx
// Created by: drose (26Apr01)
//
////////////////////////////////////////////////////////////////////
#include "loaderFileTypePandatool.h"
#include <somethingToEggConverter.h>
#include <config_util.h>
#include <load_egg_file.h>
#include <eggData.h>
TypeHandle LoaderFileTypePandatool::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: LoaderFileTypePandatool::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
LoaderFileTypePandatool::
LoaderFileTypePandatool(SomethingToEggConverter *converter) :
_converter(converter)
{
}
////////////////////////////////////////////////////////////////////
// Function: LoaderFileTypePandatool::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
LoaderFileTypePandatool::
~LoaderFileTypePandatool() {
}
////////////////////////////////////////////////////////////////////
// Function: LoaderFileTypePandatool::get_name
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
string LoaderFileTypePandatool::
get_name() const {
return _converter->get_name();
}
////////////////////////////////////////////////////////////////////
// Function: LoaderFileTypePandatool::get_extension
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
string LoaderFileTypePandatool::
get_extension() const {
return _converter->get_extension();
}
////////////////////////////////////////////////////////////////////
// Function: LoaderFileTypePandatool::resolve_filename
// Access: Public, Virtual
// Description: Searches for the indicated filename on whatever paths
// are appropriate to this file type, and updates it if
// it is found.
////////////////////////////////////////////////////////////////////
void LoaderFileTypePandatool::
resolve_filename(Filename &path) const {
path.resolve_filename(get_model_path(), get_extension());
}
////////////////////////////////////////////////////////////////////
// Function: LoaderFileTypePandatool::load_file
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
PT_Node LoaderFileTypePandatool::
load_file(const Filename &path, bool) const {
PT_NamedNode result;
EggData egg_data;
_converter->set_egg_data(&egg_data, false);
if (_converter->convert_file(path)) {
egg_data.set_coordinate_system(CS_default);
result = load_egg_data(egg_data);
}
_converter->clear_egg_data();
return result.p();
}

View File

@ -0,0 +1,55 @@
// Filename: loaderFileTypePandatool.h
// Created by: drose (20Jun00)
//
////////////////////////////////////////////////////////////////////
#ifndef LOADERFILETYPEPANDATOOL_H
#define LOADERFILETYPEPANDATOOL_H
#include <pandatoolbase.h>
#include <loaderFileType.h>
class SomethingToEggConverter;
////////////////////////////////////////////////////////////////////
// Class : LoaderFileTypePandatool
// Description : This defines the Loader interface to files whose
// converters are defined within the Pandatool package
// and inherit from SomethingToEggConverter, like
// FltToEggConverter and LwoToEggConverter.
////////////////////////////////////////////////////////////////////
class EXPCL_PTLOADER LoaderFileTypePandatool : public LoaderFileType {
public:
LoaderFileTypePandatool(SomethingToEggConverter *converter);
virtual ~LoaderFileTypePandatool();
virtual string get_name() const;
virtual string get_extension() const;
virtual void resolve_filename(Filename &path) const;
virtual PT_Node load_file(const Filename &path, bool report_errors) const;
private:
SomethingToEggConverter *_converter;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
LoaderFileType::init_type();
register_type(_type_handle, "LoaderFileTypePandatool",
LoaderFileType::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#endif