mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
maya converter should default to vertex-color on
This commit is contained in:
parent
72c594b362
commit
bf2679a7b3
@ -29,6 +29,19 @@ ConfigureFn(config_mayaegg) {
|
|||||||
init_libmayaegg();
|
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
|
// Function: init_libmayaegg
|
||||||
// Description: Initializes the library. This must be called at
|
// Description: Initializes the library. This must be called at
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
|
|
||||||
NotifyCategoryDeclNoExport(mayaegg);
|
NotifyCategoryDeclNoExport(mayaegg);
|
||||||
|
|
||||||
|
extern const bool maya_default_double_sided;
|
||||||
|
extern const bool maya_default_vertex_color;
|
||||||
|
|
||||||
extern void init_libmayaegg();
|
extern void init_libmayaegg();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "eggTable.h"
|
#include "eggTable.h"
|
||||||
#include "eggXfmSAnim.h"
|
#include "eggXfmSAnim.h"
|
||||||
#include "eggData.h"
|
#include "eggData.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include "pre_maya_include.h"
|
#include "pre_maya_include.h"
|
||||||
#include <maya/MString.h>
|
#include <maya/MString.h>
|
||||||
@ -227,6 +228,8 @@ get_egg_group(MayaNodeDesc *node_desc) {
|
|||||||
egg_group->set_group_type(EggGroup::GT_joint);
|
egg_group->set_group_type(EggGroup::GT_joint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MayaEggGroupUserData *parent_user_data = NULL;
|
||||||
|
|
||||||
if (node_desc->_parent == _root) {
|
if (node_desc->_parent == _root) {
|
||||||
// The parent is the root.
|
// The parent is the root.
|
||||||
_egg_root->add_child(egg_group);
|
_egg_root->add_child(egg_group);
|
||||||
@ -235,6 +238,10 @@ get_egg_group(MayaNodeDesc *node_desc) {
|
|||||||
// The parent is another node.
|
// The parent is another node.
|
||||||
EggGroup *parent_egg_group = get_egg_group(node_desc->_parent);
|
EggGroup *parent_egg_group = get_egg_group(node_desc->_parent);
|
||||||
parent_egg_group->add_child(egg_group);
|
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()) {
|
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
|
// And "vertex-color" and "double-sided" have meaning only to
|
||||||
// this converter.
|
// 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")) {
|
if (egg_group->has_object_type("vertex-color")) {
|
||||||
egg_group->remove_object_type("vertex-color");
|
egg_group->remove_object_type("vertex-color");
|
||||||
user_data->_vertex_color = true;
|
user_data->_vertex_color = true;
|
||||||
|
@ -87,7 +87,8 @@ MayaToEggConverter(const string &program_name) :
|
|||||||
_from_selection = false;
|
_from_selection = false;
|
||||||
_polygon_output = false;
|
_polygon_output = false;
|
||||||
_polygon_tolerance = 0.01;
|
_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;
|
_transform_type = TT_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +99,13 @@ MayaToEggConverter(const string &program_name) :
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
MayaToEggConverter::
|
MayaToEggConverter::
|
||||||
MayaToEggConverter(const MayaToEggConverter ©) :
|
MayaToEggConverter(const MayaToEggConverter ©) :
|
||||||
_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.
|
// will be different from world space.
|
||||||
LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv();
|
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_vertex_color = false;
|
||||||
bool egg_double_sided = false;
|
bool egg_double_sided = false;
|
||||||
if (egg_group->has_user_data(MayaEggGroupUserData::get_class_type())) {
|
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;
|
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()) {
|
while (!pi.isDone()) {
|
||||||
EggPolygon *egg_poly = new EggPolygon;
|
EggPolygon *egg_poly = new EggPolygon;
|
||||||
@ -1351,9 +1359,12 @@ make_polyset(const MDagPath &dag_path, const MFnMesh &mesh,
|
|||||||
// same object. To allow this, we define the special egg flag
|
// same object. To allow this, we define the special egg flag
|
||||||
// "vertex-color", which when set indicates that we should
|
// "vertex-color", which when set indicates that we should
|
||||||
// respect the vertex color anyway.
|
// 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;
|
bool ignore_vertex_color = false;
|
||||||
if (shader != (MayaShader *)NULL) {
|
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.
|
// Get the vertices for the polygon.
|
||||||
|
@ -133,6 +133,7 @@ public:
|
|||||||
bool _polygon_output;
|
bool _polygon_output;
|
||||||
double _polygon_tolerance;
|
double _polygon_tolerance;
|
||||||
bool _respect_maya_double_sided;
|
bool _respect_maya_double_sided;
|
||||||
|
bool _always_show_vertex_color;
|
||||||
|
|
||||||
enum TransformType {
|
enum TransformType {
|
||||||
TT_invalid,
|
TT_invalid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user