Reading texture data

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 15/06/2010 at 00:43, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   11.5 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hello,

i like to read the size of an texture from a material which assigned to an base object.
I do this with the PluginShader.

PluginShader *shd = (PluginShader* )matdata->GetLink(MATERIAL_COLOR_SHADER, GetActiveDocument() , Xbitmap);

BaseBitmap *pbb = shd->GetBitmap();
if (pbb) {
    lx = pbb->GetBw();
    ly = pbb->GetBh();
}

But i get always an NULL pointer for the base bitmap??
Has someone an idea?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 15/06/2010 at 01:08, xxxxxxxx wrote:

You have to make sure to call GetBitmap() within a pair of InitRender()/FreeRender() calls. If there is no InitRenderStruct avaible you can create a dummy structure on the stack.

here an example:

  
Bool MenuTest::Execute(BaseDocument *doc)  
{  
  BaseMaterial *mat = doc->GetActiveMaterial();  
  if (!mat) return FALSE;  
  
  BaseContainer *data = mat->GetDataInstance();  
  
  PluginShader *shd = (PluginShader* )data->GetLink(MATERIAL_COLOR_SHADER, doc, Xbitmap);  
  if (!shd) return FALSE;  
  
  InitRenderStruct is;  
  is.version = GetC4DVersion();  
  is.time = doc->GetTime();  
  is.fps = doc->GetFps();  
  Filename docpath = doc->GetDocumentPath();  
  is.docpath = &docpath;  
  String matname = mat->GetName();  
  is.matname = &matname;  
  is.errorlist = NULL;  
  is.vd = NULL;  
  is.doc = doc;  
  is.thread = NULL;  
  is.flags = INITRENDERFLAG_TEXTURES;  
  
  shd->InitRender(&is);  
  
  BaseBitmap *bmp = shd->GetBitmap();  
  if (!bmp) return FALSE;  
  
  GePrint(LongToString(bmp->GetBw()));  
  GePrint(LongToString(bmp->GetBh()));  
  
  shd->FreeRender();  
  
  return TRUE;  
}  

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 15/06/2010 at 01:35, xxxxxxxx wrote:

i see, create it works
thanks a lot