Creating your own heightmap and weightmap formats for importing landscape data is accomplished by writing a plugin. The plugin will add your new format to the engine, as well as importing the data from your files.
Writing A Custom Importer
-
In order to create new importers, your plugin should create instances of objects implementing
ILandscapeHeightmapFileFormat
andILandscapeWeightmapFileFormat
, and register those objects withILandscapeEditorModulemodule::RegisterHeightmapFileFormat
andILandscapeEditorModulemodule::RegisterWeightmapFileFormat
, respectively. - Implementing the
ILandscapeHeightmapFileFormat
interface in a plugin requires overriding the following functions:const FLandscapeFileTypeInfo& GetInfo() const
: Returns type information indicating which file types this class handles, and whether or not exporting is supported.FLandscapeHeightmapInfo Validate(const TCHAR* HeightmapFilename) const
- Validates the named file, or rejects it and returns an error code and message.FLandscapeHeightmapImportData Import(const TCHAR* HeightmapFilename, FLandscapeFileResolution ExpectedResolution) const
- Actually imports the file.void Export(const TCHAR* HeightmapFilename, TArrayView<const uint16> Data, FLandscapeFileResolution DataResolution, FVector Scale) const
- Exports the file, if this format supports exporting (see the return value fromGetInfo
). This is the only function that doesn't need to be overridden in order to compile. However, if it is called without being overridden, it will callcheck
.(Destructor)
- Classes that implement this interface should use a virtual destructor, as they will be deleted via a pointer to the interface class.
- Implementing the
ILandscapeWeightmapFileFormat
interface is nearly identical, with only minor differences in some return types:const FLandscapeFileTypeInfo& GetInfo() const
- Returns type information indicating which file types this class handles, and whether or not exporting is supported.FLandscapeWeightmapInfo Validate(const TCHAR* WeightmapFilename) const
- Validates the named file, or rejects it and returns an error code and message.FLandscapeWeightmapImportData Import(const TCHAR* WeightmapFilename, FLandscapeFileResolution ExpectedResolution) const
- Actually imports the file.void Export(const TCHAR* WeightmapFilename, TArrayView<const uint16> Data, FLandscapeFileResolution DataResolution, FVector Scale) const
- Exports the file, if this format supports exporting (see the return value fromGetInfo
). This is the only function that doesn't need to be overridden in order to compile. However, if it is called without being overridden, it will callcheck
.(Destructor)
- Classes that implement this interface should use a virtual destructor, as they will be deleted via a pointer to the interface class.
- For further information and examples, you can see the interfaces in
LandscapeFileFormatInterfaces.h
, the .PNG implementations inLandscapeFileFormatPng.cpp
andLandscapeFileFormatPng.h
, and the .RAW implementations inLandscapeFileFormatRaw.cpp
andLandscapeFileFormatRaw.h
. All of this code is in the LandscapeEditor module in the engine.