Trigger on BaseShader change
-
I am wondering how to detect a change in
BITMAPSHADER_FILENAME
of aBaseShader
?Say I have a
GeDialog
which lists information of the current active object.
A material was created and assigned to the object.That material has aXbitmap
BaseShader
.
The dialog displays the filename of the bitmap by parsing theBaseMaterial
's colorBaseChannel
.
If itsBaseShader
is an instance ofXbitmap
it gets theBITMAPSHADER_FILENAME
parameter.
Now, when the user replaces the bitmap of the color channel with another bitmap, what trigger could be used to detect this from within theGeDialog
?
Is some kind of message sent (EVMSG_xxx)?Edit:
I 'd like to broaden the question a little. Next to knowing how to detect a change of bitmap in a material, what would be the best way to detect a change of material? How to detect when user removes or assigns a material to aBaseObject
? -
In the meantime I went for a simplified solution, as I only need to monitor a single texture from a single material. I thus went with a MessageData plugin, and listen to the EVMSG_CHANGE. Then I check if the current material's texture filename is still the same and perform the necessary when different.
Obviously this will not work when user changes the content of the bitmap file on disk, without changing the name ... but it's a start. -
Hello,
There's nothing more than that.
Some remarks:
-
You can simple react to the CoreMessage, EVMSG_CHANGE and EVMSG_DOCUMENTRECALCULATED inside your GeDialog without the need to use a
MessageData
. You also could need to react to this message MESSAGE_ACTIVE_NODESPACE_CHANGED -
You can also checked for the dirty state of the Document with GetHDirty using the mask HDIRTYFLAGS::MATERIAL | HDIRTYFLAGS::SHADER and store it in a class variable to compare if it does changed.
That's what the AssetInspector is doing to check if something have changed.
Cheers,
Manuel. -
-
@m_magalhaes
Thanks for reminding me of theGeDialog::CoreMessage
.
I totally overlooked that.