maya converter should default to vertex-color on

This commit is contained in:
David Rose 2003-09-22 20:09:57 +00:00
parent 72c594b362
commit bf2679a7b3
5 changed files with 48 additions and 6 deletions

View File

@ -29,6 +29,19 @@ ConfigureFn(config_mayaegg) {
init_libmayaegg();
}
// These control the default behavior of the mayaegg converter, but
// not necessarily the default behavior of the maya2egg command-line
// tool (which has its own defaults).
// Should we respect the Maya double-sided flag (true) or ignore it
// and assume everything is single-sided (false)?
const bool maya_default_double_sided = config_mayaegg.GetBool("maya-default-double-sided", false);
// Should we apply vertex color even when a texture is applied (true)
// or only when no texture is applied or the vertex-color egg flag is
// set (false)?
const bool maya_default_vertex_color = config_mayaegg.GetBool("maya-default-vertex-color", true);
////////////////////////////////////////////////////////////////////
// Function: init_libmayaegg
// Description: Initializes the library. This must be called at

View File

@ -24,6 +24,9 @@
NotifyCategoryDeclNoExport(mayaegg);
extern const bool maya_default_double_sided;
extern const bool maya_default_vertex_color;
extern void init_libmayaegg();
#endif

View File

@ -24,6 +24,7 @@
#include "eggTable.h"
#include "eggXfmSAnim.h"
#include "eggData.h"
#include "dcast.h"
#include "pre_maya_include.h"
#include <maya/MString.h>
@ -227,6 +228,8 @@ get_egg_group(MayaNodeDesc *node_desc) {
egg_group->set_group_type(EggGroup::GT_joint);
}
MayaEggGroupUserData *parent_user_data = NULL;
if (node_desc->_parent == _root) {
// The parent is the root.
_egg_root->add_child(egg_group);
@ -235,6 +238,10 @@ get_egg_group(MayaNodeDesc *node_desc) {
// The parent is another node.
EggGroup *parent_egg_group = get_egg_group(node_desc->_parent);
parent_egg_group->add_child(egg_group);
if (parent_egg_group->has_user_data()) {
DCAST_INTO_R(parent_user_data, parent_egg_group->get_user_data(), NULL);
}
}
if (node_desc->has_dag_path()) {
@ -278,7 +285,14 @@ get_egg_group(MayaNodeDesc *node_desc) {
// And "vertex-color" and "double-sided" have meaning only to
// this converter.
MayaEggGroupUserData *user_data = new MayaEggGroupUserData;
MayaEggGroupUserData *user_data;
if (parent_user_data == (MayaEggGroupUserData *)NULL) {
user_data = new MayaEggGroupUserData;
} else {
// Inherit the flags from above.
user_data = new MayaEggGroupUserData(*parent_user_data);
}
if (egg_group->has_object_type("vertex-color")) {
egg_group->remove_object_type("vertex-color");
user_data->_vertex_color = true;

View File

@ -87,7 +87,8 @@ MayaToEggConverter(const string &program_name) :
_from_selection = false;
_polygon_output = false;
_polygon_tolerance = 0.01;
_respect_maya_double_sided = true;
_respect_maya_double_sided = maya_default_double_sided;
_always_show_vertex_color = maya_default_vertex_color;
_transform_type = TT_model;
}
@ -98,7 +99,13 @@ MayaToEggConverter(const string &program_name) :
////////////////////////////////////////////////////////////////////
MayaToEggConverter::
MayaToEggConverter(const MayaToEggConverter &copy) :
_maya(copy._maya)
_from_selection(copy._from_selection),
_maya(copy._maya),
_polygon_output(copy._polygon_output),
_polygon_tolerance(copy._polygon_tolerance),
_respect_maya_double_sided(copy._respect_maya_double_sided),
_always_show_vertex_color(copy._always_show_vertex_color),
_transform_type(copy._transform_type)
{
}
@ -1307,7 +1314,7 @@ 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 these modeling flag for the a check below.
// Save these modeling flags for the check below.
bool egg_vertex_color = false;
bool egg_double_sided = false;
if (egg_group->has_user_data(MayaEggGroupUserData::get_class_type())) {
@ -1318,6 +1325,7 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh,
}
bool double_sided = _respect_maya_double_sided ? maya_double_sided : egg_double_sided;
cerr << "respect = " << _respect_maya_double_sided << " maya = " << maya_double_sided << " egg = " << egg_double_sided << " result = " << double_sided << "\n";
while (!pi.isDone()) {
EggPolygon *egg_poly = new EggPolygon;
@ -1344,16 +1352,19 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh,
// Should we extract the color from the vertices? Normally, in
// Maya a texture completely replaces the vertex color, so we
// should ignore the vertex color if we have a texture.
// should ignore the vertex color if we have a texture.
// However, this is an inconvenient property of Maya; sometimes we
// really do want both vertex color and texture applied to the
// same object. To allow this, we define the special egg flag
// "vertex-color", which when set indicates that we should
// respect the vertex color anyway.
// Furthermore, if _always_show_vertex_color is true, we pretend
// that the "vertex-color" flag is always set.
bool ignore_vertex_color = false;
if (shader != (MayaShader *)NULL) {
ignore_vertex_color = color_def._has_texture && !egg_vertex_color;
ignore_vertex_color = color_def._has_texture && !(egg_vertex_color || _always_show_vertex_color);
}
// Get the vertices for the polygon.

View File

@ -133,6 +133,7 @@ public:
bool _polygon_output;
double _polygon_tolerance;
bool _respect_maya_double_sided;
bool _always_show_vertex_color;
enum TransformType {
TT_invalid,