blShapeSuperToroid — Construct and render super toroid shapes and height maps in opengl

Introduction

To continue with the super quadrics theme, this article presents a simple class to construct and render super toroids shapes and height maps.

As an example, the following snippet, which uses sfml for the windowing part and the blImageAPI for the webcam part, generates two super toroids, and shows them like two rings, one inside the other. One of the rings is used as a dynamic height map, where the vertex heights are read from the webcam video feed.

Snippet (Click to see code…)

The resulting output is the following:


Dependencies

This class is derived from the blShapeSuperEllipsoid class.

The Code

My code uses inline documentation and follows a clean structure, (at least to me). The blShapeSuperToroid class is saved in a file called blShapeSuperToroid.hpp as follows:

blShapeSuperToroid.hpp (Click to see code…)

Usage

There are literally too many potential applications for such a tool, too many to show in one post anyway, so in later posts, I will build applications built on superquadrics.

Downloads

I have put all the files into a zip file which can be downloaded here. All you have to do is extract it somewhere, let’s say in a directory called blShapeAPI, and then include the blShapeAPI.hpp file as follows:

#include "blShapeAPI/blShapeAPI.hpp"
using namespace blShapeAPI;

Note: The blShapeAPI depends on the blMathAPI and thus you’ll need both APIs:
[download#2] [download#5]

About Vincenzo Barbato

Known to his friends as Enzo, he's an outside-the-box engineer/researcher whose interests and expertise span many fields, including controls systems, multi-physics simulations, mechatronics, oil technologies, data analysis and machine vision just to name a few.

Refusing to grow up, he's on a continuous journey to develop simple and creative solutions that have the power of disrupting industries by optimizing systems and processes.

Married to a beautiful wife, with two beautiful daughters and two identical twin boys, his home is a never ending chaotic fountain of inspiration.

His outlook on life:

"Never blindly accept what you're told, listen, but then question, with curiosity, creativity and collaboration we can change the world"

About Enzo

Known to his friends as Enzo, he's an outside-the-box engineer/researcher whose interests and expertise span many fields, including controls systems, multi-physics simulations, mechatronics, oil technologies, data analysis and machine vision just to name a few. Refusing to grow up, he's on a continuous journey to develop simple and creative solutions that have the power of disrupting industries by optimizing systems and processes. Married to a beautiful wife, with two beautiful daughters and two identical twin boys, his home is a never ending chaotic fountain of inspiration. His outlook on life: "Never blindly accept what you're told, listen, but then question, with curiosity, creativity and collaboration we can change the world"

Leave a Reply

Your email address will not be published. Required fields are marked *