SHARE
TWEET

Untitled

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. #include <ai_msg.h>
  4. #include <ai_nodes.h>
  5. #include "mfRibArch_mtoa_translator.h"
  6.  
  7. void* mfRibArch_mtoa_translator::creator()
  8. {
  9.     return new mfRibArch_mtoa_translator();
  10. }
  11.  
  12. void mfRibArch_mtoa_translator::NodeInitializer(CAbTranslator context)
  13. {
  14.     CProceduralTranslator::NodeInitializer(context);
  15. }
  16.  
  17. static std::string expandAssFilePath(std::string shape)
  18. {
  19.     std::string cmd( "mfRibArch_expandAssFile('" + shape + "')" );
  20.     MString res = MGlobal::executePythonCommandStringResult(cmd.data());
  21.     return res.asChar();
  22. }
  23.  
  24.  
  25. AtNode* mfRibArch_mtoa_translator::CreateArnoldNodes()
  26. {
  27.     if (IsMasterInstance())
  28.         return AddArnoldNode("procedural");
  29.     else
  30.         return AddArnoldNode("ginstance");
  31. }
  32.  
  33.  
  34. void mfRibArch_mtoa_translator::Export(AtNode* i_node)
  35. // AtNode* mfRibArch_mtoa_translator::ExportProcedural(AtNode* i_node)  // ExportProcedural is not being called for some reason
  36. {
  37.     if( AiNodeIs(i_node, AtString("procedural")) )
  38.     {
  39.         std::cout<<"Export procedural"<<std::endl; // I can see this branch executes
  40.        
  41.         i_node = CProceduralTranslator::ExportProcedural(i_node);
  42.  
  43.         std::string maya_shape_name = GetMayaNodeName().asChar();
  44.         AiNodeSetStr(i_node, AtString("name"), maya_shape_name.c_str());
  45.  
  46.         std::string fname = expandAssFilePath(maya_shape_name);
  47.         AiNodeSetStr(i_node, AtString("filename"), fname.c_str());
  48.  
  49.         master_node_ = i_node; // store master node for further instancing
  50.     }
  51.     else if(master_node_) // I can see this branch executes, but nothing gets expoerted to ASS file
  52.     {
  53.         std::cout<<"Export ginstance"<<std::endl;
  54.  
  55.         AiNodeSetPtr( i_node, AtString("node"), (void*)master_node_ );
  56.        
  57.         auto visib = AiNodeGetByte(master_node_, AtString("visibility"));
  58.         AiNodeSetByte(i_node, AtString("visibility"), visib);
  59.  
  60.         std::string maya_shape_name = GetMayaNodeName().asChar();
  61.         AiNodeSetStr(i_node, AtString("name"), maya_shape_name.c_str());
  62.     }
  63.  
  64.     ProcessRenderFlags(i_node); // this sets visibility based on standard Arnold properties
  65.     ExportMatrix(i_node);
  66.     ExportLightLinking(i_node);
  67.    
  68.     // return i_node;
  69. }
  70.  
  71.  
  72. void mfRibArch_mtoa_translator::ExportMotion(AtNode* node)
  73. {
  74.    if ( !IsMotionBlurEnabled() ) return;
  75.    ExportMatrix(node);
  76. }
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