Exporting Rhino models, and the normals are out of place ! Can anybody give me some suggestions?

Hi Rhino developers!
So, I am exporting a Rhino model into another file format, and the normals look way off.

Here’s how the model looks in Rhino (on top) and how it looks when exported (below) :

Please note, that I am getting the mesh vertices and normals by doing this:

for (int i = 0; i < currentONMesh->m_V.Count(); i++)
			// Vertex
			currentTreziMesh->Vertices[i] = Vector3d(-(currentONMesh->m_V[i].x), (currentONMesh->m_V[i].y), (currentONMesh->m_V[i].z));

			// Normal
			if (currentONMesh->m_N)
				currentTreziMesh->Normals[i] = Vector3d(-(currentONMesh->m_N[i].x), (currentONMesh->m_N[i].y), (currentONMesh->m_N[i].z));

Where, Vector3d is a container for 3 float values in the 3d viewer I am exporting for.

Note that I am reversing the x co-ordinate as the model was appearing flipped horizontally, and I also did that with the normal, just to be sure.

Could anybody with some idea about this explain to me what’s wrong here, and what can be fixed here?


I think that instead of doing the transform on mesh data you should do it on the camera instead.

Here is what I do for Cycles, where I need to flip on one axis too.

Where RhinoToCyclesCam is the matrix:

As you can see I have to flip on the Z-axis, so I scale that axis with -1.0. That way you don’t have to touch your geometry data with all the pain that comes from it.

1 Like

This looks interesting ! What would be the equivalent of RhinoToCyclesCam in C++ ?

Hi @nathanletwory, first of all, thank you so much for helping me out !

So, regarding modifying the camera data that you mentioned, I am not reading any camera data right now, as the SDK I am working with doesn’t have a special data field for a camera. I just get the objects, materials and that’s pretty much it.

So, when you say to get the camera, I am unsure regarding how will I do it, and whether it would be useful for me. Also, I am using C++ and the syntax looks that of C#, so, would that be applicable in C++ too?

As you see, I am not operating on cameras right now, and I only have the access to the objects and meshes only. I would like to modify the normals, the vertices only to get the desired result. Do you have anything on your mind regarding this, and would you please share it? I am currently clueless on how to approach this.

P.S : The software in which the Rhino model is being imported to is based on Unreal Engine, if that helps.

ON_Xform with the same values. Really just identity with z scaled to -1

I mean to say you apply the necessary transform matrix to the unreal camera.

Oh ok, I get it now. But, if I had no way to modify the unreal camera, would there be any way for me to just derive upon some logic and modify the normals directly.
But, if there is not, I’ll look into modifying the unreal camera. Thank you for the tip, @jesterKing, :slight_smile:

Scale the objects negatively on the z-axis with world origon as pivot point ( essentially mirror) using SDK functionality before exporting. That should keep your geometry intact

1 Like