HarmoniumUFO
A small interactive OpenGL program to explore spherical harmonics.
Special attention has been given to enable high resolution export
so that artists may print the spherical harmonic on 3D printers.
Exports OBJ and PLY formats.
Copyright (c) Nicholas Shea 2010-2014
nicholasshea_AT_tutanota_DOT_com
http://myweb.tiscali.co.uk/oaktree/butterfly/index.html
http://myweb.tiscali.co.uk/oaktree/harmonium/index.html
I have no mathematical qualifications and Harmonium was written in
my spare time as a mathematical recreation, both to explore
spherical harmonics and to try and understand them a little better.
-------------------------------------------------------------------------
BUILD
This is a 32 bit development version; some features are disabled.
The program has been tested on Windows XP 32 bit and Windows 7 64 bit.
MOUSE
Right mouse button: drag to zoom in and out.
Middle mouse button: drag to translate.
Left mouse button: drag to tumble; click to stop tumble.
Left and Right mouse buttons together: resets the view.
EXPORT and VIEW MENU OPTIONS
The OBJ file is exported using the current drawing attributes.
Thus, if smooth shading is on (in the View menu), then the OBJ file
exports with weighted vertex normals. Parameters are saved as comments.
Vertex colours, (which depict changes in amplitude), can only be
exported using PLY format at present. Exporting the quad wireframe is
not yet implemented.
POSSIBLE FAQ
Q. "Why does a split sometimes appear at the poles of the model?"
A. "Pm(x), or Legendre's Coefficient, is a function of x and contains
no higher powers of x than x^m where m = Cos(theta), with theta
measured from the zenith. Cos(0)=1 and cos(-180)=-1. Increasing the
resolution of the mesh to 'High' or 'Super'..." will close the gap
at the poles.
Q. "What direction is the winding in the exported OBJ file?"
A. "The default winding is counter-clockwise with outward pointing normals...
But Harmonium can render and export with either counter-clockwise or
clockwise winding. I decided to implement this feature because some 3D
programs require clockwise winding and inward pointing normals, but do
not provide an import option to re-orientate the data set.
Explanation
Facet elements use surface normals to indicate their orientation.
If vertices are ordered counter-clockwise around the face, both the face
and the normal point TOWARD the viewer; but if the vertex ordering is
clockwise, the face and the normal point AWAY from the viewer.
If, after importing the OBJ file into your 3D program, the model looks
strange, transparent or back-to-front, re-export the OBJ from Harmonium,
but this time ensure that 'Clockwise winding' is checked in the View menu.
(Leave the option 'Flip model normals' un-checked).
'Clockwise winding' builds the model with clockwise orderded vertices and
inward pointing normals, which are only visible when you zoom inside the
sphere. The OBJ file should then import correctly; if it does not, try
again with 'Flip model normals' checked.
When 'Flip model normals' is checked, model normals always point in the
OPPOSOTE direction given by the winding. This changes OpenGL's lighting
calculation so this option is best left unchecked, except for special
export reasons. The default launch state leaves all these items unchecked.
The menu option 'Draw model normals' displays model normals as BLUE lines,
drawn at a fraction of their actual length.
You can always see which direction model normals should be pointing by
checking 'Draw Winding Normals' which renders winding normals as RED lines.
To test this, check the following View menu options: 'Flip model normals',
'Draw model normals' and 'Draw Winding Normals'. You will see that model
normals point in the opposite direction to winding normals. Thus one set
of normals appears inside the sphere, and the other outside. (Zoom into
the sphere by dragging with the right mouse button).
Generally, model normals should always be coincident with winding normals,
in which case the model normals (blue) obscure the winding normals (red).
Of course, the winding normals are not part of the model data, they are
simply provided as a rendering hint, if you run into export problems.
CREDITS
Built using mingw toolchain and FLTK user interface toolkit. Links to
a modified version of WildMagic5p13 mathematics. Uses Boost legendre_function.h
amd special_function_util.h
---------------------------------------------------------------------------------------------------------
Version Date Notes
---------------------------------------------------------------------------------------------------------
Harmonium-0-0-3 23 Aug 2014 - First upload
Harmonium-0-0-3b 26 Aug 2014 - Enabled OBJ file export and modified UI.
Harmonium-0-0-3c 26 Aug 2014 - Fixed amplitude bug for power series.
- Fixed negative power input error for power series.
Harmonium-0-0-3d 27 Aug 2014 - Fixed fractional power input error for power series.
Harmonium-0-0-3e 27 Aug 2014 - Fixed OpenGL update bug when user enters illegal value.
Harmonium-0-0-3f 27 Aug 2014 - Ensured field values are not reset to zero after an illegal
entry - rather the closest legal value is used instead.
Harmonium-0-0-3g 28 Aug 2014 - Tweaked memory code to give better leak checking and reporting.
- Tweaked assert code to enable assertion logging.
Harmonium-0-0-3h 29 Aug 2014 - Added a 'Flip Normals' option for OBJ export
- Added small material file for OBJ file export
- Fixed bug where OpenGL lighting normals were scaled with a zoom.
Harmonium-0-0-3i 31 Aug 2014 - Changed View menu options to 'Clockwise winding', 'Flip model
- normals', 'Draw model normals', 'Draw winding normals'.
- Improved export format of OBJ file for flat shading with vertex
normals now specified for flat facets.
- Examined exported files to ensure that 'Clockwise winding' and
- 'Flip model normals' behave correctly.
Harmonium-0-0-3j 05 Sep 2014 - Added View menu option 'Draw quad wireframe'. This is helpful in
revealing the structure of the spherical harmonic. Thus you
can render with smooth shading and simultaneosly 'overlay' the
quad wireframe. This is drawn ever so slightly above the underlying
triangular mesh, thus eliminating motion artefacts. (Otherwise facets
sometimes obscure wires as the sphere tumbles). This combination
gives the best of both worlds - a triangular mesh for fine subdivision
of complex harmonics - and a quad overlay to visually describe the form.
- Added preliminary code to colour by amplitude using vertex colours so that
higher amplitudes render in a warmer colours.
- Fixed UI bug. At app launch, n=8 and m=4; however the min and max of the
'm' spinner control were not initialised.
- Added Prefs window where the color ramp for amplitude can be scaled, thus
adjusting the gradient between colors.
Harmonium-0-0-3j2 06 Sep 2014 - Added PLY export format for vertex colours. Tested exported files which
open in MeshLab version 1.3.3. (http://meshlab.sourceforge.net). When
rendering the file in Meshlab, ensure that the menu Render->Color->Per vertex
is ticked.