2004-11-24 05:11 PM - last edited on 2022-12-13 10:30 PM by Daniel Kassai
ACAPI_3D_DecomposePgon(long ipgon, long ***cpoly)And now the question:
This function is used to decompose a polygon into convex polygons.
The polygon is defined by ipgon index.
The decomposed polygon is returned in the cpoly long array,
which contains the following values:
[-n], [-m1], i1, i2, ... i(m1), [-m2], j1, j2, ... j(m2)...
//j is allready referencing the current polygon long * Verts = new long[100]; // array of 100 longs (seems stupid) long ** cpoly = &Verts; // a pointer to this array GSErrCode TriangulationError = ACAPI_3D_DecomposePgon(j, &cpoly);When I do this, Archicad goes through, but I cannot do anything with the results... Do I miss something? Do I need to allocate memory? Or do I need an array with pointers to longs? Or is it actually an array of verts?
2004-11-24 06:12 PM
long** cpoly=0; // this is handle bool ok = ACAPI_3D_DecomposePgon( id, &cpoly ) == NoError; ... and after using BMhKill((GSHandle*)&cpoly );PS: One more open source renderer for you http://www.cs.berkeley.edu/~okan/Pixie/pixie.htm
2004-11-25 11:16 AM
2004-11-25 11:46 AM
stefan wrote:You dont need to allocate memory, but you need to release the memory ( kill the handle ).
Thanks again!
Now, do I need to allocate memory myself or is that the responsability of the DecomposPgn function?
And lastly, I'm still struggling on getting access to the actual array that should be referenced by the cpoly.
Would *cpolygive me acces to it? Or do I need to cast it to a (GSHandle*) and then work through the handle?
2004-11-25 11:52 AM
long n = (*cpoly)[0] * -1; // number of sub-polygons if (n > 0) { for (long poly = 0; poly < n; ++poly) { ++count; long m = (*cpoly)[count] * -1; // number of vertices in current subpolygon if (m > 0) { // get indices to the vertices for (long vert = 0; vert < m; ++vert) { ++count; long vertindex = (*cpoly)[count]; // get the actual vertex component.header.typeID = API_VertID; component.header.index = vertindex; err = ACAPI_3D_GetComponent (&component); if (err == NoError) { double xx, yy, zz; xx = component.vert.x; yy = component.vert.y; zz = component.vert.z; // transform it into world coordinates Geometry::TMPoint(&tranmat_struct, &xx, &yy, &zz); // export... } // end if no error getting vertex } // end for vert } // end if m > 0 } // end for poly } // end if n > 0Well, one step closer to heaven
2004-11-25 04:59 PM
long vertindex = (*cpoly)[count]; vertindex +=1;before you get the actual vertex (API_VertID)