3
Steps to make an extension being recognized by the SDK
- Implement a C3DParser (Read and / or Save and / or Update methods)
- Implement a function that will be called for creating / destroying the parser object
- Register the extension using fileRegisterFile
Please have a look at the 3DCustomFormat in the SDK samples.
Make the scene being prepared after import or before export
C3DParser usually defines some needed flags for reading in the C3DParser::LoadDefaultOptions implementation.
C3DParser::SaveDefaultOptions defines some needed flags for writing.
This method are optional. In this case default import / export processing occurs.
Here are some example of implementation:
{
options.targetunit = UNIT_M;
}
{
options.swapmode = SWAP_YZ;
}
@ SCENE_IMPORT_CLEAN_GROUPS
Deletes any group which has no childs.
Definition 3DType.h:301
@ SCENE_IMPORT_CONCATENATE
Concatenates all mesh to a single one.
Definition 3DType.h:298
@ SCENE_EXPORT_CONVERT_TO_STANDARD_MATERIALS
Convert any materials to standard ones.
Definition 3DType.h:274
@ SCENE_EXPORT_GLOBAL_COORDINATES
The scene is exported with global coordinates.
Definition 3DType.h:263
@ SCENE_EXPORT_TRIANGULATE
Triangulate objects.
Definition 3DType.h:254
This class is used to provide some specific options when exporting a 3D scene.
Definition Io3dmgr.h:157
longuint neededflags
Fill by the parser. A combination of SCENE_EXPORT_FLAGS that are absolutely required.
Definition Io3dmgr.h:179
This class is used to provide some specific options when loading scene file.
Definition Io3dmgr.h:133
Implement Read or Save method
Implementation depends on your files. If the process fails, properly inform the C3DIo about what occurs.
Here are some example of read / write process, using the C3DScene::Serialize mechanism.
#define CUSTOM_3D_STRING MAKE_CUSTOM_ID('C', 'S', 'S', 'T')
#define CUSTOM_3D_INT MAKE_CUSTOM_ID('C', 'S', 'I', 'T')
{
IoFile file(IsSilentMode(), IOFILE_MEMORY_FILE);
if (!file.OpenFile(filename, true))
{
io->SetIoError(IO_FILE_CANT_OPEN_FILE, &options, IoLogInfo::LOG_ERROR);
file.CloseFile();
}
unsigned int value;
file.CloseFile();
return ioscene;
}
{
if (!
iofile.OpenFile(filename,
false))
{
io->SetIoError(IO_FILE_CANT_OPEN_FILE, &options, IoLogInfo::LOG_ERROR);
return false;
}
return true;
}
CXTString< TCHAR > CXString
CXString depend on the target OS. Could be CXStringW (Windows) or CXStringA (Linux / Macos)
Definition XString.h:118
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
IoFile is a class for reading binary or ascii file using internally a CStdioFileEx.
Definition IoFile.h:45
Implement a function to initialize / destroy the parser on request
When C3DIo recognized your format extension, it will ask you to create your C3DParser object and once finished to destroy it.
bool Init3DParser(IoPluginMode mode, void *data)
{
switch (mode)
{
case IO_INIT_PLUGIN:
{
}
case IO_GET_PARSER:
{
{
break;
}
break;
}
}
}
Register your parser and extension
You have to inform the SDK that a new extension is recognized. You have to give your extension a file class and give some information about what the parser does.
ext.description = "My custom 3D files";
ext.ext = ".mesh1|.mesh2";
ext.
fileclass = MAKE_CUSTOM_ID(
'C',
'S',
'T',
'M');
ext.
properties = IMPORT_FILE | EXPORT_FILE | OBJECT_FILE | COMMON_EXTENSION_FILE | LOAD_HAS_DIALOG;
ext.
saver = CALLBACK_PARSER;
fileRegisterFile(ext);
CFileExt is the class that allows to add a custom file parser for supporting a new file format....
Definition FileInfo.h:182
unsigned int fileclass
A tag created with MAKE_CUSTOM_ID.
Definition FileInfo.h:186
InitIOPluginFunc iocallback
The function which allows to create parser.
Definition FileInfo.h:194
unsigned int properties
Definition FileInfo.h:187
unsigned int saver
Inform about the file saver: MOOTOOLS_PARSER, PLUGIN_PARSER, CALLBACK_PARSER or something else (ie....
Definition FileInfo.h:193
unsigned int loader
Definition FileInfo.h:192