# Custom Instancer question

**URL:** <https://forums.chaos.com/t/custom-instancer-question/42276>\
**Category:** SDK\
**Tags:** instancer, proxy\
**Created:** [August 7, 2012, 2:20pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276 "2012-08-07T14:20:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 7, 2012, 2:20pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276/1 "2012-08-07T14:20:19Z")

</div>

Hi everyone,

We are trying to find a way to build a plugin that does instancing at rendertime, so far we found a couple of good examples how to generate mesh at rendertime. But we couldn’t find a way to instance a single mesh that has been compiled before.

For example, take a node like this: (psuedo)

GeomStaticMesh mesh1\_mesh{}  
GeomStaticMesh mesh2\_mesh{}  
GeomStaticMesh mesh3\_mesh{}

Node mesh1\_node{}  
Node mesh2\_node{}  
Node mesh3\_node{}

MyInstancer instancer\_node\_geo {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;instanced\_meshes=“mesh1;mesh2;mesh3”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positions=ListVectorHex(“ZIPB…”);  
}

Node instancer\_node {  
&nbsp;&nbsp;&nbsp;&nbsp;transform=Transform(…);  
&nbsp;&nbsp;&nbsp;&nbsp;geometry=instancer\_node\_geo;  
&nbsp;&nbsp;&nbsp;&nbsp;visible=1;  
}

Obviously there are a bunch more parameters that should control the instances.

Can someone point me into the right direction to pull this off? Also let me know if this isn’t clear enough.

Jeroen,  
House of Secrets

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 10, 2012, 8:45am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/2 "2012-08-10T08:45:07Z")

</div>

Also, is there any documentation about the GeomStaticNURBS plugin?  
I like to read the surface data and get surface position at a certain UV coordinate.  
I couldn’t find anything about NURBS in the documentation.

Regards,  
Jeroen

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 13, 2012, 2:08pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276/3 "2012-08-13T14:08:24Z")

</div>

Alright, so far I have simple spheres mapped onto a NURBS surface at rendertime. However can somebody explain to me how I convert a parameter object to a plugin?

Plugin \*plug = static\_cast\<Plugin \*\>(getParameter(“surface”)-\>getObject());

Doesn’t seem to work.  
The surface param is of type Plugin, getObject returns a PluginBase, but this gives me a base object that isn’t of any use.  
All I need is an InstanceID and I am good to go..

Any thoughts?

Jeroen,  
House of Secrets

**EDIT: False alarm.. seems to work, vrscene wasn’t set up correctly 🙂**

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [August 14, 2012, 7:04pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276/4 "2012-08-14T19:04:48Z")

</div>

Sorry for the late reply; I just saw the thread - but it looks like you figured it out already 🙂

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 15, 2012, 8:23am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/5 "2012-08-15T08:23:24Z")

</div>

Yes we are on a good track now, starting to understand the API a little better every day.

The only thing I still have to figure out is how I should use a BitmapInterface before the resource has been loaded. When requesting the size, the render crashes.  
I figure it is because the resources are loaded after the plugin is done.

Log looks like:  
…  
**Starting render sequence.**  
Preparing renderer… _\<-- This is where the plugin is working_  
**Creating bitmap manager** _\<-- Loads the resources_  
…

Is there a workaround for this? I promise I will free the bitmap when I’m done 🙂

Jeroen  
House of Secrets

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [August 16, 2012, 6:49am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/6 "2012-08-16T06:49:17Z")

</div>

Let me try to clarify, you want to use a bitmap plugin before any rendering is done? In which method are you trying to use it?

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 16, 2012, 7:58am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/7 "2012-08-16T07:58:57Z")

</div>

Yes, that is right. We like to use a density map for our instancing. But we like to do this at rendertime.  
So I tried linking a BitmapBuffer plugin. But this didn’t work out, so I’m looking for alternatives.

Jeroen,  
House of Secrets

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 17, 2012, 8:54am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/8 "2012-08-17T08:54:29Z")

</div>

Nevermind, since we are recalculating the scatter points every frame. This enabled the bitmapManager, now I’m able to access the BitmapInterface options. 🙂  
This was just a happy coincidence, I still haven’t figured out how we had to accomplish this in beginSequence though.

Jeroen,  
House of Secrets

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [August 18, 2012, 12:52am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/9 "2012-08-18T00:52:32Z")

</div>

You might have to initialize the bitmap plugin manually in this case (i.e. calling its renderBegin() method first).

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 23, 2012, 9:17am UTC](https://forums.chaos.com/t/custom-instancer-question/42276/10 "2012-08-23T09:17:55Z")

</div>

Sorry for the late reply, we have made some nice progress with the plugin. We are at the point of stabelizing the features and memory usage.  
Thanks for pointing at the renderBegin() method, I could use this information the next time!

Is there a way to launch vray in a debug mode?

Jeroen,  
House of Secrets

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [August 23, 2012, 2:52pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276/11 "2012-08-23T14:52:25Z")

</div>

By “debug mode” you mean with the debug visual studio runtime?

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![Hos](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@Hos](https://forums.chaos.com/u/Hos)\
**Post date:** [August 23, 2012, 2:59pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276/12 "2012-08-23T14:59:31Z")

</div>

Yes, I am developing under Linux and Windows so I tried to attach gdb, but I am not sure how.  
But information about either gdb or visual studio is welcome.

Jeroen,  
House of Secrets

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [August 23, 2012, 3:02pm UTC](https://forums.chaos.com/t/custom-instancer-question/42276/13 "2012-08-23T15:02:46Z")

</div>

Either of them should work fine; there is no problem to debug the version of V-Ray that you have. You won’t get symbol information, but it will work fine and you can still debug your code.

Best regards,  
Vlado
