libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
donut::graphics::Model Struct Reference

Container for a set of 3D triangle meshes stored on the GPU, combined with associated materials. More...

#include <donut/graphics/Model.hpp>

Classes

struct  Object
 A single 3D mesh with an associated material. More...
 

Public Member Functions

 Model (std::vector< Object > objects) noexcept
 Construct a model from a list of meshes. More...
 
 Model (const Filesystem &filesystem, const char *filepath)
 Load a model from a virtual file. More...
 

Public Attributes

std::vector< Objectobjects
 List of objects defined by the loaded model. More...
 

Static Public Attributes

static const Model *const QUAD
 Pointer to the statically allocated storage for the built-in quad model. More...
 
static const Model *const CUBE
 Pointer to the statically allocated storage for the built-in cube model. More...
 

Detailed Description

Container for a set of 3D triangle meshes stored on the GPU, combined with associated materials.

Examples
example_game.cpp.

Constructor & Destructor Documentation

◆ Model() [1/2]

donut::graphics::Model::Model ( std::vector< Object objects)
inlineexplicitnoexcept

Construct a model from a list of meshes.

Parameters
objectsmeshes that define the model.

◆ Model() [2/2]

donut::graphics::Model::Model ( const Filesystem filesystem,
const char *  filepath 
)

Load a model from a virtual file.

The supported file formats are:

  • Wavefront OBJ (.obj)
Parameters
filesystemvirtual filepath to load the files from.
filepathvirtual filepath of the model file to load.
Exceptions
File::Erroron failure to open the file.
graphics::Erroron failure to load a model from the file.
std::bad_allocon allocation failure.
Note
The file format is determined entirely from the file contents; the filename extension is not taken into account.
Any material libraries and texture image files required by the model are also loaded as needed. See the documentation of Image for a description of the supported image file formats.

Member Data Documentation

◆ QUAD

const Model* const donut::graphics::Model::QUAD
static

Pointer to the statically allocated storage for the built-in quad model.

Warning
This pointer must not be dereferenced in application code. It is not guaranteed that the underlying model will be present at all times.
Examples
example_game.cpp.

◆ CUBE

const Model* const donut::graphics::Model::CUBE
static

Pointer to the statically allocated storage for the built-in cube model.

Warning
This pointer must not be dereferenced in application code. It is not guaranteed that the underlying model will be present at all times.
Examples
example_game.cpp.

◆ objects

std::vector<Object> donut::graphics::Model::objects

List of objects defined by the loaded model.


The documentation for this struct was generated from the following file: