Skip to content

ModelMesh

Chuck Walbourn edited this page Sep 26, 2021 · 12 revisions

This class is part of the Model hierarchy. The primary purpose of this class is to be a shared container for a list of ModelMeshPart instances which are referenced by one or more instances of the Model class.

Note that Model uses a collection of std::shared_ptr instances to ModelMesh since meshes can be shared by multiple instances of Model.

Header

#include <Model.h>

Initialization

ModelMesh instances are typically created by a Model loader along with the ModelMeshPart instances that make up the mesh.

Type alias

ModelMesh::Collection is an alias for std::vector<std::shared_ptr<ModelMesh>>.

Simple drawing

Use the Model::Draw template function which will call ModelMesh::DrawOpaque and ModelMesh::DrawAlpha on all the meshes it contains. See Model for an example.

Advanced drawing

The Model class provides a DrawOpaque and DrawAlpha template function which should be used to invoke the ModelMesh::DrawOpaque and ModelMesh::DrawAlpha methods, but you can also choose to invoke them directly.

You can directly submit the geometry using the following methods, which assumes you have set up the required render state:

void DrawOpaque(ID3D12GraphicsCommandList* commandList) const;
void DrawAlpha(ID3D12GraphicsCommandList* commandList) const;

You can use the following methods to submit the geometry using a specific effect. This effect must have the proper state to match your geometry, but can be used for "material override" rendering such as doing a shadow pass:

void DrawOpaque(ID3D12GraphicsCommandList* commandList, IEffect* effect) const;
void DrawAlpha(ID3D12GraphicsCommandList* commandList, IEffect* effect) const;

You can also use the following methods to get a call-back for setting up the proper state for each ModelMeshPart:

void DrawOpaque(ID3D12GraphicsCommandList* commandList,
    ModelMeshPart::DrawCallback callback) const;
void DrawAlpha(ID3D12GraphicsCommandList* commandList,
    ModelMeshPart::DrawCallback callback) const;

You can also manage you rendering by drawing individual submeshes. See ModelMeshPart for more information.

Metadata

In addition to the list of ModelMeshPart instances that make up the mesh, a ModelMesh also includes a name (a wide-character string) for tracking and application logic.

A ModelMesh also includes bounding information for culling & collision detection in the form of a BoundingSphere and a BoundingBox.

The choice of frame-of-reference for these bounding volumes is up to the Model loader, but is typically in 'local' coordinates.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Xbox One
  • Xbox Series X|S

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectXMesh

DirectXTex

DirectXMath

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally