microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++

Home Page:https://walbourn.github.io/directxtk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How I do get the bounds of a geometric priminitive?

WindowsNT opened this issue · comments

The model class has a list of meshes which have the bounding sphere and bounding box.
Would it be possible to do the same for the geometric priminitives?

Or, should I calculate them myself depending on the parameters passed to the constructors of the e.g. cube?

The assumption for most geo-prims is that you can just create a matching bounding volume from the same parameters.

If you need tighter bounds (like an oriented bounding box), you could use the custom geometry instructions in the wiki to create a bounding volume at runtime:

std::vector<VertexPositionNormalTexture> vertices;
std::vector<uint16_t> indices;
GeometricPrimitive::CreateBox( vertices, indices,
    XMFLOAT3(1.f/2.f, 2.f/2.f, 3.f/2.f) );

// Create bounding volume from vertices data

boxWithBounds = GeometricPrimitive::CreateCustom( deviceContext, vertices, indices ) );