Value Texture (metaclass)

From The Foundry MODO SDK wiki
Jump to: navigation, search

ValueTexture server can be created using metaclasses.


The ValueTexture server is similar to a Package in that it depends on channels. Channels defined for evaluation input are read into the channels struct, and those for nodal evaluation are then overwritten if they are wired for nodal evaluation. All of that is handled automatically by setting the proper state in the CLxAttributeDesc object.

	desc.eval_flag (LXfECHAN_READ);
	desc.nodal_input ();

The client's texture returns a pointer to the destination for the channel values, and computes the texture output in its eval() method.

class MyValueTexture : public CLxValueTexture
	MyChannels		 my;
		void *
	struct_ptr ()					LXx_OVERRIDE
		return reinterpret_cast<void *> (&my);
	eval (
		ILxUnknownID		 vector,
		CLxPkg_TextureInput	&tInp,
		CLxPkg_TextureOutput	&tOut)		LXx_OVERRIDE
		LXtFVector		 rgb;
		tOut.Set (rgb);
static CLxMeta_ValueTexture<MyValueTexture>	 vtex_meta ("myValueTextureServerName");

If UI settings for channels are set the ChannelUI metaclass will need to be added.

	vtex_meta.add_channel_ui<CLxChannelUI> ();