From b95f6ecff4f83ca4ef66bdda121da6f5d6682141 Mon Sep 17 00:00:00 2001 From: "Asad M. Zaman" Date: Sat, 12 Nov 2005 02:39:28 +0000 Subject: [PATCH] added the maya blendmode support for the add, multiply and over --- pandatool/src/maya/mayaShader.cxx | 2 +- pandatool/src/maya/mayaShader.h | 12 +++++- pandatool/src/maya/mayaShaderColorDef.cxx | 46 +++++++++++++++++++---- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index 93002b155c..61576ea4a5 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -50,7 +50,7 @@ MayaShader(MObject engine) { << "Reading shading engine " << get_name() << "\n"; } - _alpha_is_luminance = true; + _blend_type = BT_unspecified; bool found_shader = false; MPlug shader_plug = engine_fn.findPlug("surfaceShader"); diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index c0923b5c05..4309449107 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -53,7 +53,17 @@ public: typedef pvector ColorDef; ColorDef _color; - bool _alpha_is_luminance; + enum BlendType { + BT_unspecified, + BT_modulate, + BT_decal, + BT_blend, + BT_replace, + BT_add, + BT_blend_color_scale, + }; + + BlendType _blend_type; private: bool read_surface_shader(MObject shader); diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 483282d758..e00c78c795 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include "post_maya_include.h" //////////////////////////////////////////////////////////////////// @@ -311,15 +312,46 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) { } else if (color.hasFn(MFn::kLayeredTexture)) { maya_cat.debug() << "Found layered texture" << endl; - //list_maya_attributes(color); - //shader->_multi_texture = true; - //get_enum_attribute(color,"blendMode",shader->_blend_mode); - //maya_cat.debug() << "blend mode :" << shader->_blend_mode << endl; - - get_bool_attribute(color, "alphaIsLuminance", shader->_alpha_is_luminance); - // get_bool_attribute(color, "isVisible", test_b); MFnDependencyNode layered_fn(color); + MStatus status; + MPlug inputsPlug = layered_fn.findPlug("inputs", &status); + MPlug blendModePlug = layered_fn.findPlug("blendMode", &status); + size_t numElements = inputsPlug.evaluateNumElements(&status); + maya_cat.spam() << "*** Start doIt... ***" << endl; + maya_cat.spam() << "inputsPlug Name: " << inputsPlug.name() << endl; + // Asad:following block fills the plug array values: needed to get all the connections + int blendValue; + for (size_t i=0; i_blend_type = MayaShader::BT_decal; + break; + case 6: + shader->_blend_type = MayaShader::BT_modulate; + break; + case 4: + shader->_blend_type = MayaShader::BT_add; + break; + default: + shader->_blend_type = MayaShader::BT_modulate; + } + + maya_cat.spam() << "blendModePlug's field name is " << blendName << endl; + maya_cat.spam() << "*** END doIt... ***" << endl; + MPlugArray color_pa; layered_fn.getConnections(color_pa); maya_cat.debug() << "number of connections: " << color_pa.length() << endl;