On 19/07/2013 at 12:23, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform:
Language(s) : C++ ;
---------
Hi! I'm still pretty much a noob when it comes to C++ so even the simplest things, that would take me 2 minutes in Python, can get very tricky. :)
At the moment I'm struggling with assigning a preset noise shader to SHADERLINK GUI element in an object plugin.
Thats what I have so far.
// This part happens in the Init method of the plugin
BaseShader *noise = BaseShader::Alloc(Xnoise);
data->SetLink(TEXTURE, noise);
Obviously there's something wrong with this, because I don't see the shader, when I start the plugin. I know, that the Basecontainer basically points to a TEXBOX_GUI element that contains the shader link, but I don't know how access it.
The other part I'm struggling with is the get part of the equation, where I want so sample the shader that's set in the GUI.
Here I'm using this:
/// This is in the ModifyObject method
texture = (BaseShader* )data->GetLink(TEXTURE,doc,Xbase);
if (texture) {
if (texture->InitRender(InitRenderStruct()) != INITRENDERRESULT_OK) return FALSE;
}
ChannelData cd;
cd.p = Vector(0,0,0); // this is just an example vector
value *= texture->Sample(&cd).x; // This is where things go sour
It works somewhat half way, because I can load some shaders that I manually assign during runtime, but whenever I pick a noise shader I get a straight crash. The debugger is pointing me to the Sample method of BaseShader in the api to be the cause for the exception.
I'm guessing it has something to do with the volumetic information of the ChannelData, because it doesn't happen with simple 2D shaders, but I'm not sure.
I hope someone can help me out. :)