CurrentStateToObject Ignoring Modifier..

On 12/08/2014 at 08:57, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R14 
Platform:   Windows  ;   
Language(s) :     C++  ;


I am trying to use SMC CurrentStateToObject inside my GetVirtualObjects function.  It is actually working and returning the object however it is ignoring the Displacer object in my hierarchy..

The way it is set up is roughly:

Inside GetVirtualObjects i call a function which returns myObject.  MyObject is basically a null, with a cube inside it, and a Displacer object as a child of the cube.  I then run currentstatetoobject on the returned object and GetVirtualObjects returns the result.

It appears to work fine, as my cube comes back however it is ignoring the Displacer..

Any clues why this might be??  I`ve tried setting various flags on both smc and csto but no avail..

Here`s roughly my GVO code:

BaseObject* MyPlugin::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
	myObject = CreateObject((BaseObject* )(op));
	ModelingCommandData cd;
	cd.op = myObject;
	cd.doc = op->GetDocument();
		GePrint("returning SMC");
		return static_cast<BaseObject*>(cd.result->GetIndex(0));
		GePrint("returning non-SMC");
		return myObject;
	return myObject;

On 12/08/2014 at 16:06, xxxxxxxx wrote:

Pretty frustrated with this now..

Im pretty sure its a cache issue, ie CSTO being used during GVO when the deform cache isn`t yet built..

Im also aware of the issue of using having to clone the object or insert it into another document and doing CSTO with that - but ive tried every combination of it that i can think of and still just getting the basic object with no deform back..

Any help much appreciated.

On 12/08/2014 at 16:36, xxxxxxxx wrote:

try to add a bend deformer after the displacement deformer in the stack, then CSTO "not sure if it will work"

On 12/08/2014 at 17:31, xxxxxxxx wrote:

Interestingly Mohamed, when i do that the bend works fine with CSTO..  It`s just the Displacer that is not working..

What ive realised is that when i press the C key to make my plugin object editable, it generates the object into the ObjectManager exactly as i have created it - ie with the Displacer in place etc - but what ive noticed is that the shaders that i have put in the Displacer are missing!

So, somewhere along the line, when CSTO is performed, the shaders in the displacer object as lost, even though they work fine when i have GVO return the object without doing CSTO on it..

Need to do more digging i think.

On 12/08/2014 at 17:53, xxxxxxxx wrote:

in the worst case you will do it manually , reading all displaced points into another array, then remove deformers and modify current point array with the stored array

On 12/08/2014 at 17:59, xxxxxxxx wrote:

I figured it out damnit - it turns out, i was inserting the shaders, with InsertShader(), into the op ( ie the generator plugin object itself ), which worked fine for normal operation but not when doing CurrentStateToObject..  What fixed it was using InsertShader() to insert the shaders into the Displacer object itself.

Doesn`t make a great deal of sense why it should work in one case and not the other, but at least i know now.

On 12/08/2014 at 18:08, xxxxxxxx wrote:

looks like a design hole :smile: , if they intend to let it work like this, then the shader shouldn't be added to the mesh object by all means "so if you link it in displacement deformer object it shouldn't work", but somehow it works with link, but not with bake