---------------------------------------------------------------
| 784 | |
| 785 | //--------------------------------------------------------------- |
| 786 | void EffectExporter::exportTransparency ( |
| 787 | const String& effectId, |
| 788 | COLLADASW::EffectProfile* effectProfile, |
| 789 | MObject shadingNetwork, |
| 790 | const MColor& transparentColor, |
| 791 | const String& targetSid, |
| 792 | const char* attributeName, |
| 793 | int& nextTextureIndex ) |
| 794 | { |
| 795 | // Get the animation exporter |
| 796 | AnimationExporter* animationExporter = mDocumentExporter->getAnimationExporter(); |
| 797 | |
| 798 | // Flag, if the current attribute is animated |
| 799 | bool animated = false; |
| 800 | |
| 801 | // Build the target sid and export animation |
| 802 | animated = animationExporter->addNodeAnimation ( shadingNetwork, targetSid, attributeName, kColour, RGBA_PARAMETERS ); |
| 803 | // Set the transparent color or texture |
| 804 | effectProfile->setTransparent ( mayaColor2ColorOrTexture ( transparentColor ), animated ); |
| 805 | |
| 806 | MObject transparentTextureNode = |
| 807 | exportTexturedParameter ( effectId, effectProfile, shadingNetwork, attributeName, EffectExporter::TRANSPARENt, nextTextureIndex, animated ); |
| 808 | |
| 809 | // For the 'opaque' attribute, check the plug's name, that's connected to |
| 810 | // the shader's 'transparency' plug. |
| 811 | MPlug connectedPlug; |
| 812 | if ( !transparentTextureNode.isNull() ) |
| 813 | { |
| 814 | // DO NOTE: We're missing 2 transparency mode that were wrongly deemed useless in COLLADA 1.4.1. |
| 815 | // Until then, we cannot use the 'invert' attribute or correctly export the transparency mode. |
| 816 | MFnDependencyNode texture2DFn ( transparentTextureNode ); |
| 817 | bool isInverted = false; |
| 818 | texture2DFn.findPlug ( ATTR_INVERT ).getValue ( isInverted ); |
| 819 | |
| 820 | DagHelper::getPlugConnectedTo ( shadingNetwork, attributeName, connectedPlug ); |
| 821 | String partialName = connectedPlug.partialName().asChar(); |
| 822 | |
| 823 | if ( connectedPlug.partialName() == ATTR_OUT_COLOR ) |
| 824 | effectProfile->setOpaque ( COLLADASW::EffectProfile::RGB_ZERO ); // should be RGB_ONE. |
| 825 | else if ( connectedPlug.partialName() == ATTR_OUT_TRANSPARENCY ) |
| 826 | effectProfile->setOpaque ( COLLADASW::EffectProfile::A_ONE ); |
| 827 | else if ( connectedPlug.partialName() == ATTR_OUT_ALPHA ) |
| 828 | effectProfile->setOpaque ( COLLADASW::EffectProfile::A_ONE ); // valid? |
| 829 | |
| 830 | if ( effectProfile->getOpaque() == COLLADASW::EffectProfile::A_ONE ) |
| 831 | { |
| 832 | // Get the animation cache |
| 833 | AnimationSampleCache* animationCache = mDocumentExporter->getAnimationCache(); |
| 834 | |
| 835 | // Export any animation on the alpha gain/alpha offset |
| 836 | if ( AnimationHelper::isAnimated ( animationCache, transparentTextureNode, ATTR_ALPHA_GAIN ) ) |
| 837 | { |
| 838 | // TODO Test |
| 839 | String targetPath = effectId + "/" + effectProfile->getTechniqueSid() + "/"; |
| 840 | String targetSubId = targetPath + ATTR_ALPHA_GAIN; |
| 841 | animationExporter->addNodeAnimation ( transparentTextureNode, targetSubId, ATTR_ALPHA_GAIN, kSingle ); |
| 842 | } |
| 843 | else |
nothing calls this directly
no test coverage detected