Opolygon

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 02/10/2008 at 02:32, xxxxxxxx wrote:

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

---------
Hi,

I am currently trying to construct an object from a plugin, having a list of points and vertices etc. I found the Modeling class in the SDK but I am guessing there must be a much simpler way to create a polygon object (points, vertices, faces) from C++?

Sorry if this seems trivial...I couldn't find anything on this topic 😉

Thanks

Markus

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 02/10/2008 at 07:37, xxxxxxxx wrote:

Hi,

if you want to do it by hand you have to alloc your poly object, then get the points and poly arrays, and fill them by hand.

somewhat like this:

> <code>
> // create poly-object and init with point count and polycount
> PolygonObject* polygon = PolygonObject::Alloc(ppCount,polyCount);
> PointObject* point = ToPoint(polygon);                                                                                                                                                                
>
> // get points array
> Vector* padr = point->GetPointW();
> // get poly array
> CPolygon* polys = polygon->GetPolygonW();
>
> // set points
> for(int i=0;i<ppCount;i++){
>      padr->x = polyPoints _.x;
>      padr->y = polyPoints _.y;
>      padr->z = polyPoints _.z;
>         // inc point adress
>      padr++;
> }
>
> // set polys point indices
> for(int p=0;p<polyCount;p++){
>       polys->a = ..
>       polys->b = ..
>       polys->c = ..
>       polys->d = ..     
>       // inc poly adress               
>       polys++;
> }
>
> // add it to the document          
> polygon->SetPhong(TRUE,FALSE,0);
> polygon->InsertAfter(doc->GetActiveObject());
> polygon->SetName("Polygon");
> .
> .
> </code>

maybe there's a better way to do this, but this works for me 😉

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 02/10/2008 at 09:21, xxxxxxxx wrote:

Many thanks, this exactly like what I was searching for 😉 Will try asap.