THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/03/2006 at 11:26, xxxxxxxx wrote:
Hey David,
I checked and the Ngons are being created and the Ngon count seems to be correct. In fact, I finished implementing the export side of things and all the calls used for that are retrieving the data correctly as well - but if I set the display Mode to 'N-Gons' in the Structure Browser, it's blank (no polys, no ngons, no nothing is listed).
This is the code that I finally got working:
//======== S N I P - bunch-o-code above here to set up the object
if( m_opt_mpNgons && m_numNgons ) // see if we need to set up Ngons...
{
op->GetNgon(); // force NgonBase to be created
pNgonBase = op->GetNgonBase();
if( pNgonBase )
{
op->Message(MSG_UPDATE);
NgonLoader *pNgons = &m_pNgons[0]; // <-- NgonLoader is my own structure
for(i=0; i<m_numNgons; i++)
{
LONG ndx;
LONG *pEdge = &m_pEdgeList[0]; // <-- array big enough to hold max-ngon-edges
if( m_opt_mpRevFaces )
{
for(ndx=0; ndx<pNgons->polycnt; ndx++) // default action is to reverse faces, so this logic is backwards...
{
if( ndx == 0 ) // if this is the first poly, add edge #0
*pEdge++ = (pNgons->polys[ndx] * 4)+0;
*pEdge++ = (pNgons->polys[ndx] * 4)+1; // add edge #1
if( ndx == pNgons->polycnt-1 ) // if this is the last poly, add edge #3
*pEdge++ = (pNgons->polys[ndx] * 4)+3;
}
}
else
{
for(ndx=pNgons->polycnt-1; ndx>=0; ndx--) // need to reverse order for proper winding
{
if( ndx == pNgons->polycnt-1 ) // if this is the first poly, add edge #3
*pEdge++ = (pNgons->polys[ndx] * 4)+3;
*pEdge++ = (pNgons->polys[ndx] * 4)+0; // add edge #0
if( ndx == 0 ) // if this is the last poly, add edge #1
*pEdge++ = (pNgons->polys[ndx] * 4)+1;
}
}
pNgonBase->BuildNgon(NULL, m_pEdgeList, 0, pNgons->polycnt+2, vadr, padr);
pNgons++;
}
pNgonBase->InitMap();
pNgonBase->SetFlags(NGON_FLAG_NOVALIDATION);
}
}
doc->InsertObject(op,NULL,NULL);
op->MakeTag(Tphong);
op->Message(MSG_UPDATE);
doc->SetActiveObject(op);
}
...in the above code, the 'NgonLoader ' is my own structure, that keeps track of the triangles (no quads, in this case) that make up the Ngons. Also, by default, I reverse the winding order of polygons on import, to fit C4D's system (there's an option that lets you 'reverse faces', which in this case actually loads them as they are found in the file). Anyway, the above code checks for each condition and sets up the Ngon edges appropriately for each case.
So, as I mentioned, the code 'appears' to be working correctly - it creates Ngons, which are visible/selectable/etc. in the editor window, if I enable the option to view Ngons, I can see the original triangles that make up the Ngons and op->GetNgonCount(), op->GetPolygonTranslationMap(), op->GetNGonTranslationMap(), op->GetNgon() and op->GetNgonEdgesCompact() all seem to be working correctly. The only thing that seems to not be working is the Structure Manager display, as described above.
Any thoughts?
Thanks,
- Keith