Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Relevant

...

Files

  • EditorCommon/AssetSystem/AssetImporter.{h,cpp}
  • MeshImporter/AssetImporterFBX.{h,cpp}
  • MeshImporter/AssetImporterImages.{h,cpp}

See also: CAsset, CAssetType, CAssetBrowser

What

...

Is an

...

Asset Importer?

Users think about their data in terms of assets, such as meshes, skeletons, animations, and so on, which are handled as a logical unit inside the Sandbox. There's a one-to-one relationship between the assets seen in the asset browser and cryasset files on disk. These files, however, do not store the actual data used by the engine, but merely store a list of references to data files. An asset of type Mesh, for example, might reference a data file of type cgf that stores the actual geometry. The data file types are specific to CryENGINE (click here for an overview of these types). An asset created in some DCC tool needs to be converted to one of CRYENGINE's data file formats before it can be used in the engine.

The job of an asset importer is to take a source file of some type and create an asset, which includes creating the cryasset file, as well as the necessary data files. Asset importers might be called by the Sandbox in different places. One of them is certainly the asset browser, which allows importing of assets. There may be multiple asset importers that handle different combinations of source file types and asset types. For example, there is one asset importer that creates all asset types from FBX files. New importers can be implemented in plugins.

Implementing an

...

Asset Importer

In the following, we implement a simple asset importer (CMyMeshImporter) that imports source files of the fictional type mymesh and create Mesh assets.

...

Each of these methods is passed an import context that holds data of for importing process of a single source file. The path to the source file, and the path to the output directory, for example, can be queried from the context (6).

Implementation

...

Details of the FBX

...

Importer

The FBX importer (class CAssetImporterFBX) delegates the majority of the work to the Resource Compiler (RC). The RC is called as a separate process that takes some arguments and produces some output files. It writes the data files, as well as the cryasset files. Unfortunately, the RC is pretty much a black-box and a caller cannot tell in advance what files are going to be written, or how many. This stands in conflict with the requirements of the CAssetImporter interface, which asks the FBX importer for a list of potentially written asset files for a given pair of the source file and asset types.

...

FBX files might contain embedded media, including textures. In this case, texture importing is delegated to the image importer.

Implementation

...

Details of the

...

Image Importer

The image importer (class CAssetImporterImage) creates texture assets from image formats like png, jpg, or bmp. It first converts an image to TIF, and then invokes the RC to create a CryTif. After this, the CryTif is converted to dds, as usual.

...