THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/04/2012 at 03:32, xxxxxxxx wrote:
yes,
BaseObject *cube = BaseObject::Alloc( Ocube );
BaseObject *sphere = BaseObject::Alloc( Osphere );
cube.InsertUnder(sphere);
return sphere;
will return a sphere with cube as its child.
edit : i am a beginner myself, but here is an example of my plugin work in progress, it is a static method which either returns a loftnubrs>nsidespline or a loftnubrs > spline + spline structure. it
doesn't inculde the recursion / tree aspect of your example, but maybe it helps.
i
static BaseObject *GetDisc(BaseObject *op)
{
BaseContainer *bc = op->GetDataInstance();
BaseObject *loft = NULL, *inner = NULL, *outer = NULL;
switch (bc->GetLong(PLIGHT_DISC_TYPE))
{
case PLIGHT_DISC_TYPE_DISC :
{
loft = BaseObject::Alloc(Oloft);
inner = BaseObject::Alloc(Osplinearc);
outer = BaseObject::Alloc(Osplinearc);
BaseContainer *loftbc = loft->GetDataInstance();
BaseContainer *innerbc = inner->GetDataInstance();
BaseContainer *outerbc = outer->GetDataInstance();
loft->SetName("Light");
loftbc->SetBool(LOFTOBJECT_ADAPTIVEY , FALSE);
loftbc->SetLong(LOFTOBJECT_SUBX, bc->GetReal(PLIGHT_DISC_SEGMENTS_ROTATION) * 4 + 1);
loftbc->SetLong(LOFTOBJECT_SUBY, bc->GetReal(PLIGHT_DISC_SEGMENTS_DISC) + 2);
loftbc->SetLong(CAP_START, CAPTYPE_NOCAP);
loftbc->SetLong(CAP_END, CAPTYPE_NOCAP);
outer->SetName("Outer");
outerbc->SetReal(PRIM_ARC_RADIUS , bc->GetReal(PLIGHT_DISC_OUTER_SIZE_X));
outerbc->SetReal(PRIM_ARC_START , bc->GetReal(PLIGHT_DISC_SLICE_START));
outerbc->SetReal(PRIM_ARC_END , bc->GetReal(PLIGHT_DISC_SLICE_END));
if (bc->GetBool(PLIGHT_DISC_ISELLIPTICAL))
if (bc->GetReal(PLIGHT_DISC_OUTER_SIZE_X) > 0)
outer->SetAbsScale(Vector(1 , (bc->GetReal(PLIGHT_DISC_OUTER_SIZE_Y)/bc->GetReal(PLIGHT_DISC_OUTER_SIZE_X)) , 1));
else
outer->SetAbsScale(Vector(1 , 1 , 1));
outer->InsertUnder(loft);
inner->SetName("Inner");
innerbc->SetReal(PRIM_ARC_RADIUS , bc->GetReal(PLIGHT_DISC_INNER_SIZE_X));
innerbc->SetReal(PRIM_ARC_START , bc->GetReal(PLIGHT_DISC_SLICE_START));
innerbc->SetReal(PRIM_ARC_END , bc->GetReal(PLIGHT_DISC_SLICE_END));
if (bc->GetBool(PLIGHT_DISC_ISELLIPTICAL))
if (bc->GetReal(PLIGHT_DISC_INNER_SIZE_X) > 0)
inner->SetAbsScale(Vector(1 , bc->GetReal(PLIGHT_DISC_INNER_SIZE_Y)/bc->GetReal(PLIGHT_DISC_INNER_SIZE_X) , 1));
else
inner->SetAbsScale(Vector(1 , 1 , 1));
inner->InsertUnderLast(loft);
}
break;
case PLIGHT_DISC_TYPE_NSIDE :
{
loft = BaseObject::Alloc(Oloft);
outer = BaseObject::Alloc(Osplinenside);
BaseContainer *loftbc = loft->GetDataInstance();
BaseContainer *outerbc = outer->GetDataInstance();
loft->SetName("Light");
loftbc->SetLong(CAP_TYPE , CAP_TYPE_NGON);
outerbc->SetLong(SPLINEOBJECT_INTERPOLATION , SPLINEOBJECT_INTERPOLATION_NATURAL);
outerbc->SetLong(SPLINEOBJECT_SUB , bc->GetLong(PLIGHT_NSIDE_SEGMENTS));
outerbc->SetReal(PRIM_NSIDE_RADIUS, bc->GetReal(PLIGHT_NSIDE_SIZE_X));
outerbc->SetBool(PRIM_NSIDE_ROUNDING , TRUE);
outerbc->SetReal(PRIM_NSIDE_RRADIUS, bc->GetReal(PLIGHT_NSIDE_ROUNDING));
outerbc->SetLong(PRIM_NSIDE_SIDES, bc->GetReal(PLIGHT_NSIDE_SIDES));
if (bc->GetBool(PLIGHT_DISC_ISELLIPTICAL))
if (bc->GetReal(PLIGHT_DISC_INNER_SIZE_X) > 0)
outer->SetAbsScale(Vector(1 , bc->GetReal(PLIGHT_NSIDE_SIZE_Y)/bc->GetReal(PLIGHT_NSIDE_SIZE_X) , 1));
else
outer->SetAbsScale(Vector(1 , 1 , 1));
outer->SetAbsRot(Vector(0 , 0 , bc->GetReal(PLIGHT_NSIDE_ROTATION)));
outer->InsertUnder(loft);
}
break;
}
return loft;
}