VCloudsManager::VCloudsManager(SkyX *s)
    : mSkyX(s)
    , mVClouds(0)
    , mHeight(Ogre::Vector2(-1, -1))
    , mWindSpeed(800.0f)
    , mAutoupdate(true)
    , mCreated(false)
{
    mAmbientGradient = ColorGradient();
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.9f, 1.0f));
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.7,0.7,0.65), 0.625f));
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.6,0.55,0.4)*0.5, 0.5625f));
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.6,0.55,0.4)*0.2, 0.475f));
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.6,0.45,0.3)*0.1, 0.5f));
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.2,0.2,0.3)*0.25, 0.35f));
    mAmbientGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.2,0.2,0.3)*0.3, 0));

    mSunGradient = ColorGradient();
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.9f, 1.0f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(1,1,1)*0.8, 0.75f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.8,0.75,0.55)*1.3, 0.5625f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.6,0.5,0.2)*1.5, 0.5f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.6,0.5,0.2)*0.2, 0.4725f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.5,0.5,0.5)*0.05, 0.45f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.25,0.25,0.25), 0.3725f));
    mSunGradient.addCFrame(ColorGradient::ColorFrame(Ogre::Vector3(0.5,0.5,0.5), 0.0f));
}
	SmokeHandler(vec3 pos, unsigned char maxAlpha, float minVel, float maxVel, float spread) :
	speed(vec3(0,1,0), spread, minVel, maxVel),
	pos(pos,.1,.4), life(2.5,3) {
		delta = 0;
		fadeIn = Interpolator<unsigned char>(0, .4, maxAlpha);
		fadeOut = Interpolator<unsigned char>(.5, 1, 0, maxAlpha);
		expand = Interpolator<float>(0, .7, 1.2);
		retract = Interpolator<float>(.9, 1, 0, 5);
		//unsigned char colorMin[3] {0,0,0};
		unsigned char colorMax[3] {180,180,180};
		startGrad = ColorGradient(0,1,colorMax);
	}
  CloudLayer::CloudLayer(SkyX *s, const Options& o)
    : mSkyX(s),
    mOptions(o),
    mCloudLayerPass(0)
  {
    mAmbientGradient = ColorGradient();
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(1, 1, 1)*0.95f, 1.0f));
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.7, 0.7, 0.65), 0.625f));
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.6, 0.55, 0.4), 0.5625f));
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.6, 0.45, 0.3)*0.4, 0.5f));
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.5, 0.25, 0.25)*0.1, 0.45f));
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.2, 0.2, 0.3)*0.1, 0.35f));
    mAmbientGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.2, 0.2, 0.5)*0.15, 0));

    mSunGradient = ColorGradient();
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(1, 1, 1)*0.95f, 1.0f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(1, 1, 1)*0.8, 0.75f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.8, 0.75, 0.55)*1.3, 0.5625f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.6, 0.5, 0.2)*0.75, 0.5f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.6, 0.5, 0.2)*0.35, 0.4725f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.5, 0.5, 0.5)*0.15, 0.45f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.2, 0.2, 0.25)*0.5, 0.3f));
    mSunGradient.addCFrame(
        ColorGradient::ColorFrame(Ogre::Vector3(0.5, 0.5, 0.5)*0.35, 0.0f));
  }
	CloudLayer::CloudLayer(VCloudSkySystem *s, const Options& o)
		: mSkyX(s)
		, mOptions(o)		
	{
		mAmbientGradient = ColorGradient();
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(1,1,1)*0.95f, 1.0f));
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.7,0.7,0.65), 0.625f)); 
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.6,0.55,0.4), 0.5625f));
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.6,0.45,0.3)*0.4, 0.5f));
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.5,0.25,0.25)*0.1, 0.45f));
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.2,0.2,0.3)*0.1, 0.35f));
		mAmbientGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.2,0.2,0.5)*0.15, 0));

		mSunGradient = ColorGradient();
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(1,1,1)*0.95f, 1.0f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(1,1,1)*0.8, 0.75f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.8,0.75,0.55)*1.3, 0.5625f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.6,0.5,0.2)*0.75, 0.5f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.6,0.5,0.2)*0.35, 0.4725f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.5,0.5,0.5)*0.15, 0.45f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.2,0.2,0.25)*0.5, 0.3f));
		mSunGradient.addCFrame(ColorGradient::ColorFrame(noVec3(0.5,0.5,0.5)*0.35, 0.0f));
	}