Setting the vertex normal vectors

Hi all,

I searched for a while and browsed this forum but I can’t find a clear and definitive answer so… I decided to ask :wink:

I want to modify the converter from my firm format to Sketchup that uses the C API so that I can set the vertex normal vectors even maybe have different normal vectors for a vertex wether it is in a face or another…

The vertices and face are are created the following way:

SUGeometryInputRef skpGeomInput;
// we add all the object vertices to the geometry input
SUPoint3D * objectVtx = new SUPoint3D[object.nb_sommet];
getObjectVertices(sdmdb, iobj, object.nb_sommet, objectVtx);
SUGeometryInputSetVertices(skpGeomInput, object.nb_sommet, objectVtx);

and the faces are created a little further:

SUPoint3D * faceVtx = new SUPoint3D[nbVertex];
for(ivtx = 0; ivtx < nbVertex; ivtx++)
	int skpVtxIndex = face.ind_sommet[ivtx];
	skpFaceVtxIndices[ivtx] = skpVtxIndex;
	SULoopInputAddVertexIndex(skpFaceLoop, skpVtxIndex);
	faceVtx[ivtx] = objectVtx[skpVtxIndex];
if(computeArealNormalVectorLength(nbVertex, faceVtx) > EPS)
	// since at this point we are sure to create the face, we deal with the shading
	if((aspectFaceComplet.type_omb == GOURAUD)||(aspectFaceComplet.type_omb == PHONG))
		for(ivtx=0; ivtx < nbVertex; ivtx++)
			SULoopInputEdgeSetSmooth(skpFaceLoop, ivtx, true);
	SUGeometryInputAddFace(skpGeomInput, &skpFaceLoop, &skpFaceIndex);
	// if we have to convert the materials, we set its aspect
		createFaceTextureAndColor(sdmdb, iobj, iface, sdmMat, sdmMot, aspectFaceComplet, skpFaceIndex, skpFaceVtxIndices, nbVertex, &skpGeomInput);
delete [] faceVtx;

Is there a way to do that ?

Thanks for your help and have a good day :slight_smile:

SketchUp don’t store vertex normals. You could perhaps store them as attributes and modify your exporter to read those attributes on export, but they wouldn’t be recognized by SketchUp.

Oh thank you so much for this quick and clear answer! :slight_smile:

I’ll try to do as you say and store the normal vectors as attribute.

Thanks again and have a good day :slight_smile:

The vertex normals in SketchUp are implicit based on the smooth property of it’s connected edges.

If no connected edges are smooth the normals are the same as each faces connected. If there are smooth edges then the vertex normal between the faces connected is interpolated.

1 Like


And thank you so much for your answer :slight_smile: I had read such articles but I had not found the information about the normal vectors. But it seems logical :slight_smile: I saw with my boss and that is what we are going to code (no storing in some attribute for this time)

Thanks again, all, for your time and have a good day.

1 Like