On 29/05/2015 at 10:46, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R16
Platform: Mac OSX ;
Language(s) : C++ ;
---------
Hi
Ive copied some of the "bake texture" code that's been posted here the last couple of days. Ive got this:
Bool MenuTest::Execute(BaseDocument *doc)
{
BaseObject *obj = doc->GetFirstObject();
UVWTag* uvwTag = (UVWTag* )obj->GetTag(Tuvw);
if(uvwTag == nullptr)
return true;
BaseTag* tag = obj->GetFirstTag();
maxon::BaseArray<TextureTag*> textureTagArray;
maxon::BaseArray<UVWTag*> uvwTags;
while(tag)
{
GePrint(tag->GetName());
if(tag->GetType() == Ttexture)
{
textureTagArray.Append((TextureTag* )tag);
uvwTags.Append((UVWTag* )uvwTag);
}
tag = tag->GetNext();
}
if(textureTagArray.GetCount() == 0)
return true;
Int32 BakeWidth = 256;
Int32 BakeHeight = 256;
BaseContainer settings;
settings.SetBool(BAKE_TEX_SHOW_STATUS, true);
settings.SetInt32(BAKE_TEX_WIDTH, BakeWidth);
settings.SetInt32(BAKE_TEX_HEIGHT, BakeHeight);
settings.SetInt32(BAKE_TEX_PIXELBORDER, 0);
settings.SetBool(BAKE_TEX_CONTINUE_UV, true);
settings.SetBool(BAKE_TEX_USE_PHONG_TAG, true);
settings.SetVector(BAKE_TEX_FILL_COLOR, Vector(0.0));
settings.SetBool(BAKE_TEX_COLOR, true);
settings.SetBool(BAKE_TEX_COLOR_ILLUM, true);
settings.SetBool(BAKE_TEX_COLOR_SHADOWS, true);
settings.SetBool(BAKE_TEX_COLOR_LUMINANCE, false);
settings.SetBool(BAKE_TEX_COLOR_DIFFUSION, false);
BAKE_TEX_ERR err;
BaseDocument* bakeDoc = InitBakeTexture( doc, textureTagArray.GetFirst(), uvwTags.GetFirst(), nullptr, textureTagArray.GetCount(), settings, &err;, nullptr );
if(err == BAKE_TEX_ERR_NONE)
{
const String LayerNameOne = "Shadow";
const String LayerNameTwo = "Gi";
MultipassBitmap* bitmap = MultipassBitmap::Alloc(BakeWidth,BakeHeight,COLORMODE_RGB);
BakeTexture(bakeDoc,settings,bitmap,nullptr,nullptr,nullptr);
MultipassBitmap* layerOne = bitmap->AddLayer( nullptr, COLORMODE_RGB );
// layerOne->SetName(LayerNameOne);
MultipassBitmap* layerTwo = bitmap->AddLayer( nullptr, COLORMODE_RGB );
// layerTwo->SetName(LayerNameTwo);
Int NumLayers = bitmap->GetLayerCount();
GePrint("Number of layers: " + String::IntToString(NumLayers));
ShowBitmap(bitmap);
MultipassBitmap::Free(bitmap);
}
else if(err != BAKE_TEX_ERR_NONE)
{
MessageDialog(GeLoadString(err));
}
BaseDocument::Free(bakeDoc);
}
Even though i'm calling AddLayer twice i only get the base layer and one additional layer in PV when i run the code.
How am i supposed to do this? I thought that the additional layers would be added automatically to "bitmap" when i specify more than one channel.
I am also wondering how i am supposed to do this if i need to bake out animation. The Bake Texture tag has timing parameters in its UI. But i can't find any timing settings in c4d_tools.h.
Any help appreciated.
Cheers
Bonsak