hi,
I try to implement a simple node that expects an input connection with maya's file texture node. Since the input attribute has no connection at the time of node generation i think the input attribute(i.e. "plugin_Texture" in the code snippet) should be NULL. What confusing me is even i set "plugin_Texture" as NULL in constructor, it seems filled in with something before frameBegin call such that I can pass all the condition check even there's not any connection to the "bitmap" attribute of my node. Why settings in constructor not take effect ? And what's filled in "plugin_Texture" parameter ?
What i want to achieve in frameBegin is before retrieving any related interface (or something else) i can make sure that there exist an effective connection to that attriubte\parameter, how to i fix my code to fit this requirement ?
I try to implement a simple node that expects an input connection with maya's file texture node. Since the input attribute has no connection at the time of node generation i think the input attribute(i.e. "plugin_Texture" in the code snippet) should be NULL. What confusing me is even i set "plugin_Texture" as NULL in constructor, it seems filled in with something before frameBegin call such that I can pass all the condition check even there's not any connection to the "bitmap" attribute of my node. Why settings in constructor not take effect ? And what's filled in "plugin_Texture" parameter ?
What i want to achieve in frameBegin is before retrieving any related interface (or something else) i can make sure that there exist an effective connection to that attriubte\parameter, how to i fix my code to fit this requirement ?
Code:
#include "vrayplugins.h" #include "vrayinterface.h" #include "vrayrenderer.h" #include "vraytexutils.h" #include "defparams.h" // Prevent from "to tchar*" conversion warning ... #if (defined __GNUC__) && !(defined __clang__) #pragma GCC diagnostic ignored "-Wwrite-strings" #endif //(defined __GNUC__) && !(defined __clang__) #include "globalnewdelete.cpp" using namespace VR; // Parameters struct TexSteepParallaxMap_Params: VRayParameterListDesc { TexSteepParallaxMap_Params(void) { // Add the parameters addParamTexture("bitmap", AColor(1.0f, 0.0f, 0.0f, 1.0f), -1, "The input of bitmap texture"); } }; struct TexSteepParallaxMap: VRayTexture { TexSteepParallaxMap(VRayPluginDesc *pluginDesc) : VRayTexture(pluginDesc) { // Set parameter caches paramList->setParamCache("bitmap", &plugin_Texture); plugin_Texture = NULL; } void frameBegin(VR::VRayRenderer* vray); void frameEnd(VR::VRayRenderer* vray); // VRayTexture member function AColor getTexColor(const VRayContext &rc); void getTexColorBounds(AColor &cmin, AColor &cmax); Vector getColorBumpGradient(const VRayContext &rc); private: PluginBase* plugin_Texture; }; #define TexSteepParallaxMap_PluginID PluginID(LARGE_CONST(2004110919)) SIMPLE_PLUGIN_LIBRARY(TexSteepParallaxMap_PluginID, EXT_TEXTURE, "TexSteepParallaxMap", "SteepParallaxMap texture plugin for VRay", TexSteepParallaxMap, TexSteepParallaxMap_Params); void TexSteepParallaxMap::frameBegin(VR::VRayRenderer *vray) { // Call the base class to update the parameter caches VRayTexture::frameBegin(vray); printf("Frame begin called ...\n"); if(plugin_Texture) { printf("Get valid texture plugin ...\n"); TextureInterface* texture_interface = (TextureInterface*)GET_INTERFACE(plugin_Texture, EXT_TEXTURE); if(texture_interface) { printf("Get valid texture interface ...\n"); const tchar* n = texture_interface->getInterfaceName(); // <----- Maya crash if i uncomment this line !!!!!!!!!!!! //printf("IF name = %s\n", n); } } } void TexSteepParallaxMap::frameEnd(VRayRenderer *vray) { VRayTexture::frameEnd(vray); } AColor TexSteepParallaxMap::getTexColor(const VRayContext &rc) { return AColor(0.0f, 0.0f, 0.0f, 1.0f); } void TexSteepParallaxMap::getTexColorBounds(AColor &cmin, AColor &cmax) { cmin = AColor(0.0f, 0.0f, 0.0f, 1.0f); cmax = AColor(1.0f, 1.0f, 1.0f, 1.0f); } Vector TexSteepParallaxMap::getColorBumpGradient(const VRayContext &rc) { return Vector(0.0f, 0.0f, 0.0f); }
Comment