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) Shea Nicholas 2010-2014-2024
nicholas-shea_AT_talktalk.net
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 64 bit development version; some features are disabled.
The program has been tested on Windows 10 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 Boost and
a modified version of WildMagic5p13 mathematics.
---------------------------------------------------------------------------------------------------------
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.
Harmonium-0-0-3m-64 16 Dec 2024 - 64 bit version for windows 10.
Harmonium-0-0-4b-win64 17 Dec 2024 - Added roller valuator controls and updated UI with custom Fl_Counter_X control.
Harmonium-0-0-5b-win64 18 Dec 2024 - Added animation recorder to capture frames as png images.
Start tumbling with the LEFT mouse button. Press PLAY, then press RECORD.
The frames are saved to the ./Output/Frames directory. Be sure to read the
info file: ./Output/Frames/Readme.txt for details. You may optionally reset
the frame counter using the menu 'View->Reset frame counter'.
Harmonium-0-0-6-win64 27 Dec 2024 - Added options to set sphere body and wireframe colours via the Prefs dialog.
Increased granularity of the morph controls from 0.1 to 0.01.
Made Prefs window floating and non-modal.
Harmonium-0-0-7-1b-win64 28 Dec 2024 - Changed power inputs to counters.
Synched values between morpher wheels and inputs.
Ensured Prefs window is hidden on Quit. Added Quit confirmation.
Added program resources and icon.
Harmonium-0-1-2-1b-win64 28 Dec 2024 - Changed UI and put controls into separate 'Controller' window with tabs.
Harmonium-0-1-2-2b-win64 29 Dec 2024 - Got rid of console window for release build.
NOTE: For some reason Microsoft Windows 11 has suddenly started reporting
a false positive entitled "Threat detected: Trojan:Win32/Wacatac.B!ml" but
there are no Trojans in the software. This only started happening on
29 DEC 2024, and I can only assume it is industrial espionage as most of
my sourceforge projects have been stolen and incorporated into commercial
products.
HarmoniumUFO-0-1-3-2b-win64 30 Dec 2024 - Added another 'Power Series B' tab to the controller. This functions exactly
as the 'Power Series A' tab, except that the inputs are set with FL_Counter_X
widgets; this allows finer control when creating animations.
NOTE: I submitted Harmonium-0-1-2-2b-win64 29 Dec 2024 to Microsoft for
examination of the false positive trojan report. Meanwhile, I compiled
HarmoniumUFO-0-1-3-2b-win64 which is an unstripped binary; curiously,
the unstripped version is not subject to the false positive report, and
Windows 11 allows me to run the executable without problems.
Development is now frozen for the foreseeable future.