Triangulate?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2007 at 03:42, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.1
Platform: Windows ;
Language(s) : C++ ;---------
Im writing a plugin to export C4D scenes to indigo XML format. When i export to .obj format(3ds gets triangulated automatically) i need to triangulate the mesh before export. how do i do that?heres a code snippet:
Bool ExportXML::ExportObject(BaseObject *bo, BaseDocument *doc, Bool objExport, Filename fn, Bool meshLight)
{
BaseDocument *doc_dummy = BaseDocument::Alloc();
BaseTag *baset;
GeData gedata;
Material *tagmat;
Material *clonetagmat;
//Vector tempVector;
//Vector vector;if (meshLight == 0)
{
//COPY MATERIAL
}//COPY OBJECT
//SET POS 0,0,0 and ROTATION
Matrix matrix = baseobj->GetMg();matrix.off.x = 0;
matrix.off.y = 0;
matrix.off.z = 0;//rotete if .obj 0 1 0
if(objExport == 1)
{
//x
matrix.v1.x = 1;
matrix.v1.y = 0;
matrix.v1.z = 0;
//y
matrix.v2.x = 0;
matrix.v2.y = 0;
matrix.v2.z = -1;
//z
matrix.v3.x = 0;
matrix.v3.y = 1;
matrix.v3.z = 0;
}baseobj->SetMg(matrix,FALSE);
if (meshLight == 0)
{
//SET MAT
}if(objExport == 1)
{
// triangulate here
}//EXPORT
if (objExport == 1) SaveDocument(doc_dummy,fn,TRUE,FORMAT_OBJEXPORT);
else SaveDocument(doc_dummy,fn,TRUE,FORMAT_3DSEXPORT);doc_dummy->Free(doc_dummy);
return TRUE;
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2007 at 09:05, xxxxxxxx wrote:
Have you tried Triangulate()?
If your object isn't polygonal, you'll need to convert it to be so first using either BaseDocument::Polygonize() or SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT,...).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2007 at 10:05, xxxxxxxx wrote:
yes, i saw thet function in the documentation, but i have no clue wherei should get the values from
Bool Triangulate(Vector* padr, LONG pcnt, CPolygon** vadr, LONG* vcnt)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2007 at 12:13, xxxxxxxx wrote:
Straight from the polygon object:
BaseObject* obj; // Your starting object PolygonObject* pobj = ToPoly(obj); Vector* padr = pobj->GetPoint(); LONG pcnt = pobj->GetPointCount() if (!pcnt) return FALSE; // - or some error handling. This object has no points (and no useful polygons) // These point to the newly created polygon triangle array and the number of triangles - don't forget to GeFree(tripolys) when you are done with the array! CPolygon* tripolys; LONG tricount; if (!Triangulate(padr, pcnt, &tripolys;, &tricount;)) return FALSE; // Failed to triangulate if (!(tripolys && tricount)) return FALSE; // tripolys=NULL or tricount=0L
Then use these polygons instead of the ones on the original object - use the original points as they don't get changed during triangulation.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2007 at 14:17, xxxxxxxx wrote:
thank you so far, but i still dont get what to do with the array.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/03/2007 at 14:44, xxxxxxxx wrote:
Ah, you are using the built-in Cinema 4D OBJ export. There are two ways to do this then:
1. Triangulate using SendModelingCommand(MCOMMAND_TRIANGULATE) and get the result to use for export - you'll probably want to InsertObject() this result into the dummy document. Follow the MCOMMAND_CURRENTSTATETOOBJECT example in this case.
2. Use the tripoly array to update the Polygon object. This will require calling PolygonObject::ResizeObject() with the current vertex array size and new polygon array size, filling in its polygon array with the tripoly array info, and then using the original Polygon object for export.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2007 at 00:54, xxxxxxxx wrote:
thank you very much, works great.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/04/2008 at 10:50, xxxxxxxx wrote:
ok, first of all, sry for ressurrecting such an old topic.
I'm still have problems with triangulation.
Until now i was using SendModelingCommand(MCOMMAND_TRIANGULATE, Mdd), and it works fine.
But when i use Triangulate() the way kuroyume described, they alway come out mixed up, i cant get i to work:
help?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/04/2008 at 14:58, xxxxxxxx wrote:
did i understand something wrong?
no idea, anyone?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/01/2009 at 05:13, xxxxxxxx wrote:
Hey, I just got the very same problem.
Found any solution yet?Or is there working example code for the MCOMMAND_TRIANGULATE? Can't get that to work, either.
Thanks in advance!
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/01/2009 at 03:23, xxxxxxxx wrote:
Triangulate() is not really meant to be used for existing polygon meshes but rather for example to create triangles from a point cloud.
> Quote: _Or is there working example code for the MCOMMAND_TRIANGULATE?
>
> * * *
_
That's actually pretty easy, here an example:
>
\> Bool MenuTest::Execute(BaseDocument \*doc) \> { \> StopAllThreads(); \> \> BaseObject \*op = doc->GetActiveObject(); \> if(!op) return TRUE; \> \> if(op->GetType() == Opolygon) \> { \> ModelingCommandData md; \> md.doc = doc; \> md.op = op; \> \> SendModelingCommand(MCOMMAND_TRIANGULATE, md); \> } \> \> return TRUE; \> } \>
cheers,
Matthias