On 21/08/2014 at 23:06, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15
Platform:
Language(s) : C++ ;
---------
Hi, I can create Ngons fine with the example from the SDK. The question is, how can I create an Ngon with a user controlled number of points.
//Generate N-Gon
int mySides = 7; //this is a dynamic value, and therefore cannot be used with padr
AutoAlloc<PolygonObject> obj(0,0);
if (!obj) return FALSE;
AutoAlloc<Modeling> mod;
if (!mod || !mod->InitObject(obj)) return FALSE;
//Create a circular point array
maxon::BaseArray<Int32>myPoints; Matrix m;
for (int i=0; i<mySides; i++)
{
m = MatrixRotY(Rad(i*360/ mySides));
int temp = mod->AddPoint(obj, m*Vector(100,0,0));
myPoints.Append(temp);
}
Int32 padr[] = {-1, -2, -3, -4, -5, -6, -7}; // I want padr to use mySides for its size!!
Int32 cnt = mySides;
Int32 i = mod->CreateNgon(obj, padr, cnt);
if (!i) return FALSE;
if (!mod->Commit()) return FALSE;
doc->InsertObject(obj.Release(), NULL, NULL);
EventAdd();
Please excuse the r15 code style