Sunday 21 July 2013

Submesh breakdown


Because I had a couple of minutes, I rewrote the LDR importer to divide the mesh into discrete submesh components and now post processs each component for normals and smoothing before recombining them.
Sections with a shared triangle edge are treated as the same submesh, and I just walk all of the triangles edges to build each one.

Here is a composition of the AirTanks(3838) and Hips(3815) meshes with each submesh colourised. There are a couple of tears in the mesh which I have yet to get to the bottom of but in general it proves the concept and demonstrates the process is probably sound.



To achieve this I created a new MeshToolApp. My Application base class looks like this
class Application
{
public: virtual int Execute()=0;

public: Application() {}
public: virtual ~Application() {}
};

So the main method looks something like this:

int main( int argc, char ** argv )
{
Application * MyApp = new MeshToolApplication();

int Result = 0;
if ( MyApp )
{
Result = MyApp->Execute();
}
return Result;
}

There is a little more to it in practice as I first parse the command line parameters to determine which application to execute, and there is some other init/cleanup, but this demonstrates the pattern very well.

The mesh tool app instantiates the same engine, renderer and input code as the main application but supplies an orbiting camera so I ca spin around the model to view it. It has simple import/load at the moment - once I'm happy enough with the post process I'll add a GUI to load, convert, view and save meshes. The last step will be creating a MeshConvertApplication that scans the content folder for LDR meshes and serializes out a converted mesh as an automated process.  It might render a screen capture of each mesh and save a bitmap for each one too.






No comments:

Post a Comment