A quite complete and complex scenery which simulates a cloud-covered sky and a setting sun, by user choice over some land or above some ocean. Lots of parameters can be set on the command line.
#include <3D/scenery/atmosphere.hpp>
#include <3D/scenery/clouds.hpp>
#include <3D/fractal.hpp>
#include <3D/Camera.hpp>
#include <3D/Scene.hpp>
#include <3D/Material.hpp>
#include <3D/Textur.hpp>
#include <wb/Parameters.hpp>
#include <3D/ObjectManager.hpp>
using namespace wb;
using namespace Lux;
class Spherical_Layer : public Fractal_Clouds
{
void addto(Scene&) {}
public: Spherical_Layer(Atmosphere&Erde, Material&S,
const vector3&Center,double r,
const Fractal&FDensity, const Shape&Sh,
double de, double db, const vector3&scale);
};
Spherical_Layer::Spherical_Layer(Atmosphere&Erde,Material&S,
const vector3&Center,
double r, const Fractal&FDensity,
const Shape&Sh, double de, double db,
const vector3&scale)
:Fractal_Clouds(Erde,S,1,2,0,FDensity, Sh, de, db, scale)
{
R = r;
M = Center;
}
int main(int argc,const char*argv[])
{
if (print_help(argc, argv))
return 0;
Parameters Params(argc,argv);
Params.load("wolke.par");
ObjectManager OM;
Params.Qmode = Params.CREATE_ENTRY;
double sonne_altitude = Params("sun::altitude",70)*M_PI/180,
sonne_azimuth = Params("sun::azimuth",270)*M_PI/180;
double Standhoehe = Params("Camera::height",1.500);
vector3 Standpkt(0,0,Standhoehe);
vector3 Blickpkt = West + vector3(0,0,Standhoehe+
tan(Params("Camera::upangle",15)*M_PI/180));
Camera Kamera(Standpkt,Blickpkt);
Standardobjektiv Stdlens(Params("Lens::angle",50)*M_PI/180.);
Kamera.use(Stdlens);
Scene Welt;
const double Erdradius = 6350000.0;
const vector3 Erdmitte(0,0,-Erdradius);
Material Sand = Material::matt;
Sand.diffuse = rgb_real(1,1,1);
Sand.speculiar = rgb_real(0,0,0);
Material H2O = Material::water;
Material&Erde = Params["water::"]?H2O:Sand;
vnoise Vmeer(Erde,0.1,.1,fast_cubic);
Transformed_Material Tmeer1(Vmeer), Tmeer2(Vmeer);
Tmeer1.scale(vector3(10,1,1));
Tmeer2.scale(vector3(10,1,1));
Tmeer2.rotz(45*M_PI/180.);
Two_Materials Tmeer(Tmeer1, Tmeer2);
Material&Meer = Params["transmeer::"]?(Material&)Tmeer
:(Material&)Vmeer;
bool waves = Params[ "waves::" ];
Sphere Erdkruste(waves?Meer:Erde, Erdmitte,Erdradius);
Welt.add(Erdkruste);
Erdkruste.name="Erdkruste";
Atmosphere atm(Erdkruste, Params["air::"] );
if (Params["air::"] )
Welt.add(atm);
atm.Luft.optical_depth = Params("air::steps",-7);
#if 1
Material Clair = atm.Luft;
Antique_Clouds AClouds(atm, Clair,
Params("ac::low",2000),
Params("ac::high",4000));
if (Params["ac::"])
Welt.add(AClouds);
AClouds.sharpness = Params("ac::sharp", 40.0);
AClouds.scale = Params("ac::scale", vector3(.2,1,1));
AClouds.complexity = Params("ac::cmplx", 20);
AClouds.density = Params("ac::cdens", 1E-1);
AClouds.origin = Params("ac::origin",vector3(0,0,0));
double cloud_odepth = Params("ac::steps",-7);
AClouds.setoptical_depth(cloud_odepth);
fBm fBm_Cloud( Params("fBm::o",0),
Params("fBm::lac",2.0),
Params("fBm::h",0.6) );
Turbulence Turbcloud( Params("Turb::o",0),
Params("Turb::lac",2.0),
Params("Turb::h",0.6) );
Fractal&Cloudstructure = Params("fBm")?(Fractal&)fBm_Cloud
:(Fractal&)Turbcloud;
Fractal_Clouds::Shape Noshape;
vector3 RCenter = Params("radial::C",vector3(-10000,0,3000));
double R = Params("radial::R",2000),
expf = Params("radial::exp",.1);
Radial_Shape RShape( RCenter, R, expf);
Hyperbolic_Shape HShape( RCenter, Params("hyperb::R",1.0)*R,
Params("hyperb::Zscale",1.),
Params("hyperb::a",1.),
Params("hyperb::b",1.),
Params("hyperb::exp",1.),
expf);
ZShape Upper(Params("top::z",RCenter.z+R*0.5),
Params("top::scale",1.0),
Params("top::exp",expf), true);
ZShape Lower(Params("bot::z",RCenter.z-R*0.5),
Params("bot::scale",1.0),
Params("bot::exp",expf), false);
double D = Params("fractal::D",1E-2);
double B = Params("fractal::B",0.0);
vector3 S = Params("fractal::S",vector3(1E-4,1E-4,1E-4));
bool RADIAL = Params("fractal::RADIAL"),
HYPERB = Params("fractal::HYPERB");
Fractal_Clouds::Shape&Cshape =
HYPERB?(Fractal_Clouds::Shape&)HShape :
RADIAL?(Fractal_Clouds::Shape&)RShape : Noshape;
bool ZSHAPE = Params("fractal::ZSHAPE");
Trishape Tris(Cshape, Upper, Lower);
Fractal_Clouds::Shape&Cloudshape = ZSHAPE?(Fractal_Clouds::Shape&)Tris:Cshape;
Spherical_Layer SL(atm, Clair,RCenter, R, Cloudstructure, Cloudshape, D, B, S);
SL.name="Spherical Cloud Layer";
Fractal_Clouds FC(atm, Clair,
Cloudstructure, Cloudshape,
Params["fractal::"]);
FC.top_exponent = S.z*Params("layer::top",1.0);
FC.bottom_exponent = S.z*Params("layer::bottom",1.0);
FC.wind_speed = Params("fractal::windspeed",vector3(0,.3, 1.0) );
FC.name="Fractal Cloud Layer";
double fsteps = Params("fractal::steps",-7.0);
FC.setoptical_depth(fsteps);
SL.setoptical_depth(fsteps);
if (Params["fractal::"])
Welt.add(FC);
if (Params["rfractal::"])
Welt.add(SL);
Material SB = Material::swporz;
Sphere Checksphere( RCenter, R, SB);
if (Params("checksphere"))
Welt.add(Checksphere);
#endif
Amun_Re Sonne(sonne_altitude,sonne_azimuth);
Welt.add(Sonne);
Kamera.Exposure_time= 1.0;
Kamera.action(Welt, Params["Camera::"] );
Params.save("wolke-out.par");
return 0;
}