SHARE
TWEET

mtoa procedural exporter

a guest Jan 9th, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <iostream>
  3.  
  4. #include <ai_msg.h>
  5. #include <ai_nodes.h>
  6.  
  7. #include "mfRibArch_mtoa_translator.h"
  8.  
  9.  
  10. void mfRibArch_mtoa_translator::NodeInitializer(CAbTranslator context)
  11. {
  12. }
  13.  
  14.  
  15. void* mfRibArch_mtoa_translator::creator()
  16. {
  17.     return new mfRibArch_mtoa_translator();
  18. }
  19.  
  20.  
  21. static std::string expandAssFilePath(std::string shape)
  22. {
  23.     std::string cmd( "mfRibArch_expandAssFile('" + shape + "')" );
  24.     MString res = MGlobal::executePythonCommandStringResult(cmd.data());
  25.     return res.asChar();
  26. }
  27.  
  28.  
  29. AtNode* mfRibArch_mtoa_translator::CreateArnoldNodes()
  30. {
  31.     using namespace std;
  32.  
  33.     std::string maya_shape_name = GetMayaNodeName().asChar();
  34.  
  35.     // ass file name - get it from python proc
  36.     std::string fname = expandAssFilePath(maya_shape_name);
  37.  
  38.     AtNode* procedural_node = AddArnoldNode("procedural");
  39.  
  40.     AiNodeSetStr(procedural_node, AtString("name"), maya_shape_name.c_str());
  41.     AiNodeSetStr(procedural_node, AtString("filename"), fname.c_str());
  42.     //AiNodeSetBool(procedural_node, AtString("override_nodes"), 0);
  43.     auto visib = AiNodeGetByte(procedural_node, AtString("visibility"));
  44.     AiNodeSetByte(procedural_node, AtString("visibility"), visib);
  45.  
  46.     return procedural_node;
  47. }
  48.  
  49.  
  50. void mfRibArch_mtoa_translator::RequestUpdate()
  51. {
  52.     SetUpdateMode(AI_RECREATE_NODE);
  53.     CShapeTranslator::RequestUpdate();
  54. }
  55.  
  56.  
  57. void mfRibArch_mtoa_translator::Export(AtNode* i_node)
  58. {
  59.     ProcessRenderFlags(i_node);
  60.     ExportMatrix(i_node);
  61.     ExportLightLinking(i_node);
  62. }
  63.  
  64. void mfRibArch_mtoa_translator::NodeChanged(MObject& node, MPlug& plug)
  65. {
  66.     SetUpdateMode(AI_RECREATE_NODE);
  67.     CShapeTranslator::NodeChanged(node, plug);
  68. }
  69.  
  70.  
  71. void mfRibArch_mtoa_translator::ExportMotion(AtNode* node)
  72. {
  73.    // Check if motionblur is enabled and early out if it's not.
  74.    if ( !IsMotionBlurEnabled() ) return;
  75.  
  76.    // Set transform matrix
  77.    ExportMatrix(node);
  78. }
  79.  
  80.  
  81. void mfRibArch_mtoa_translator::ExportShaders(AtNode* node)
  82. {
  83.     int instanceNum = m_dagPath.isInstanced() ? m_dagPath.instanceNumber() : 0;
  84.     MPlug shadingGroupPlug = GetNodeShadingGroup(m_dagPath.node(), instanceNum);
  85.     if (!shadingGroupPlug.isNull())
  86.     {
  87.         auto shader = ExportConnectedNode(shadingGroupPlug);
  88.         if (shader)
  89.             AiNodeSetPtr(node, AtString("shader"), shader);
  90.         else
  91.             AiMsgWarning("[mtoa] [translator %s] ShadingGroup %s has no surfaceShader input",
  92.                          GetTranslatorName().asChar(), MFnDependencyNode(shadingGroupPlug.node()).name().asChar());
  93.     }
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top