Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Generalized Geometry Handling

Posted by , 21 September 2012 · 1,243 views

Over the past few commits to the Hieroglyph 3 repository, I have been building up some generalized geometry classes in an effort to make working with customized pipeline input forms easier. This has resulting in a few classes that specialize the PipelineExecutorDX11 class, which is responsible for configuring the Input Assembler and then performing an appropriate draw call that will use that IA setup. These subclasses include ImmediateGeometryDX11, IndexedImmediateGeometryDX11, and InstancedQuadGeometryDX11.

The basic usage paradigm is to add a 'vertex' to the class, which then gets automatically loaded into a vertex buffer later on. In reality, the vertices are added to a system memory buffer first, and then the contents of the buffer are uploaded later on. Overall, this makes it pretty easy to draw any number of shapes via algorithmic drawing. ImmediateGeometryDX11 uses simple vertex buffers, and executes the pipeline with an ID3D11DeviceContext::Draw call. IndexedImmediateGeometryDX11 adds the same ability, but also includes the use of indices (and of course an indexed draw call). Finally the Instanced variant uses two vertex buffers (one for per-vertex data, one for per-instance data) and an index buffer.

The advantage to these types of methods are that you don't have to plan ahead as much - you don't need to worry about how big of an array you need, or anything like that. It is much simpler to just throw down some code and get the geometry up on the screen.

These various classes let me build up a few routines for drawing different basic shapes, as seen in the following images:

Attached Image
Attached Image

After building some methods for drawing these basic shapes (cylinders, cones, and spheres), I could build higher level constructs like arrows, axis markes, or even larger structures such as these images from a work project:

Attached Image
Attached Image
Attached Image

Overall I am quite happy with the results so far, and I will be adding more shapes in the coming few commits. The trend toward simplified usage geometry will continue for certain!

October 2016 »

2324252627 28 29