THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/12/2004 at 08:12, xxxxxxxx wrote:
Cinema 4D Version: 8.100
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;
Hello, I'm writing an export plugin for a game and I need to know how to save each polygons vertex indexes of an object. I managed to export points xyz values but don't know how to retrieve polygons indexes. I found that PolygonTag gives the index array of a polygon but I don't know how to implement it in code.
On 14/12/2004 at 21:05, xxxxxxxx wrote:
For a Polygon Object, vertices and polygons are stored in arrays. obj->GetPoints() and obj->GetPolygons() get the arrays while obj->GetPointCount() and obj->GetPolygonCount() get the number of elements in each array.
After you get the polygon array, you can get the vertex indices directly:
var polys = obj->GetPolygons(); // object Polygon array
var pcnt = obj->GetPolygonCount(); // object Polygon count
var vindex; // a Polygon's vertex indices for storage
for (var j = 0; j < pcnt; j++)
// polygon.a,.b,.c,.d contain indices into the vertex array
vindex = polys[j].a;
vindex = polys[j].b;
vindex = polys[j].c;
if (polys[j].d != vindex) vindex = polys[j].d;
else vindex = -1; // For triangles, index c = d
This is off the top of my head (and it's easier for me to think in C++ at the moment), but just to give you a general idea.
On 15/12/2004 at 09:26, xxxxxxxx wrote:
I managed to access polys[j]; itself but I get errors accessing polys[j].a, polys[j].b etc. I'm not sure COFFEE is supporting this unless if its a vector type. Well I'm not sure correct me if I'm wrong.
On 15/12/2004 at 10:01, xxxxxxxx wrote:
If you are still getting your array from a PolygonTag and not the object Polygon array, then, yes, that would be incorrect.
The PolygonTag returns an array with each member containing a 4-array with real Points in it, not vertex indices.
This information is in the COFFEE docs.
On 15/12/2004 at 15:07, xxxxxxxx wrote:
Thanks a lot but I had a different approach. This is what I did to retrieve it:
for (cnt = 0; cnt < model->GetPolygonCount(); j++)
I managed to get its index this way and it works! No need for PolygonTags.