Game Development Reference
In-Depth Information
bool convert(const char* pSrcFilename, const char* pDestPath, const Args& rArgs);
const char* supportedExtensions() const
{
return "*.jpg *.png *.psd *.tex";
}
EType type() const
{
return eType_ImporterCompiler;
}
};
As you can see, the texture converter plug-in class will return all supported file extensions and their types, so the
main compiler class will select it when appropriate.
Inside the convert method, the code will check the input filename and dispatch the logic to the specific image
format handler.
This class can reside in a DLL, and you can have a single converter per DLL, but you can also have as many
converter classes in a DLL as you want. In that case, the query function will just have to change to support multiple
classes. See Listing 1-5.
Listing 1-5. A Plug-in with Multiple Converter Classes Inside a Single DLL
// this class must be implemented by the plug-ins
class AssetCompilerPlugin
{
virtual int getClassCount() = 0;
virtual AssetConverter* newClassInstance(int aIndex) = 0;
}
DLL_EXPORT AssetCompilerPlugin* createPluginInstance();
The exported createPluginInstance() will create the plug-in's class instance, which will take care of
instantiating converter classes.
Other converter plug-in examples include an FBX converter, mesh compiler, prefab compiler, shader compiler,
MP3/OGG/WAV converter, level compiler, etc. The plug-in system can be developed further with class descriptors, so
you can have information about the converter classes without having to instantiate them unless they are needed.
Conclusion
Making the asset compiler modularized can yield huge benefits: shorter development time, the ability to extend and
debug the tool, and happy third party developers who will use the tools since they can implement new converters/
compilers for their custom data file formats.
Keep in mind optimizations like multithreading; dependency trees; CUDA/GPGPU operations to speed things; a
CRC-based last-modified file info database so you can skip assets that haven't changed; and even safely running many
compiler executables on the same data folders.
The solution can be implemented in various ways. The converter ecosystem can be detailed as needed so it will
fit perfectly into the game engine's pipeline.
 
Search WWH ::




Custom Search