THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2012 at 08:57, xxxxxxxx wrote:
Okay, next problem:
How can I access the BaseContainer() of a BaseObject() created this way to manipulate it?
Neither the SetParameter/GetParameter nor the GetDataInstance method seems to work!
I can fill the base container with parameters and pass it to the object with GeneratePrimitive() but how can I change them afterwards?
I'm confused.
/////////////////////////////////////////////////////////////
// CINEMA 4D BaseDrawTest //
/////////////////////////////////////////////////////////////
// (c) 2012 Thomas Chen, all rights reserved //
/////////////////////////////////////////////////////////////
// basedrawtest.cpp //
/////////////////////////////////////////////////////////////
#include "c4d.h"
#include "c4d_symbols.h"
#include "obasedrawtest.h"
#if API_VERSION < 12000
#define EXECUTIONRESULT LONG
#define EXECUTIONFLAGS LONG
#define EXECUTIONRESULT_OK EXECUTION_RESULT_OK
#define DRAWRESULT Bool
#define DRAWPASS LONG
#define DRAWRESULT_OK TRUE
#endif
/////////////////////////////////////////////////////////
// Class functions
/////////////////////////////////////////////////////////
class BaseDrawTest : public ObjectData
{
INSTANCEOF(BaseDrawTest, ObjectData)
public:
virtual Bool Init(GeListNode* node);
virtual void Free(GeListNode* node);
virtual EXECUTIONRESULT Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, LONG priority, EXECUTIONFLAGS flags);
virtual DRAWRESULT Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh);
static NodeData *Alloc(void) { return gNew BaseDrawTest; }
private:
BaseObject* plane;
};
Bool BaseDrawTest::Init(GeListNode *node)
{
//plane: GeneratePrimitive(), Osinglepoly
BaseContainer bc_plane;
bc_plane.SetReal(PRIM_POLY_WIDTH, 200.0);
bc_plane.SetReal(PRIM_POLY_HEIGHT, 200.0);
bc_plane.SetLong(PRIM_POLY_SUB, 1);
bc_plane.SetBool(PRIM_POLY_TRIANG, FALSE);
bc_plane.SetLong(PRIM_AXIS, PRIM_AXIS_ZN);
plane = (BaseObject* )GeneratePrimitive(node->GetDocument(), Osinglepoly, bc_plane, 1.0, FALSE, NULL);
return TRUE;
}
void BaseDrawTest::Free(GeListNode* node)
{
BaseObject::Free(plane);
}
EXECUTIONRESULT BaseDrawTest::Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, LONG priority, EXECUTIONFLAGS flags)
{
return EXECUTIONRESULT_OK;
}
DRAWRESULT BaseDrawTest::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh)
{
if (drawpass==DRAWPASS_OBJECT)
{
const Matrix &m; = bh->GetMg();
//pplane: DrawPolygonObject(), Osinglepoly
if (plane)
{
plane->SetParameter(DescID(PRIM_POLY_WIDTH), GeData(1000.0), DESCFLAGS_SET_0); //<--- Doesn't work!
BaseContainer *bc = plane->GetDataInstance(); //<--- Doesn't work either!
bc->SetReal(PRIM_POLY_HEIGHT,1000.0); //<--- Doesn't work either!
plane->SetMg(m); //<--- Okay, that works of course! ;o)
bd->DrawPolygonObject(bh, plane, DRAWOBJECT_XRAY_ON, op, NULL);
}
}
return DRAWRESULT_OK;
}
/////////////////////////////////////////////////////////
// Register function
/////////////////////////////////////////////////////////
Bool RegisterBaseDrawTest(void)
{
// decide by name if the plugin shall be registered - just for user convenience
String name = GeLoadString(IDS_BASEDRAWTEST); if (!name.Content()) return TRUE;
#if API_VERSION < 12000
return RegisterObjectPlugin(ID_BASEDRAWTEST,name,OBJECT_USECACHECOLOR,BaseDrawTest::Alloc,"Obasedrawtest","icon.tif",0);
#else
return RegisterObjectPlugin(ID_BASEDRAWTEST,name,OBJECT_USECACHECOLOR,BaseDrawTest::Alloc,"Obasedrawtest",AutoBitmap("icon.tif"),0);
#endif
}