Hi all,
I am new to the new Sketchup SDK and I am currently trying to migrate an old converter. It works fairly well (the new SDK is much better documented than the old one ) except for one point.
I use a geometry input to create my faces, since they are textured faces and so I need to set the texture coordinates. And at the end I use the SUEntitiesFill.
When trying to convert an object that has 4700 faces, I ended up with an empty SketchUp database. After some debugging, I realised that if I limited the number of faces to 2000 faces, it worked OK. So I thought there was a size limitation and tried to do the SUEntitiesFill every 2000 faces, reset the geometry input and go on. But it does not seem to work that way…
So my questions are : is there a size limit to the SUEntitiesFill or to the geometry input ? and how can I do what I want ? (without creating a serie of child components with 2000 faces )
I would really appreciate help
Thanks a lot and have a good day
Here is the code loop I currently use:
SUGeometryInputRef skpGeomInput;
SUSetInvalid(skpGeomInput);
SUGeometryInputCreate(&skpGeomInput);
// we store the SKP vertex index
int skpVtxIndex = 0;
size_t skpFaceIndex = 0;
int realNbFace = 0;
// browsing through the object faces
for(INDICE_SDM iface = MBOIsetNext(object.face, -1); iface != -1; iface = MBOIsetNext(object.face, iface))
{
if(skpFaceIndex > 2000)
{
// we flush the already converted faces
SUEntitiesFill(container, skpGeomInput, false);
// we release the geometry input
SUGeometryInputRelease(&skpGeomInput);
// we create a new one
SUSetInvalid(skpGeomInput);
SUGeometryInputCreate(&skpGeomInput);
// we reset the indices
skpVtxIndex = 0;
skpFaceIndex = 0;
}
Sdm3dLireAspectFace(sdmdb, iobj, iface, &aspectFaceComplet);
const poly & face = object.face[iface];
// getting the face vertices coordinates and adding it to a loop
int ivtx, nbVertex = MBOIlisteLength(face.ind_sommet);
SULoopInputRef skpFaceLoop;
SUSetInvalid(skpFaceLoop);
SULoopInputCreate(&skpFaceLoop);
for(ivtx = 0; ivtx < nbVertex; ivtx++)
{
som vertexPosition;
INDICE_SDM rep = SdmRepereCourant(sdmdb, iobj);
SdmRepereLireSommet(sdmdb, iobj, face.ind_sommet[ivtx], rep, &vertexPosition);
SUPoint3D skpVtx;
skpVtx.x = vertexPosition.x*METER_TO_INCH; //
skpVtx.y = vertexPosition.y*METER_TO_INCH; // Conversion from meters to inch
skpVtx.z = vertexPosition.z*METER_TO_INCH; //
if(ivtx < 4) // the material input structure only wants 4 vertices to define the texturing
skpFaceVtxIndices[ivtx] = skpVtxIndex;
SUGeometryInputAddVertex(skpGeomInput, &skpVtx);
SULoopInputAddVertexIndex(skpFaceLoop, skpVtxIndex);
skpVtxIndex++;
}
SUGeometryInputAddFace(skpGeomInput, &skpFaceLoop, &skpFaceIndex);
realNbFace++;
// if we have to convert the materials, we set its aspect
if(_convertMaterials)
createFaceTextureAndColor(sdmdb, iobj, iface, sdmMat, sdmMot, aspectFaceComplet, skpFaceIndex, skpFaceVtxIndices, nbVertex, &skpGeomInput);
}
SUEntitiesFill(container, skpGeomInput, false);
size_t nbFace = -1;
SUEntitiesGetNumFaces(container, &nbFace);
printf("nbFace : %d realNbFace : %d", nbFace, realNbFace);
SUGeometryInputRelease(&skpGeomInput);