From 8ecf040e27e7822544352d87db73160e6e92d07a Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 2 Oct 2004 15:38:25 +0000 Subject: [PATCH] resurrect x converter --- pandatool/src/ptloader/Sources.pp | 6 +- pandatool/src/ptloader/config_ptloader.cxx | 4 -- pandatool/src/xfile/Sources.pp | 9 +-- pandatool/src/xfile/xFileToEggConverter.cxx | 74 ++++++++++++++------- pandatool/src/xfileprogs/Sources.pp | 11 +-- pandatool/src/xfileprogs/xFileToEgg.cxx | 10 +-- 6 files changed, 72 insertions(+), 42 deletions(-) diff --git a/pandatool/src/ptloader/Sources.pp b/pandatool/src/ptloader/Sources.pp index 29e783da76..3834c32f99 100644 --- a/pandatool/src/ptloader/Sources.pp +++ b/pandatool/src/ptloader/Sources.pp @@ -2,7 +2,8 @@ #define TARGET ptloader #define BUILDING_DLL BUILDING_PTLOADER #define LOCAL_LIBS \ - fltegg flt lwoegg lwo dxfegg dxf vrmlegg pvrml converter pandatoolbase + fltegg flt lwoegg lwo dxfegg dxf vrmlegg pvrml xfile \ + converter pandatoolbase #define OTHER_LIBS \ egg2pg:c builder:c egg:c pandaegg:m \ mathutil:c linmath:c putil:c \ @@ -17,6 +18,9 @@ #define UNIX_SYS_LIBS \ m + #define WIN_SYS_LIBS \ + d3dxof.lib dxguid.lib d3d8.lib d3dx8.lib dxerr8.lib + #define SOURCES \ config_ptloader.cxx config_ptloader.h \ loaderFileTypePandatool.cxx loaderFileTypePandatool.h diff --git a/pandatool/src/ptloader/config_ptloader.cxx b/pandatool/src/ptloader/config_ptloader.cxx index da2079a08e..5f6879e99c 100644 --- a/pandatool/src/ptloader/config_ptloader.cxx +++ b/pandatool/src/ptloader/config_ptloader.cxx @@ -26,12 +26,10 @@ #include "dxfToEggConverter.h" #include "vrmlToEggConverter.h" -/* #ifdef HAVE_DX #include "config_xfile.h" #include "xFileToEggConverter.h" #endif -*/ #include "dconfig.h" #include "loaderFileTypeRegistry.h" @@ -89,13 +87,11 @@ init_libptloader() { VRMLToEggConverter *vrml = new VRMLToEggConverter; reg->register_type(new LoaderFileTypePandatool(vrml)); - /* #ifdef HAVE_DX init_libxfile(); XFileToEggConverter *xfile = new XFileToEggConverter; reg->register_type(new LoaderFileTypePandatool(xfile)); #endif - */ #ifdef HAVE_MAYA // Register the Maya converter as a deferred type. We don't compile diff --git a/pandatool/src/xfile/Sources.pp b/pandatool/src/xfile/Sources.pp index d18628749e..3473ef5d80 100644 --- a/pandatool/src/xfile/Sources.pp +++ b/pandatool/src/xfile/Sources.pp @@ -1,7 +1,8 @@ -// This package is temporarily disabled. -#define BUILD_DIRECTORY -//#define BUILD_DIRECTORY $[HAVE_DX] +// The .x converter takes advantage of the DirectX API's; therefore, +// it can only be built if we have DX available (and therefore it only +// builds on Windows--sorry). +#define BUILD_DIRECTORY $[HAVE_DX] #define USE_PACKAGES dx #begin ss_lib_target @@ -14,7 +15,7 @@ dtoolconfig dtool pystub \ #define WIN_SYS_LIBS \ - d3dxof.lib dxguid.lib + d3dxof.lib dxguid.lib d3d8.lib d3dx8.lib dxerr8.lib #define COMBINED_SOURCES $[TARGET]_composite1.cxx diff --git a/pandatool/src/xfile/xFileToEggConverter.cxx b/pandatool/src/xfile/xFileToEggConverter.cxx index 61c7ad298d..8aea646ac3 100644 --- a/pandatool/src/xfile/xFileToEggConverter.cxx +++ b/pandatool/src/xfile/xFileToEggConverter.cxx @@ -231,9 +231,11 @@ convert_object(LPDIRECTXFILEOBJECT obj, EggGroupNode *egg_parent) { } // It isn't. - xfile_cat.error() - << "Ignoring object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring object of unknown type: " + << get_object_name(obj) << "\n"; + } return true; } @@ -276,9 +278,11 @@ convert_data_object(LPDIRECTXFILEDATA obj, EggGroupNode *egg_parent) { } } else { - xfile_cat.error() - << "Ignoring data object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring data object of unknown type: " + << get_object_name(obj) << "\n"; + } } return true; @@ -416,9 +420,11 @@ convert_mesh_object(LPDIRECTXFILEOBJECT obj, XFileMesh &mesh) { } // It isn't. - xfile_cat.error() - << "Ignoring object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring mesh object of unknown type: " + << get_object_name(obj) << "\n"; + } return true; } @@ -462,9 +468,11 @@ convert_mesh_data_object(LPDIRECTXFILEDATA obj, XFileMesh &mesh) { } } else { - xfile_cat.error() - << "Ignoring data object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring mesh data object of unknown type: " + << get_object_name(obj) << "\n"; + } } return true; @@ -581,6 +589,7 @@ bool XFileToEggConverter:: convert_material_list_object(LPDIRECTXFILEOBJECT obj, XFileMesh &mesh) { HRESULT hr; LPDIRECTXFILEDATA data_obj; + LPDIRECTXFILEDATAREFERENCE ref_obj; // See if the object is a data object. hr = obj->QueryInterface(IID_IDirectXFileData, (void **)&data_obj); @@ -589,10 +598,21 @@ convert_material_list_object(LPDIRECTXFILEOBJECT obj, XFileMesh &mesh) { return convert_material_list_data_object(data_obj, mesh); } + // Or maybe it's a reference to a previous object. + hr = obj->QueryInterface(IID_IDirectXFileDataReference, (void **)&ref_obj); + if (hr == DD_OK) { + // It is. + if (ref_obj->Resolve(&data_obj) == DXFILE_OK) { + return convert_material_list_data_object(data_obj, mesh); + } + } + // It isn't. - xfile_cat.error() - << "Ignoring object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring material list object of unknown type: " + << get_object_name(obj) << "\n"; + } return true; } @@ -620,9 +640,11 @@ convert_material_list_data_object(LPDIRECTXFILEDATA obj, XFileMesh &mesh) { return false; } } else { - xfile_cat.error() - << "Ignoring data object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring material list data object of unknown type: " + << get_object_name(obj) << "\n"; + } } return true; @@ -692,9 +714,11 @@ convert_material_object(LPDIRECTXFILEOBJECT obj, XFileMaterial &material) { } // It isn't. - xfile_cat.error() - << "Ignoring object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring material object of unknown type: " + << get_object_name(obj) << "\n"; + } return true; } @@ -722,9 +746,11 @@ convert_material_data_object(LPDIRECTXFILEDATA obj, XFileMaterial &material) { return false; } } else { - xfile_cat.error() - << "Ignoring data object of unknown type: " << get_object_name(obj) - << "\n"; + if (xfile_cat.is_debug()) { + xfile_cat.debug() + << "Ignoring material data object of unknown type: " + << get_object_name(obj) << "\n"; + } } return true; diff --git a/pandatool/src/xfileprogs/Sources.pp b/pandatool/src/xfileprogs/Sources.pp index 12c4daf6f4..326f981969 100644 --- a/pandatool/src/xfileprogs/Sources.pp +++ b/pandatool/src/xfileprogs/Sources.pp @@ -1,7 +1,8 @@ -// This package is temporarily disabled. -#define BUILD_DIRECTORY -//#define BUILD_DIRECTORY $[HAVE_DX] +// The .x converter takes advantage of the DirectX API's; therefore, +// it can only be built if we have DX available (and therefore it only +// builds on Windows--sorry). +#define BUILD_DIRECTORY $[HAVE_DX] #define USE_PACKAGES dx #begin bin_target @@ -14,7 +15,7 @@ dtoolconfig dtool pystub \ #define WIN_SYS_LIBS \ - d3dxof.lib dxguid.lib + d3dxof.lib dxguid.lib d3d8.lib d3dx8.lib dxerr8.lib #define SOURCES \ eggToX.cxx eggToX.h @@ -31,7 +32,7 @@ dtoolconfig dtool pystub \ #define WIN_SYS_LIBS \ - d3dxof.lib + d3dxof.lib dxguid.lib d3d8.lib d3dx8.lib dxerr8.lib #define SOURCES \ xFileToEgg.cxx xFileToEgg.h diff --git a/pandatool/src/xfileprogs/xFileToEgg.cxx b/pandatool/src/xfileprogs/xFileToEgg.cxx index 7064ace756..73ea8accf5 100644 --- a/pandatool/src/xfileprogs/xFileToEgg.cxx +++ b/pandatool/src/xfileprogs/xFileToEgg.cxx @@ -29,11 +29,11 @@ XFileToEgg:: XFileToEgg() : SomethingToEgg("DirectX", ".x") { + add_path_replace_options(); + add_path_store_options(); + add_units_options(); add_normals_options(); add_transform_options(); - add_texture_path_options(); - add_rel_dir_options(); - add_search_path_options(true); set_program_description ("This program converts DirectX retained-mode (.x) files to egg. This " @@ -59,7 +59,9 @@ run() { XFileToEggConverter converter; converter.set_egg_data(&_data, false); - converter.set_texture_path_convert(_texture_path_convert, _make_rel_dir); + + // Copy in the path and animation parameters. + apply_parameters(converter); if (!converter.convert_file(_input_filename)) { nout << "Unable to read " << _input_filename << "\n";