Engine

Asset Loaders

Specific documentation for MeshLoader, MaterialLoader, and TextureLoader.

Introduction

Nevo Engine uses specialized loader classes to handle the complexities of different file formats and to coordinate between the file system, the ResourceManager, and the GPU.

MeshLoader

The MeshLoader is responsible for loading 3D geometry from disk.

  • Supported Formats: OBJ (.obj) and GLTF/GLB (.glb, .gltf).
  • Process:
    1. Loads the file using FileLoaderOBJ or FileLoaderGLTF.
    2. Populates an IntermediateMesh (a platform-independent data structure).
    3. Registers the mesh with the ResourceManager, which involves creating GPU buffers (VAO, VBO, EBO) via the GraphicsFactory.

MaterialLoader

The MaterialLoader parses material definitions, which are typically stored as JSON files.

  • Format: JSON files in the materials/ directory.
  • Responsibilities:
    1. Parses material properties (e.g., color, castShadows).
    2. Identifies required shaders and, optionally, textures.
    3. Uses ShaderLoader and TextureLoader to load any missing dependencies.
    4. Registers the completed Material with the ResourceManager.

Material textures are optional. If no texture is specified, the shader uses the material color directly. If a texture is present, it is multiplied by the material color.

TextureLoader

The TextureLoader handles loading image files and uploading them to the GPU.

  • Supported Formats: PNG (via lodepng).
  • Process:
    1. Reads image data using AssetLoader.
    2. Decodes the image data.
    3. Creates a GraphicsTexture on the GPU.
    4. Registers the Texture metadata and GPU resource with the ResourceManager.

SceneLoader

The SceneLoader (often used by the ComponentFactory) loads entire entity hierarchies and their components from JSON scene files. It coordinates the creation of entities and the addition of components by calling other specialized loaders as needed.