I try to modify the frameBegin member function as following but the returned result is always “Number of polygons = 0”. My test scene is just a default maya sphere mesh with shape node named “pSphereShape1”. I’ve also check the “geometry” attribute of my texture node in .vrscene has filled with the name of geometry plugin node, Could you help to figure out what part i still go wrong ?
And here are some additional questions about the detail of implementing plugin:
1. Since the framebegin() function is also invoked at the time of node generation, a mechanism to check it’s input connection is required to further get valid interfce object. In this example, i try to take use of “getParam” function to check if there’s a conection to specified attribute, but i not sure whether this is the correct(or good) way to do the job or not.
2. I find two similar statements about casting interface to MeshInfoInterface*:
meshInfoInterface = static_cast<MeshInfoInterface*>(geometry_Plugin->newInterface(EXT_MESH_INFO)); // I find this in “environmentfog.cpp”
meshInfoInterface = (MeshInfoInterface*)GET_INTERFACE(geometry_Plugin, EXT_MESH_INFO); // I find this in “geom_hair.cpp”
I think the differece is the first one explicitly declare as a static casting, and the question about is when should i casting interface using the first statement(static casting) and when to use the other ?
3. I still not very clear about the “plugin” custom type you mentioned:
The API has some custom types like “plugin”, you can export it from a maya node, you can get it from a parameter. It’s just a reference to the internal V-Ray plugin and you can do some basic stuff with it as setting parameters, assign to another plugin, etc.
In my example i add “geometry” attribute by using addParamPlugin so i think now it’s type is “plugin”, but it still represent as a plug that can’t make connection with other type of attributes except color\texture. I also put my node to exportNode() function in python API but no differences in resulting .vrscene. Could you provide more details about the “export” mechanism you mentioned ? Thanks a lot !
(In parameters class)
...
addParamPlugin("geometry", EXT_STATIC_GEOM_SOURCE);
(In plugin class)
...
paramList->setParamCache("geometry", &geometry_Plugin);
...
void frameBegin(VR::VRayRenderer *vray) {
printf("Frame Begin Called !!!\n");
VRayTexture::frameBegin(vray);
double time = vray->getFrameData().t;
VRayPluginParameter* geometry_Param = paramList->getParam("geometry");
if(geometry_Param)
{
meshInfoInterface = (MeshInfoInterface*)GET_INTERFACE(geometry_Plugin, EXT_MESH_INFO);
if(meshInfoInterface)
{
meshInfoInterface = static_cast<MeshInfoInterface*>(geometry_Plugin->newInterface(EXT_MESH_INFO));
// meshInfoInterface = (MeshInfoInterface*)GET_INTERFACE(geometry_Plugin, EXT_MESH_INFO);
if(meshInfo)
{
int poly_num = meshInfo->getNumPolygons();
printf("Number of polygons = %d\n", poly_num);
}
}
}
}
...
PluginBase* geometry_Plugin;
MeshInfoInterface* meshInfoInterface;
And this is the python script i use in post translator
from vray.utils import *
nodes = findByName("InputTypeTestTex")
inputTypeTest_node = nodes[0]
print inputTypeTest_node.name() # Check node exist
nodes = findByName("pSphereShape1@mesh1")
geometry_node = nodes[0]
print geometry_node.name() # Check node exist
inputTypeTest_node.set("geometry", geometry_node)