[Melange] How to add PLA to a PolygonObject?

On 20/12/2013 at 08:39, xxxxxxxx wrote:

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

Hi there,

I have created a PolygonObject :

int nbPts(8);   
int nbFaces(12);   
_melange_::BaseObject* c4dMesh = _melange_::BaseObject::Alloc(Opolygon);   
((_melange_::PolygonObject* )c4dMesh)->ResizeObject(nbPts, nbFaces, 0);   

How should I proceed to add PLA to my object?
Should I create a CTrack? But this requires a tag to be created and there is no PLA tag. Indeed when importing a FBX file with vertex cache, no PLA tag is created.
Should I then add a CCurve?

Any help would be appreciated, I couldn't find an example of creating PLA from scratch.


On 03/01/2014 at 07:13, xxxxxxxx wrote:


I could answer my own question, so if anyone is interested in adding PLA, here is a way to do it :

First add a track to the polygon object "c4dMesh"

_melange_::CTrack *plaTrack(   
                    _melange_::DescLevel(CTpla, CTpla, 0)),   
          _melange_::CCurve *plaCurve(plaTrack->GetCurve());

Now add a key for each time sample and fill the data.

_melange_::BaseTime t;   
          _melange_::CKey *plaKey(plaCurve->AddKey(t));   
          _melange_::CustomDataType *plaData(_melange_::PLADataTypeClass::AllocData());   
          _melange_::PointTag *pointTag;   
          _melange_::TangentTag *tangentTag;   
          ((_melange_::PLAData* )plaData)->GetVariableTags(pointTag, tangentTag);   
          _melange_::Vector *a = pointTag->GetPointAdr();   
          for (size_t i_pt(0); i_pt < nbPoints; ++i_pt)   
               a[i_pt].x = animatedPoints[3 * i_pt];   
               a[i_pt].y = animatedPoints[3 * i_pt + 1];   
               a[i_pt].z = animatedPoints[3 * i_pt + 2];   
          _melange_::GeData dat(CUSTOMDATATYPE_PLA, *plaData);   
          plaKey->SetParameter(CK_PLA_DATA, dat);

Hope someone finds this useful one day!