blShapeSuperEllipsoid — Construct and render super ellipsoid shapes and height maps in opengl

Introduction

How can a shape API be taken seriously if it doesn’t provide an easy way to generate super quadrics and super quadrics height maps. So as part of my blShapeAPI series, in this article, I introduce a very simple but powerful class that can generate super ellipsoids and super ellipsoid height maps dynamically.

As an example, the following snippet, which uses sfml for the windowing part and the blImageAPI for the webcam part, generates two super ellipsoids, and one third super ellipsoid height map, where the height values are coming from a webcam feed.

Snippet (Click to see code…)

The resulting output is the following:


Dependencies

This class is derived from the blShapeQuadric class.

The Code

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

blShapeSuperEllipsoid.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]

Updates

  1. 11/27/2010 — Updated the CalculateVertex function so that it is much clearer.
  2. 11/27/2010 — Updated the GenerateVertex function for generating height maps, as before I was not generating the correct number of vertices.

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"

One Comment

  1. Pingback: blShapeSuperToroid — Construct and render super toroid shapes and height maps in opengl | BarbatoLabs

Leave a Reply

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