Hello,
We use SketchUp SDK in our cross-platform app for a couple of years already. In our app user can import different 3D formats, including .skp, then we show 3D scene in OpenGL window, allow to rotate it, change materials’ colors save as 2D image.
Some people complain that they see the scene very different from what it looks like in SketchUp app. So, what happens is that we can’t handle object visibility and layer colors correctly. Like, in this casa.skp file:
Car and building.zip (2.7 MB)
there are several layers, they have colors and different visibilities.
When we read this file using similar approach demonstrated in skp2xml project example, calling inheritance_manager_.GetCurrentLayer(); on the lowest level for each face, for most of them we get Layer0. But if you open the scene in SketchUp app it’s clear that they don’t belong to that layer (hiding/showing Layer0 does not affect building walls, for example). So we get wrong visibility and layer color in our app. What do we do wrong? Even if we just call
SUDrawingElementRef drawingEl = SUFaceToDrawingElement(face);
SULayerRef layer = SU_INVALID;
SUDrawingElementGetLayer(drawingEl, &layer);
we get the wrong layer for the walls. It returns Layer0, not even Invalid or 0 value. So, even if the parent objects (groups, instances) have correct layer, we have to ignore them and use the wrong one, returned by each face, since it’s not zero or invalid).
Second question is, when user select “color by layer” and saves the file, when we read it in our app, how can we know that this mode is on?
Also, we tried some tricks - convert .skp to .fbx before opening it, because we handle .fbx much better. First, we couldn’t access the SketchUpModelExporterInterface that easily from skp2fbx.dll internal SketchUp exporter plugin. Then we found that we have to use certain version of Visual Studio and compiler flags, because std::string objects don’t parse correctly. Not clear why ConvertFromSkp from SketchUpModelExporterInterface is made with std string arguments that cause VS version limitations instead of just parsing const char * that can be UTF8. But, anyways, after files are converted to fbx, they also often look different from what they look like in SketchUp app. Even if it’s converted in SketchUp app, faces get wrong materials. Like this attached model car.skp looks wrong after conversion.
So, we had to leave that idea.
And the last question about SUFaceRef and SUMeshHelperCreate.
Is there a way to get normal per vertex from SUFaceRef without using SUMeshHelperCreate ? I mean not just a normal to face, but per vertex that allow to make soft edges. Right now we have to create SUMeshHelperCreate and call SUMeshHelperGetNormals in order to do that. Also, after we create the mesh helper, where is it stored? Does it become attached to the face object somehow? Can we reuse it, like getting it instead of faces if we reread same model? Or is there any global function that would triangulate the whole model before we access each face?
Thank you for your help. It’s very important to us.