3D I/O files principles
C3DIo is the class for reading a 3D file and obtain a C3DScene, or writing a C3DScene to a file.
A specific file format is recognized using the file extension, and the appropriate C3DParser is then called to read or write the file.
*
Reading a 3D file and get the scene
Reading a file is quite simple.
C3DIo file(filename, FILE_PARSER_LOADING);
if (!scene)
{
file.ReportIoError();
return;
}
C3DIo class handles reading / writing / updating 3D file.
Definition Io3dmgr.h:233
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
You can provide some specific options using CSceneImportOptions. For example, you might need to define an FBX file.
C3DIo file(filename, FILE_PARSER_LOADING);
if (!scene)
{
file.ReportIoError();
return;
}
#define FBX_IO_OPTION_PASSWORD
CXString: String that contains a password to read/write the fbx.
Definition Io3dmgr.h:26
This class is used to provide some specific options when loading scene file.
Definition Io3dmgr.h:133
Writing a scene to a file
Writing a C3DScene to a file is also easy. Here is a sample that use some specific options to export the scene.
C3DIo file(filename, FILE_PARSER_SAVING);
if (!file.Save(scene, &options))
{
file.ReportIoError(
error);
}
@ SCENE_EXPORT_REMOVE_CURVE
Remove curves.
Definition 3DType.h:244
@ SCENE_EXPORT_MAKE_UNIQUE_NAME
Generate unique name for materials and nodes.
Definition 3DType.h:260
@ SCENE_EXPORT_CONVERT_PATCH
Convert patch to polygonal mesh.
Definition 3DType.h:258
@ SCENE_EXPORT_TRIANGULATE
Triangulate objects.
Definition 3DType.h:254
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
This class is used to provide some specific options when exporting a 3D scene.
Definition Io3dmgr.h:157
longuint flags
Definition Io3dmgr.h:173
Retrieve the list of registered extensions
By default the SDK integrates a lot of parsers for different format.
This can be useful for displaying a dialog box for example.
The following code retrieve the 3D extensions that are recognized for reading.
{
unsigned int i=0,
j, size;
filter.Empty();
unsigned int count;
{
size = fileGetExtensionArray(fileinfo->GetClass(),
extArray);
XASSERT(size);
{
{
}
}
filter += fileinfo->GetDescription();
}
{
filter +=
_T(
"All recognized files");
filter += "|";
filter += "||";
}
return filter;
}
CFileExt is the class that allows to add a custom file parser for supporting a new file format....
Definition FileInfo.h:182
CXStringArray implement an array of CXString.
Definition XStringArray.h:25
C3DParser information
C3DParser usually defines some default flags and some needed flags for reading in the C3DParser::LoadDefaultOptions implementation. C3DParser::SaveDefaultOptions defines some default flags and some needed flags for writing.
For example if the parser export only triangles, it will set C3DParser::neededflags |= SCENE_EXPORT_TRIANGULATE which will make the scene being triangulated before the export.