When I write an element to skp file, the output with old COM looks more smoother than new 64bit C API.
Are there any functions could make the output more smooth?
Thanks,
Peter
When I write an element to skp file, the output with old COM looks more smoother than new 64bit C API.
Thanks,
Peter
Hard to say exactly what is going on without seeing the files themselves. (Is the top one from the old COM API and the bottom from the C API?)
The only thing I can speculate on from the screenshots is that the bottom one has hidden edges, while the top one has soft+smooth edges for the cylinders.
You might want to look into when and where you are applying these properties. Looks like the vertical edges in the columsn should be soft+smooth. But I wouldn’t apply it to everything. For instance in the top image the shading of the top of the column looks wrong to me - most likely because the edges for the top face is soft+smooth, whereas it’s probably best to keep these as hard edges.
Hi tt_su,
I attached the skp files for the two pictures. Please take a look for them.
How I get the related edges to set the smooth and hidden properties? Which API’s I could use?
SKP EXPORT-newApi.skp (271.2 KB)
SKP EXPORT-oldApi.skp (714.6 KB)
When generating geometry via the C API, use SUGeometryInputRef
To set the hidden/soft/smooth properties:
SUGeometryInputEdgeSetHidden
SUGeometryInputEdgeSetSoft
SUGeometryInputEdgeSetSmooth
In your oldAPI file soft+smooth+hidden is used:
(Setting Hidden isn’t needed when using Soft)
Hi tt_su,
I use the following code to add soft and smooth properties.
size_t vertexCount = index.size(), edgeIndex = 0; SULoopInputRef loop = SU_INVALID; SU_CALL(SULoopInputCreate (&loop)); for (size_t i = 0; i < vertexCount; ++i) { SU_CALL(SULoopInputAddVertexIndex(loop, index[i])); } // Add the face size_t face_index = 0; SU_CALL(SUGeometryInputAddFace(geom_input, &loop, &face_index)); for (size_t i = 0; i < vertexCount; ++i) { SUGeometryInputAddEdge (geom_input, index[i], index[(i+1)%vertexCount], &edgeIndex); SUGeometryInputEdgeSetSoft (geom_input, edgeIndex, true); SUGeometryInputEdgeSetSmooth (geom_input, edgeIndex, true); }
But the output is like the following.
That depend on the logic of your application. There is no universal rule for this.
Going by the screenshots I presume you want to smooth the edges between curved surfaces. In that case, you would take any edge that connects to two faces, check the normal of the faces and compare their angles - then smooth them if they are below a certain threshold.