HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Writing GEO_IOTranslators

Overview

You can also write a DSO that directly builds a GU_Detail from your file format. The advantage of writing a translator, rather than patching the GEOio.json file, is that no intermediate copy needs to be made in memory. The GEOio.json file approach requires Houdini to then parse the .bgeo file you create. Using an GEO_IOTranslator, there is no intermediate representation.

These translators will be invoked whenever any GU_Detail is loaded or saved from disk.

Registration Process

To register you use the newGeometryIO DLL hook. No parameters are required since, inside that hook, you will just invoke GU_Detail::registerIOTranslator.

The GU_Detail::registerIOTranslator takes a pointer to an allocated subclass of GEO_IOTranslator. This object needs to be persistent as the internal table just holds on to the pointer you give it.

By overriding the fileSave and fileLoad methods and directly manipulating the GEO_Detail provided you can write your converter. Note you may need to upcast to a GU_Detail *, which is a safe operation.

The GEO_IOTranslator::checkExtension method is used to determine if your translator should be invoked. Usually, it will be based on the extension, but note that you are not in any way limited.

GEO_IOTranslator::checkMagicNumber is not currently used.

The UT_IStream you will get will be in binary mode. If you want to use the ascii parsing functions, you will need to use UT_IStreamAutoBinary to convert the stream for the extent of your function.

Examples

The volume import/export example shows how to register a translator to support the ".voxel" format.

See GEO/GEO_VoxelTranslator.C for the code.