2012-01-26 23:08:09 +00:00
# include "formatmosphere.h"
2012-02-12 17:26:17 +00:00
# include "tools.h"
2012-11-25 21:53:01 +00:00
# include <QColor>
# include <QSlider>
# include <math.h>
2012-12-02 11:08:56 +00:00
# include "../lib_paysages/atmosphere/public.h"
2012-01-26 23:08:09 +00:00
# include "../lib_paysages/scenery.h"
2012-11-25 21:53:01 +00:00
# include "../lib_paysages/renderer.h"
2012-01-26 23:08:09 +00:00
2012-11-25 21:53:01 +00:00
static AtmosphereDefinition * _definition ;
2012-01-26 23:08:09 +00:00
/**************** Previews ****************/
2012-11-25 21:53:01 +00:00
class PreviewSkyEast : public BasePreview
{
public :
PreviewSkyEast ( QWidget * parent ) :
BasePreview ( parent )
{
2012-12-08 14:12:02 +00:00
_renderer = atmosphereCreatePreviewRenderer ( ) ;
2012-12-02 11:08:56 +00:00
2012-11-25 21:53:01 +00:00
configScaling ( 0.5 , 5.0 , 0.5 , 2.5 ) ;
}
protected :
QColor getColor ( double x , double y )
{
2012-12-07 14:15:28 +00:00
return colorToQColor ( atmosphereGetPreview ( & _renderer , x , - y , M_PI_2 ) ) ;
2012-11-25 21:53:01 +00:00
}
void updateData ( )
{
AtmosphereRendererClass . bind ( _renderer . atmosphere , _definition ) ;
}
private :
Renderer _renderer ;
} ;
class PreviewSkyWest : public BasePreview
2012-02-12 17:26:17 +00:00
{
public :
2012-11-25 21:53:01 +00:00
PreviewSkyWest ( QWidget * parent ) :
2012-02-21 13:41:02 +00:00
BasePreview ( parent )
2012-02-12 17:26:17 +00:00
{
2012-12-08 14:12:02 +00:00
_renderer = atmosphereCreatePreviewRenderer ( ) ;
2012-12-02 11:08:56 +00:00
2012-11-25 21:53:01 +00:00
configScaling ( 0.5 , 5.0 , 0.5 , 2.5 ) ;
2012-02-12 17:26:17 +00:00
}
protected :
2012-06-17 09:40:40 +00:00
QColor getColor ( double x , double y )
2012-02-12 17:26:17 +00:00
{
2012-12-07 14:15:28 +00:00
return colorToQColor ( atmosphereGetPreview ( & _renderer , x , - y , - M_PI_2 ) ) ;
2012-02-12 17:26:17 +00:00
}
void updateData ( )
{
2012-11-25 21:53:01 +00:00
AtmosphereRendererClass . bind ( _renderer . atmosphere , _definition ) ;
2012-02-12 17:26:17 +00:00
}
private :
Renderer _renderer ;
} ;
2012-01-26 23:08:09 +00:00
/**************** Form ****************/
FormAtmosphere : : FormAtmosphere ( QWidget * parent ) :
BaseForm ( parent )
{
2012-12-24 13:59:17 +00:00
addAutoPreset ( tr ( " Clear day " ) ) ;
addAutoPreset ( tr ( " Clear sunset " ) ) ;
addAutoPreset ( tr ( " Hazy morning " ) ) ;
addAutoPreset ( tr ( " Foggy " ) ) ;
addAutoPreset ( tr ( " Stormy " ) ) ;
2012-11-25 21:53:01 +00:00
_definition = ( AtmosphereDefinition * ) AtmosphereDefinitionClass . create ( ) ;
2012-01-26 23:08:09 +00:00
2012-11-25 21:53:01 +00:00
previewWest = new PreviewSkyWest ( this ) ;
addPreview ( previewWest , QString ( tr ( " West preview " ) ) ) ;
previewEast = new PreviewSkyEast ( this ) ;
addPreview ( previewEast , QString ( tr ( " East preview " ) ) ) ;
2012-01-26 23:08:09 +00:00
2012-11-25 21:53:01 +00:00
addInputEnum ( tr ( " Color model " ) , ( int * ) & _definition - > model , QStringList ( tr ( " Preetham/Shirley analytic model " ) ) < < tr ( " Bruneton/Neyret precomputed model " ) ) ;
addInputDouble ( tr ( " Day time " ) , & _definition - > daytime , 0.14 , 0.86 , 0.002 , 0.1 ) ;
addInputColor ( tr ( " Sun color " ) , & _definition - > sun_color ) ;
addInputDouble ( tr ( " Sun radius " ) , & _definition - > sun_radius , 0.0 , 0.4 , 0.004 , 0.04 ) ;
addInputDouble ( tr ( " Sun halo radius " ) , & _definition - > sun_halo_size , 0.0 , 0.4 , 0.004 , 0.04 ) ;
addInputCurve ( tr ( " Sun halo profile " ) , _definition - > sun_halo_profile , 0.0 , 1.0 , 0.0 , 1.0 , tr ( " Distance to center of the sun " ) , tr ( " Light influence (halo opacity) " ) ) ;
addInputDouble ( tr ( " Influence of skydome on lighting " ) , & _definition - > dome_lighting , 0.0 , 2.0 , 0.01 , 0.1 ) ;
2012-12-02 11:08:56 +00:00
addInputDouble ( tr ( " Humidity " ) , & _definition - > humidity , 0.0 , 1.0 , 0.01 , 0.1 ) ;
2012-01-26 23:08:09 +00:00
revertConfig ( ) ;
}
void FormAtmosphere : : revertConfig ( )
{
2012-11-25 21:53:01 +00:00
sceneryGetAtmosphere ( _definition ) ;
2012-01-26 23:08:09 +00:00
BaseForm : : revertConfig ( ) ;
}
void FormAtmosphere : : applyConfig ( )
{
2012-11-25 21:53:01 +00:00
scenerySetAtmosphere ( _definition ) ;
2012-01-26 23:08:09 +00:00
BaseForm : : applyConfig ( ) ;
}
void FormAtmosphere : : configChangeEvent ( )
{
2012-11-25 21:53:01 +00:00
AtmosphereDefinitionClass . validate ( _definition ) ;
2012-01-26 23:08:09 +00:00
BaseForm : : configChangeEvent ( ) ;
}
2012-12-24 13:59:17 +00:00
void FormAtmosphere : : autoPresetSelected ( int preset )
{
atmosphereAutoPreset ( _definition , ( AtmospherePreset ) preset ) ;
BaseForm : : autoPresetSelected ( preset ) ;
}