THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/05/2004 at 06:20, xxxxxxxx wrote:
Normally, when no context is given, any example code I post is simply run in the CommandData::Execute() function of the menu plugin example. Sorry for not being more clear on that.
The TagData::Execute() code is run in a thread. So strictly speaking I'm not sure if the material update calls are allowed. (EventAdd() is of course an even bigger no-no, since it would trigger a new expression evaluation.)
But aside from that, the code above still works for me in the LookAtCamera expression example:
enum
{
CLOUDSHADER_SCALEX = 1002, // REAL
CLOUDSHADER_SCALEY = 1003, // REAL
CLOUDSHADER_LEVEL = 1004, // REAL
CLOUDSHADER_COLOR = 1005, // VECTOR
CLOUDSHADER_COMPATIBILITY = 1006
};
LONG LookAtCamera::Execute(PluginTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, LONG flags)
{
BaseMaterial* mat = doc->GetFirstMaterial();
BaseChannel* chan = mat->GetChannel(CHANNEL_COLOR);
PluginShader* shader = chan->GetShader();
if (shader->GetType() == Xcloud)
{
shader->SetParameter(DescLevel(CLOUDSHADER_SCALEX), ((GeGetTimer() % 100) + 1)/100.0, 0);
}
shader->Message(MSG_UPDATE);
chan->Message(MSG_UPDATE);
mat->Message(MSG_UPDATE);
mat->Update(TRUE, TRUE);
//EventAdd();
return EXECUTION_RESULT_OK;
}
I put a material with a cloud shader on a cube and applied the expression. When I rotated the camera the texture shown in the scene changed in realtime (regardless of the OpenGL setting).
I assume that's not what happened in your experiments. Can you think of anything that's different from the above in your code?