Correct geometry but incorrect colors after following CAD viewer example

I am a bit confused with something. I followed the CAD viewer example as closely as possible, and currently it seems the colors we are reading do not match the CAD file.

It seems we are somehow permuting the colors of the nodes. However, this is the snippet oh where we load our data:

NodeGeometry getNodeGeometry(A3DTree* const hnd_tree, A3DTreeNode* const hnd_node) {
	NodeGeometry geometry;

	// Extract the geometry as an A3DMeshData and collect their position and color to render it
    A3DMeshData mesh_data;
    A3D_INITIALIZE_DATA(A3DMeshData, mesh_data);
    A3DStatus code = A3DTreeNodeGetGeometry(hnd_tree, hnd_node, A3D_TRUE, &mesh_data, 0);

    if (code == A3D_SUCCESS) {
        Mat4 position = he_extract_position(hnd_node);
		Vec4 color = he_extract_color(hnd_node);

		geometry.color = color;
		geometry.transformation = position;
             /*more stuff*/
    }
   return geometry;
}

We are clearly loading the position/transformation at the exact same time as the color and we are completely certain we are not ever over writing the color. So we don’t understand how one can be right and the other wrong. They should both either be correct or incorrect.

This is our full code atm:
ForesightLoader.cpp (20.9 KB)

Which we based off of the CAD viewer example.

And we got the input file from autodesk, we used the second example titled rac_basic_sample_project.rvt

I have asked a colleague to look at the code and he also seemed confused as it seems we are doing what the tutorial says to do. We are hoping you can give us some pointers as to what is happening.

I can only post a few media per comment, so here are the images;

Our rendering:

Autodesk viewer:

Additionally, the autodesk viewer shows an IfcGUID , I am trying to find which HOOPS identifier corresponds to it.

It doesn’t seem to be rbd.m_pcPersistentId from A3DRootBaseData. Any suggestions as to which field might have that IFC id?

Hello @camilo.talero
By checking the Revit file, the color information is stored in A3DTessFaceData::m_puiStyleIndexes. You can refer to the example MeshViewer, and look at the function RepresentationItem::build_buffer_per_style.
As for IfcGUID, they are stored as attribute.

Best Regards,
Man

@Man Hey,

Sorry but I am not sure what you mean by your response.

The HE example that uses the key-words “Mesh Viewer” (afaik) is this
https://docs.techsoft3d.com/exchange/latest/tutorials/c/mesh-viewer-sample.html

An its source code is here on on github: techsoft3d/he_basic_viewer/.

There is no RepresentationItem class, nor build_buffer_per_style as per GH’s search function on that project.

So either I am not looking at the right repo, in which case, please point me to the right place.

Or alternatively, you might be talking about the function he_extract_color which is exactly what we did on our end.

There is nothing in the documentation under the function name build_buffer_per_style:

Hello @camilo.talero,
The sample I mentioned comes with the package “…\samples\exchange\exchangesource\MeshViewer” and the function name mentioned is in “…\MeshViewer\model\he\representation_item.cpp”.

Please let me know if this sample helps you solve the problem. Thank you.

Best Regards,
Man

Hello Man,

This has been extremely helpful, thank you for the help you have given us so far. I have looked at build_buffer_per_style and I have a much better idea of the intended way of getting color information.

1 Like