Advice regarding combining geom::Sourcemods and ci::TriMesh

Hey Embers,

Thanks to @lithium, I made progress in my quest to combine a geom::source with a ci::TriMesh. Unfortunately, all isn’t well. The following image shows my two constructions, a geom::source derived from an extrude() operation on top, and a ci::TriMesh constructed from similar vertices below:

Rendering them separately works a treat. However, as soon as I use the & operator to combine the two, the mesh is nowhere to be seen. I have a hunch as to what the issue is, but I could really use some wisdom to guide me a bit.

Below are two images of a much simpler extrude() result, along with a ci::TriMesh:


Rendered separately.


Joined and rendered in the same batch.

At least both meshes are still visible in this simple case, but they both now render as if neither has any normals. I think there’s a problem with the information attached to each vertex. I.e. the ci::Trimesh only knows of points when I build it using the following code:

void CinderProject2App::AddQuadToTriMesh( ci::TriMesh& mesh, ci::vec3 const& P0, ci::vec3 const& P1, ci::vec3 const& P2, ci::vec3 const& P3 )
{
	mesh.appendPosition( P0 );
	mesh.appendPosition( P1 );
	mesh.appendPosition( P2 );
	mesh.appendPosition( P3 );

	int vert0 = mesh.getNumVertices() - 4;
	int vert1 = mesh.getNumVertices() - 1;
	int vert2 = mesh.getNumVertices() - 2;
	int vert3 = mesh.getNumVertices() - 3;
	mesh.appendTriangle( vert0, vert1, vert3 );
	mesh.appendTriangle( vert3, vert1, vert2 );
}

… where as the extrude() result I imagine has more information attached, and when merging the two, things go sideways - hence why the extruded quad suddenly seems to lose its normals. I’d be much appreciative if anyone can confirm that this is likely the issue, and perhaps some pointers on what I need to keep an eye on when merging two things so it doesn’t go sideways?

Many thanks in advance,
Gazoo

I would writeObj() the combined mesh to a file and open it in a modelling package to see what’s going on. This way you can see if it’s a gl / rendering issue or a fundamental problem with your geometry itself, in a much more intuitive way than printf-ing vertices or looking through a debugger.

1 Like

It would appear that the exported .obj has no data exported at all :frowning:

If I export each component before appending them together, they’re fine and export/import just as expected. Once joined the exporter just writes out a 0 sized file.