Notifications
Clear all

[Closed] Create & use CompositeTexturemap in C#/C++?

Hello,

I am trying to programatically instantiate a CompositeTexturemap, add a second layer, and set the maps & blendmodes.

I can do this fine in MaxScript, such as:

diffuse_map = CompositeTextureMap(); 
diffuse_map.add(); 
diffuse_map.blendMode[2] = 2; 
diffuse_map.mapList[1] = (bitmapTexture filename:"E:/Diffuse.jpg")
diffuse_map.mapList[2] = (bitmapTexture filename:"E:/Diffuse2.jpg")

But I cannot do this in C++/C# because there is no Add() method on the IMultiTex interface, and SetNumSubTexmaps() does not work. By that I mean, I call it but the count for the various table entries in the ParamBlock2 (i.e. Maps, MapEnable, Mask, …) do not increase, and simply calling set with a higher index results in some working but some not.

Does anyone have an example of how to use this class from the SDK?

Sj

2 Replies

you can access it via it’s function publishing interface (it’s the same interfaces the mxs calls you listed use). Though there are many many examples of creating a fp interface good luck in finding an example of one being called from another plugin as i’ve never seen one.

this will get you access to the interface

#include "<whatever path>\maxsdk\samples\materials\composite.h"
   
   if(texmap->ClassID() == Class_ID(COMPOSITE_CLASS_ID, 0 ))
   {
   		Composite::Interface* ip = GetCompositeInterface(texmap);
  		if(ip)
  		{
   			int numlayers = ip->MXS_Count()
   			ip->MXS_AddLayer();
   			ip->MXS_AddLayer();
   			ip->MXS_DeleteLayer(0);
   			ip->MXS_DuplicateLayer(0);
   			ip->MXS_MoveLayer(1,0,true);
  	    }
   // you would the access the new layers via the subanims mechanism
   
   }

from the source code cpp

Reference system:
The reference Index works as follow for textures:
[0] – The parameter block
[1…n( – The Textures (1)]
[n…2n( – The Masks (1)]

think you can then access the layer setting via the texmap param block…

kBlendMode = 5
kOpacity = 8

then access would be like this (where layerNumber = the layer index)

IParamBlock2* pblock = texmap->GetParamBlock(0);
 pblock->SetValue (kBlendMode , t, kMultiply, layerNumber);
 pblock->SetValue (kOpacity , t, 0.5f, layerNumber);

Thank you Klvnk!

I have retrieved the FPInterface from the CompositeTexturemap class, from the ClassDirectory and have found how to invoke the ‘add’ method. (Since the managed SDK doesn’t have the CompositeInterface itself).

I just need to figure out how to create an FPParams object in the managed SDK and I can try it.

Sj