THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/09/2010 at 14:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C++ ;
---------
Hi, I´m trying to make a BakeTexture plugin, my principal propourse is do the same as BakeTexture tags, but making each bake operation sequentially, and never baking all objects at the same time (yes, I get out of memory errors, especially when i have +500 objects to be baked...)
The plugin tries to bake every object with a BakeTexture tag attached...(if tag name is not "Preparar Textura DONE").
The problem now is InitBakeTexture() fails on compile... (I get C2665: none of the 2 overloads can convert all argument types)
Any ideas??
My code:
#define ID_BAKINGPLUGIN 0000001
// unique ID for this plugin
#include "c4d.h"
#include <string.h>
//########################################
class HelloWorldTest : public CommandData // data class for creating new commands (previously known as "menu plugins")
{
// Funciones que use el plugin
////////////////////////////
///////////////////////////
void Dialog (String message)
{
MessageDialog(message);
}
public:
virtual Bool HelloWorldTest::Execute(BaseDocument *doc) //Plugin
{
//MessageDialog("Hello World"); // simple popup message
GePrint("This is my first plugin"); // output to C4D's "Console window"
BaseObject* obj = doc->GetFirstObject();
if(!obj)
{
Dialog("No objects in the scene!");
return TRUE;
}
BaseDocument* bakeDoc;
// Bake settings:
int bakecounter = 1;
BaseContainer bakeSettings;
bakeSettings.SetBool(BAKE_TEX_ILLUMINATION, TRUE);
bakeSettings.SetBool(BAKE_TEX_SHADOWS, TRUE);
bakeSettings.SetBool(BAKE_TEX_USE_PHONG_TAG, TRUE);
bakeSettings.SetBool(BAKE_TEX_COLOR_ILLUM, TRUE);
bakeSettings.SetBool(BAKE_TEX_COLOR_SHADOWS, TRUE);
bakeSettings.SetBool(BAKE_TEX_AUTO_SIZE, TRUE);
bakeSettings.SetLong(BAKE_TEX_AUTO_SIZE_MIN, 256);
bakeSettings.SetLong(BAKE_TEX_AUTO_SIZE_MAX, 2048);
bakeSettings.SetReal(BAKE_TEX_AUTO_PIXEL_SIZE, 2.0);
while(obj)
{
MessageDialog(obj->GetName());
BaseTag* baketag = obj->GetTag(Tbaketexture);
if(baketag)
{
if(baketag->GetName() != "Preparar Textura DONE")
{
BaseTag* textag = obj->GetTag(Ttexture);
BaseTag* uvwtag = obj->GetTag(Tuvw);
if(textag)
{
LONG error;
// Init bake:
bakeDoc = InitBakeTexture(doc, textag, uvwtag, NULL, bakeSettings, NULL, NULL);
// BaseBitmap:
BaseBitmap* resultbitmap = BaseBitmap::Alloc();
error = BakeTexture(doc, bakeSettings, resultbitmap, 0,NULL,NULL);
}
}
}
//////////////////////
BaseObject* obj2 = obj->GetDown();
if(obj2)
{
obj=obj->GetDown();
}
else
{
BaseObject* obj3 = obj->GetNext();
if(obj3)
{
obj=obj->GetNext();
}
else
{
obj=obj->GetUp()->GetNext();
}
}
}
MessageDialog("Everything baked successfully!");
return TRUE;
}
};
//########################################
Bool PluginStart(void) // the main function C4D calls to begin your plugin (think of it as main)
{
return RegisterCommandPlugin( ID_BAKINGPLUGIN,"Sequential Baking",
0,NULL,String("Sequential Baking"),
gNew HelloWorldTest );
// registers a command plugin with C4D
// (ie: the class to execute when user selects "Hello World" under the Plugin menu)
}
void PluginEnd(void) // called when the plugin is unloaded from C4D
{
}
Bool PluginMessage(LONG id, void *data) // allows you to receive plugin messages from C4D or other plugins
{
return TRUE;
}