VRay SDK Instance proxyMeshFile

It it possible to write a plugin in VRay SDK that creates instances of proxyMeshFile’s (alembic files)?

At the moment I have a postTranslate script that works, but gets pretty slow when you have a lot of instances.

I have found examples of creating new Plugins within a plugin using:
VRayPlugin *meshPlugin = (VRayPlugin*) plugman->newPlugin(“GeomMeshFile”, NULL);

Is that also possible with the instancer? If so, how do I generate the list of instances to pass to the instancer plugin node?

Post translate pseudo code below:

proxyMeshNode = vr.create(‘GeomMeshFile’, ‘GeomMeshFile’)
proxyMeshNode.set(‘file’, abcPath)
proxyNode = vr.create(‘Node’, 'TransformNode)
proxyNode.set(‘geometry’, proxyMeshNode)

instanceList = []

for i in range(0, 100000):
       instanceList.append([0, vrayTr, velTransform, proxyNode)

instanceObj = vr.create(‘Instancer’, instancerName)
instanceObj.set(‘instances’, instanceList)

--
Jacob

Hi, here’s an example python post translate script that can create an instancer:

import maya.cmds as cmds

from vray.utils import *

myCube = findByName("KUB@node")[0]
instancerList2 = [1.0, [1, Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(-24, 0, 0)), Transform(Matrix(Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0)), Vector(0, 5, 0)), myCube],
[2, Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(-30, 0, 0)), Transform(Matrix(Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0)), Vector(0, 0, 0)), myCube]]
instancer = create("Instancer", "newInstancer")
instancer.set('instances', instancerList2)

You can see how it works in the attached scene.

One alternative approach would be to create Node plugins in c++ via the VRaySceneModifierInterface. There are several examples in the V-Ray SDK that use it, you can use them as a reference.
python_access_instances.zip (9.49 KB)

Thanks for your reply.

How do I create the array of instances and add that to the Instancer plugin in the VRaySceneModiferInterface in C++?

My code looks something like this:

C++ code:
VRayPlugin *meshPlugin = (VRayPlugin*) plugman->newPlugin(“GeomMeshFile”, NULL);
meshPlugin->setParameter(new DefStringParam(“file”, abcPath.c_str()));
meshPlugin->setParameter(new DefBoolParam(“use_full_names”, true));
meshPlugin->setParameter(new DefBoolParam(“instancing”, false));

VRayPlugin *nodePlugin = (VRayPlugin*) plugman->newPlugin(“Node”, NULL);
nodePlugin->setParameter(new DefTransformParam(“transform”, basicTr));
nodePlugin->setParameter(new DefPluginParam(“geometry”, meshPlugin));
nodePlugin->setParameter(new DefPluginParam(“material”, inMaterialPlugin));
nodePlugin->setParameter(new DefBoolParam(“visible”, false));

VRayPlugin *instancerPlugin = (VRayPlugin*) plugman->newPlugin(“Instancer”, NULL);

I got it to work creating a “Node” plugin for each of my instances.

The only thing I can’t get to work is motionblur.
How do I set two transforms on each of the Nodes?

Right now I have something like this:

Transform vrayTr = Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(0, i, 0));
Transform offSetVrayTr = Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(1, i, 0));

TraceTransform tms[2];
tms[0] = TraceTransform(vrayTr);
tms[1] = TraceTransform(offSetVrayTr);

nodePlugin->setParameter(factory->saveInFactory(new DefTransformParam("transform", tms)));

But that gives me the following error:
error C2664: 'VUtils::smile:efTransformParam::smile:efTransformParam(const VUtils::smile:efTransformParam &)': cannot convert argument 2 from 'VUtils::TraceTransform [2]' to 'const VUtils::TraceTransform &'

I got motion blur working using an InterpolatedTransformParam.

I still would like to try adding the instances to an “Instancer” plugin, as it seems to be slow generating millions of “Node” plugins.

How do I create the array for each instance? Similar to Python where you create a normal List with (index, Transform, VelTransform, Node, etc).

In the vraystdplugins.chm, there’s a reference to:

VUtils::InstancerParam Struct Reference
Format: List(<time>, List(<id>, <tm>, <vel>, <attr_flags>, <attr_objectID>, <attr_primaryVisibility>, <attr_userAttributes>, <visible>, <material>, <geometry>, <node>), List(...) )

I can’t find the header file for the Struct or any examples using it.

Or would it make more sense to look at the StaticMeshInterfacePrimitive for loading the proxies?

I’m looking for the most efficient way to render millions of instances of a few different proxies (alembic).

I figured it out.