Beziér Curve
Done with a task for my computer graphics course. A Beziér Curve.
Controlpoints are defined via mouse and can be freely moved around in space. This was not that big a deal, but still I’m quite proud of myself to have done this in about 2 hours while keeping the applications architecture clean and more or less simple.
The basic archtitecture relies on a singleton application class which handles objects and mouse events. Mostly utilizing glut functions for rendering and mouse input. Objects in the scene are also modelled as objects in C++ thus providing a quite intuitive approach to object manipulation. By exposing some of the applications methods to objects, the objects are also able to modify the applications behaviour (e.g. add objects, add mouse listeners etc). Mouse listeners and keyboard listeners are implemented – as you would suspect – using the observer pattern.
There still is one drawback though. It’s kind of slow. I’ll blame this on my Beziér calculations for now as they are not nearly as effective as I hoped them to be using de Casteljau’s algorithm. This might be of a result of me pushing calculated points into a vector and pulling them out too often. Although I won’t go into detail now, I had originally done this to save memory and would not have expected it to have such an impact on speed. This certainly has to be optimized. But for now it suits my needs.
Oh, almost forgot: this was done using opengl and c++ (and I mean c++, not “C and using a c++ compiler”).