From 54047ea8932f2d0ebd0ac3c1dd311f0603881ea3 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 14 Aug 2003 00:29:07 +0000 Subject: [PATCH] add -bface to maya2egg --- pandatool/src/mayaegg/mayaEggGroupUserData.I | 5 ++++- pandatool/src/mayaegg/mayaEggGroupUserData.h | 1 + pandatool/src/mayaegg/mayaNodeTree.cxx | 11 ++++++++--- pandatool/src/mayaegg/mayaToEggConverter.cxx | 17 +++++++++++------ pandatool/src/mayaegg/mayaToEggConverter.h | 1 + pandatool/src/mayaprogs/mayaToEgg.cxx | 12 ++++++++++++ pandatool/src/mayaprogs/mayaToEgg.h | 1 + 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/pandatool/src/mayaegg/mayaEggGroupUserData.I b/pandatool/src/mayaegg/mayaEggGroupUserData.I index d21bcd2fb7..46edb1f513 100755 --- a/pandatool/src/mayaegg/mayaEggGroupUserData.I +++ b/pandatool/src/mayaegg/mayaEggGroupUserData.I @@ -25,6 +25,7 @@ INLINE MayaEggGroupUserData:: MayaEggGroupUserData() { _vertex_color = false; + _double_sided = false; } @@ -36,7 +37,8 @@ MayaEggGroupUserData() { INLINE MayaEggGroupUserData:: MayaEggGroupUserData(const MayaEggGroupUserData ©) : EggUserData(copy), - _vertex_color(copy._vertex_color) + _vertex_color(copy._vertex_color), + _double_sided(copy._double_sided) { } @@ -50,4 +52,5 @@ INLINE void MayaEggGroupUserData:: operator = (const MayaEggGroupUserData ©) { EggUserData::operator = (copy); _vertex_color = copy._vertex_color; + _double_sided = copy._double_sided; } diff --git a/pandatool/src/mayaegg/mayaEggGroupUserData.h b/pandatool/src/mayaegg/mayaEggGroupUserData.h index d44597d2e8..0d6787f55c 100755 --- a/pandatool/src/mayaegg/mayaEggGroupUserData.h +++ b/pandatool/src/mayaegg/mayaEggGroupUserData.h @@ -35,6 +35,7 @@ public: INLINE void operator = (const MayaEggGroupUserData ©); bool _vertex_color; + bool _double_sided; public: static TypeHandle get_class_type() { diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index e33b48cc3f..2834480b21 100755 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -276,13 +276,18 @@ get_egg_group(MayaNodeDesc *node_desc) { egg_group->set_model_flag(true); } - // And "vertex-color" has meaning only to this converter. + // And "vertex-color" and "double-sided" have meaning only to + // this converter. + MayaEggGroupUserData *user_data = new MayaEggGroupUserData; if (egg_group->has_object_type("vertex-color")) { egg_group->remove_object_type("vertex-color"); - MayaEggGroupUserData *user_data = new MayaEggGroupUserData; user_data->_vertex_color = true; - egg_group->set_user_data(user_data); } + if (egg_group->has_object_type("double-sided")) { + egg_group->remove_object_type("double-sided"); + user_data->_double_sided = true; + } + egg_group->set_user_data(user_data); } node_desc->_egg_group = egg_group; diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index a8b9e665e7..dde378db66 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -87,6 +87,7 @@ MayaToEggConverter(const string &program_name) : _from_selection = false; _polygon_output = false; _polygon_tolerance = 0.01; + _respect_maya_double_sided = true; _transform_type = TT_model; } @@ -1219,8 +1220,8 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh, string name = mesh.name().asChar(); MObject mesh_object = mesh.object(); - bool double_sided = false; - get_bool_attribute(mesh_object, "doubleSided", double_sided); + bool maya_double_sided = false; + get_bool_attribute(mesh_object, "doubleSided", maya_double_sided); if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() @@ -1281,14 +1282,18 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh, // will be different from world space. LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv(); - // Save this modeling flag for the vertex color check later (see the - // comment below). + // Save these modeling flag for the a check below. bool egg_vertex_color = false; + bool egg_double_sided = false; if (egg_group->has_user_data(MayaEggGroupUserData::get_class_type())) { - egg_vertex_color = - DCAST(MayaEggGroupUserData, egg_group->get_user_data())->_vertex_color; + MayaEggGroupUserData *user_data = + DCAST(MayaEggGroupUserData, egg_group->get_user_data()); + egg_vertex_color = user_data->_vertex_color; + egg_double_sided = user_data->_double_sided; } + bool double_sided = _respect_maya_double_sided ? maya_double_sided : egg_double_sided; + while (!pi.isDone()) { EggPolygon *egg_poly = new EggPolygon; egg_group->add_child(egg_poly); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index d446b4ab52..3a3d5b51cf 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -132,6 +132,7 @@ public: bool _polygon_output; double _polygon_tolerance; + bool _respect_maya_double_sided; enum TransformType { TT_invalid, diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index f79b7cce9f..8789243234 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -54,6 +54,17 @@ MayaToEgg() : "0.01.", &MayaToEgg::dispatch_double, NULL, &_polygon_tolerance); + add_option + ("bface", "", 0, + "Respect the Maya \"double sided\" rendering flag to indicate whether " + "polygons should be double-sided or single-sided. Since this flag " + "is set to double-sided by default in Maya, it is often better to " + "ignore this flag (unless your modelers are diligent in turning it " + "off where it is not desired). If this flag is not specified, the " + "default is to treat all polygons as single-sided, unless an " + "egg object type of \"double-sided\" is set.", + &MayaToEgg::dispatch_none, &_respect_maya_double_sided); + add_option ("trans", "type", 0, "Specifies which transforms in the Maya file should be converted to " @@ -108,6 +119,7 @@ run() { // Copy in the command-line parameters. converter._polygon_output = _polygon_output; converter._polygon_tolerance = _polygon_tolerance; + converter._respect_maya_double_sided = _respect_maya_double_sided; converter._transform_type = _transform_type; // Copy in the path and animation parameters. diff --git a/pandatool/src/mayaprogs/mayaToEgg.h b/pandatool/src/mayaprogs/mayaToEgg.h index fc300188c7..debdccf241 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.h +++ b/pandatool/src/mayaprogs/mayaToEgg.h @@ -39,6 +39,7 @@ protected: int _verbose; bool _polygon_output; double _polygon_tolerance; + bool _respect_maya_double_sided; MayaToEggConverter::TransformType _transform_type; };