New C API smoothed normals problem

windows10

#1

Looks like SUMeshHelperGetNormals does not return smoothed normals.
Is there a way to get smoothed normals, or equivalent to get_VertexNormal from deprecated API?


#2

Could any of you comment on this please?
I just want to know if I did something wrong or SUMeshHelperGetNormals returns faces normals instead of averaged vertices ones?


#3

What version of the SketchUp API are you using? Has the mesh just been added, or did you load it from a skp file?


#4

Ahead of GetNormals, have you called SUMeshHelperCreate() to initialize the geometry?


#5

SDK_Win_x64_18-0-18664 (newest)

Has the mesh just been added, or did you load it from a skp file?

Added from live SketchUp scene, but I tried also saving to file before exporting.
rend_test.skp (175.9 KB)

Ahead of GetNormals, have you called SUMeshHelperCreate() to initialize the geometry?

I tried both:
SUMeshHelperCreate
and
SUMeshHelperCreateWithTextureWriter

SketchUp 2017 PRO (17.2.2555 64-bit)

 info.has_single_loop_ = false;

// Create a mesh from face.
SUMeshHelperRef mesh_ref = SU_INVALID;

//SU_CALL(SUMeshHelperCreateWithTextureWriter(&mesh_ref, face, texture_writer_));
SUMeshHelperCreate(&mesh_ref, face);

// Get the vertices

size_t num_vertices = 0;
SU_CALL(SUMeshHelperGetNumVertices(mesh_ref, &num_vertices));
if (num_vertices == 0) return;

std::vector vertices(num_vertices);
SU_CALL(SUMeshHelperGetVertices(mesh_ref, num_vertices, &vertices[0], &num_vertices));

std::vector normals(num_vertices);
size_t num_normals = 0;
SU_CALL(SUMeshHelperGetNormals(mesh_ref, num_vertices, &normals[0], &num_normals));


#6

Are you using this in a standalone mode, or as live C library of a ruby extension? SketchUp 2017 would not utilized the smooth normal fixes in the 2018 API if you are connecting live to the model. Can you try with a copy of SU2018?


#7

I use it as live C library passing Sketchup.active_model.skpdoc(true) to c++ dll.

Can you try with a copy of SU2018?

I do not have PRO version of SU2018, and there is no more MAKE one to try…
I already used 1 month of 2018 trial.

SketchUp 2017 would not utilized the smooth normal fixes in the 2018 API if you are connecting live to the model.

Do you mean, I should try previous 2017 version of API, or wait for next API release with fix?


#8

I just try SDK_Win_x64_17-0-18899, on SketchUp 2017 PRO (17.2.2555 64-bit).
It is the same problem, previous (soon obsolete) C++ API works fine…

What do you suggest?


#9

There was a known bug in both version (make/pro) of SU2017, normals are cached and they are inaccessible (no way to force update them) from CAPI.

Try to test your plugin in SU 2018 PRO

For 2017 you may try to use Ruby API as a workaround.


#10

I tested on SU 2018 PRO there is the same problem.
Live scene does not export correctly, saved file works ok.

For 2017 you may try to use Ruby API as a workaround.

Do you know how to convert C API mesh_ref (SUMeshHelperRef) to Ruby API object?