From 2f7a5c0e81cbf642f6f48240fbbb9a2b7276ea4a Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 5 Feb 2003 00:21:53 +0000 Subject: [PATCH] maya2egg, mayacopy --- pandatool/src/cvscopy/cvsCopy.cxx | 16 +++++++++- pandatool/src/cvscopy/cvsCopy.h | 2 ++ pandatool/src/mayaegg/mayaToEggConverter.cxx | 15 +++++++-- pandatool/src/mayaprogs/mayaCopy.cxx | 32 ++++++++++++++++++++ pandatool/src/mayaprogs/mayaCopy.h | 4 +++ 5 files changed, 66 insertions(+), 3 deletions(-) diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index 82c68438df..0e8858953b 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -127,7 +127,7 @@ import(const Filename &source, void *extra_data, return (CVSSourceDirectory *)NULL; } - string basename = source.get_basename(); + string basename = filter_filename(source.get_basename()); CVSSourceDirectory *dir = _tree.choose_directory(basename, suggested_dir, _force, _interactive); @@ -404,6 +404,20 @@ protect_from_shell(const string &source) { return result; } +//////////////////////////////////////////////////////////////////// +// Function: CVSCopy::filter_filename +// Access: Protected, Virtual +// Description: Given a source filename (including the basename only, +// without a dirname), return the appropriate +// corresponding filename within the source directory. +// This may be used by derived classes to, for instance, +// strip a version number from the filename. +//////////////////////////////////////////////////////////////////// +string CVSCopy:: +filter_filename(const string &source) { + return source; +} + //////////////////////////////////////////////////////////////////// // Function: CVSCopy::scan_hierarchy // Access: Private diff --git a/pandatool/src/cvscopy/cvsCopy.h b/pandatool/src/cvscopy/cvsCopy.h index e45e9d7f47..3cc001ed9d 100644 --- a/pandatool/src/cvscopy/cvsCopy.h +++ b/pandatool/src/cvscopy/cvsCopy.h @@ -58,6 +58,8 @@ protected: bool cvs_add(const Filename &filename); static string protect_from_shell(const string &source); + virtual string filter_filename(const string &source); + private: bool scan_hierarchy(); bool scan_for_root(const string &dirname); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index a41f08b2ee..7cf4c2bdf2 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -1148,8 +1148,9 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh, MStatus status; string name = mesh.name().asChar(); + MObject mesh_object = mesh.object(); bool double_sided = false; - get_bool_attribute(mesh.object(), "doubleSided", double_sided); + get_bool_attribute(mesh_object, "doubleSided", double_sided); if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() @@ -1465,8 +1466,18 @@ r_get_egg_group(const string &name, const MDagPath &dag_path, } // Check for an object type setting, from Oliver's plug-in. + MObject dag_object = dag_path.node(); string object_type; - if (get_enum_attribute(dag_path.node(), "eggObjectTypes", object_type)) { + if (get_enum_attribute(dag_object, "eggObjectTypes", object_type)) { + egg_group->add_object_type(object_type); + } + if (get_enum_attribute(dag_object, "eggObjectTypes1", object_type)) { + egg_group->add_object_type(object_type); + } + if (get_enum_attribute(dag_object, "eggObjectTypes2", object_type)) { + egg_group->add_object_type(object_type); + } + if (get_enum_attribute(dag_object, "eggObjectTypes3", object_type)) { egg_group->add_object_type(object_type); } } diff --git a/pandatool/src/mayaprogs/mayaCopy.cxx b/pandatool/src/mayaprogs/mayaCopy.cxx index 2ae1f00814..267b84d4eb 100644 --- a/pandatool/src/mayaprogs/mayaCopy.cxx +++ b/pandatool/src/mayaprogs/mayaCopy.cxx @@ -54,6 +54,12 @@ MayaCopy() { clear_runlines(); add_runline("[opts] file.mb [file.mb ... ]"); + + add_option + ("keepver", "", 0, + "Don't attempt to strip the Maya version number from the tail of the " + "source filename before it is copied into the tree.", + &CVSCopy::dispatch_none, &_keep_ver); } //////////////////////////////////////////////////////////////////// @@ -105,6 +111,32 @@ copy_file(const Filename &source, const Filename &dest, return false; } +//////////////////////////////////////////////////////////////////// +// Function: MayaCopy::filter_filename +// Access: Protected, Virtual +// Description: Given a source filename (including the basename only, +// without a dirname), return the appropriate +// corresponding filename within the source directory. +// This may be used by derived classes to, for instance, +// strip a version number from the filename. +//////////////////////////////////////////////////////////////////// +string MayaCopy:: +filter_filename(const string &source) { + if (_keep_ver) { + return source; + } + + size_t dot = source.rfind('.'); + size_t underscore = source.rfind("_v", dot); + + if (underscore == string::npos) { + // No version number appears to be present. + return source; + } + + return source.substr(0, underscore) + source.substr(dot); +} + //////////////////////////////////////////////////////////////////// // Function: MayaCopy::copy_maya_file // Access: Private diff --git a/pandatool/src/mayaprogs/mayaCopy.h b/pandatool/src/mayaprogs/mayaCopy.h index f6d9127852..f4de9d6b78 100644 --- a/pandatool/src/mayaprogs/mayaCopy.h +++ b/pandatool/src/mayaprogs/mayaCopy.h @@ -47,6 +47,8 @@ protected: CVSSourceDirectory *dir, void *extra_data, bool new_file); + virtual string filter_filename(const string &source); + private: enum FileType { FT_maya, @@ -67,6 +69,8 @@ private: bool collect_shaders(); bool collect_shader_for_node(const MDagPath &dag_path); + bool _keep_ver; + PT(MayaApi) _maya; MayaShaders _shaders; };