title: Ogre3D and SkyX - Can't get SkyX to work properly
body: <p>I have been trying to get SkyX to work for a while now but couldn't succeed. Here is my code:</p>
  
  <pre><code>//THESE ARE GLOBAL
  SkyX::BasicController* skyBasicController = NULL;
  SkyX::SkyX* mSkyX = NULL;
  Ogre::Camera* camera;
  ...
  
      Ogre::SceneManager *sceneManager = ogreMain.getRoot()-&gt;createSceneManager(
              Ogre::ST_GENERIC, "MainSceneManager");
      Ogre::SceneNode *rootSceneNode = sceneManager-&gt;getRootSceneNode();
  
      Ogre::ResourceGroupManager&amp; resGrpMgr =
              Ogre::ResourceGroupManager::getSingleton();
  
      Ogre::String terrainResGrpName = "Terrain";
      resGrpMgr.createResourceGroup(terrainResGrpName);
      resGrpMgr.addResourceLocation(".\\Media\\Terrain\\programs", "FileSystem",
              terrainResGrpName, 0);
      resGrpMgr.addResourceLocation(".\\Media\\Terrain\\scripts", "FileSystem",
              terrainResGrpName, 0);
      resGrpMgr.addResourceLocation(".\\Media\\Terrain\\textures", "FileSystem",
              terrainResGrpName, 0);
  
      // The function 'initialiseResourceGroup' parses scripts if any in the locations.
      resGrpMgr.initialiseResourceGroup(terrainResGrpName);
  
      // Files that can be loaded are loaded.
      resGrpMgr.loadResourceGroup(terrainResGrpName);
  
      Ogre::String skyResGrpName = "SkyX";
      resGrpMgr.createResourceGroup(skyResGrpName);
      resGrpMgr.addResourceLocation(".\\Media\\SkyX", "FileSystem", skyResGrpName,
              0);
  
      // The function 'initialiseResourceGroup' parses scripts if any in the locations.
      resGrpMgr.initialiseResourceGroup(skyResGrpName);
  
      // Files that can be loaded are loaded.
      resGrpMgr.loadResourceGroup(skyResGrpName);
  
      ogreMain.getWindow()-&gt;setActive(true);
      ogreMain.getWindow()-&gt;setAutoUpdated(false);
      sceneManager-&gt;setAmbientLight(Ogre::ColourValue(.6, .6, .6));
      sceneManager-&gt;setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
      sceneManager-&gt;setShadowColour(ColourValue(0, 0, 0));
  
      camera = sceneManager-&gt;createCamera();
  
      Ogre::SceneNode *camera_node = player_node-&gt;createChildSceneNode();
      camera_node-&gt;attachObject(camera);
      float viewport_width = 1.0f;
      float viewport_height = 1.0f;
      float viewport_left = (1.0f - viewport_width) * 0.5f;
      float viewport_top = (1.0f - viewport_height) * 0.5f;
      unsigned short lMainViewportZOrder = 100;
      Ogre::Viewport *vp = ogreMain.getWindow()-&gt;addViewport(camera,
      lMainViewportZOrder, viewport_left, viewport_top, viewport_width,
          viewport_height);
  
      vp-&gt;setAutoUpdated(true);
      //vp-&gt;setBackgroundColour(Ogre::ColourValue(0.2f, 0.2f, 0.2f));
  
      float ratio = float(vp-&gt;getActualWidth()) / float(vp-&gt;getActualHeight());
      camera-&gt;setAspectRatio(ratio);
  
      camera-&gt;setNearClipDistance(1.5f);
      camera-&gt;setFarClipDistance(50000);
  
      camera-&gt;setPosition(0, 6, 26);
      camera-&gt;setDirection(0, -1, -6.5f);
  ...
  
      skyBasicController = new SkyX::BasicController();
      mSkyX = new SkyX::SkyX(sceneManager, skyBasicController);
      mSkyX-&gt;create();
      mSkyX-&gt;getVCloudsManager()-&gt;getVClouds()-&gt;setDistanceFallingParams(
              Ogre::Vector2(2, -1));
      ogreMain.getRoot()-&gt;addFrameListener(mSkyX);
      ogreMain.getWindow()-&gt;addListener(mSkyX);
  
      setPreset(mPresets[3]);
  
      ogreMain.getRoot()-&gt;clearEventTimes();
  
  ... //some var declarations, then main loop
  
  //BELOW HERE IS TAKEN FROM 2ND DEMO
  
  struct SkyXSettings
  {
      /** Constructor
          @remarks Skydome + vol. clouds + lightning settings
       */
      SkyXSettings(const Ogre::Vector3 t, const Ogre::Real&amp; tm, const Ogre::Real&amp; mp, const SkyX::AtmosphereManager::Options&amp; atmOpt,
          const bool&amp; lc, const bool&amp; vc, const Ogre::Real&amp; vcws, const bool&amp; vcauto, const Ogre::Radian&amp; vcwd, 
          const Ogre::Vector3&amp; vcac, const Ogre::Vector4&amp; vclr,  const Ogre::Vector4&amp; vcaf, const Ogre::Vector2&amp; vcw,
          const bool&amp; vcl, const Ogre::Real&amp; vclat, const Ogre::Vector3&amp; vclc, const Ogre::Real&amp; vcltm)
          : time(t), timeMultiplier(tm), moonPhase(mp), atmosphereOpt(atmOpt), layeredClouds(lc), volumetricClouds(vc), vcWindSpeed(vcws)
          , vcAutoupdate(vcauto), vcWindDir(vcwd), vcAmbientColor(vcac), vcLightResponse(vclr), vcAmbientFactors(vcaf), vcWheater(vcw)
          , vcLightnings(vcl), vcLightningsAT(vclat), vcLightningsColor(vclc), vcLightningsTM(vcltm)
      {}
  
      /** Constructor
          @remarks Skydome + vol. clouds
       */
      SkyXSettings(const Ogre::Vector3 t, const Ogre::Real&amp; tm, const Ogre::Real&amp; mp, const SkyX::AtmosphereManager::Options&amp; atmOpt,
          const bool&amp; lc, const bool&amp; vc, const Ogre::Real&amp; vcws, const bool&amp; vcauto, const Ogre::Radian&amp; vcwd, 
          const Ogre::Vector3&amp; vcac, const Ogre::Vector4&amp; vclr,  const Ogre::Vector4&amp; vcaf, const Ogre::Vector2&amp; vcw)
          : time(t), timeMultiplier(tm), moonPhase(mp), atmosphereOpt(atmOpt), layeredClouds(lc), volumetricClouds(vc), vcWindSpeed(vcws)
          , vcAutoupdate(vcauto), vcWindDir(vcwd), vcAmbientColor(vcac), vcLightResponse(vclr), vcAmbientFactors(vcaf), vcWheater(vcw), vcLightnings(false)
      {}
  
      /** Constructor
          @remarks Skydome settings
       */
      SkyXSettings(const Ogre::Vector3 t, const Ogre::Real&amp; tm, const Ogre::Real&amp; mp, const SkyX::AtmosphereManager::Options&amp; atmOpt, const bool&amp; lc)
          : time(t), timeMultiplier(tm), moonPhase(mp), atmosphereOpt(atmOpt), layeredClouds(lc), volumetricClouds(false), vcLightnings(false)
      {}
  
      /// Time
      Ogre::Vector3 time;
      /// Time multiplier
      Ogre::Real timeMultiplier;
      /// Moon phase
      Ogre::Real moonPhase;
      /// Atmosphere options
      SkyX::AtmosphereManager::Options atmosphereOpt;
      /// Layered clouds?
      bool layeredClouds;
      /// Volumetric clouds?
      bool volumetricClouds;
      /// VClouds wind speed
      Ogre::Real vcWindSpeed;
      /// VClouds autoupdate
      bool vcAutoupdate;
      /// VClouds wind direction
      Ogre::Radian vcWindDir;
      /// VClouds ambient color
      Ogre::Vector3 vcAmbientColor;
      /// VClouds light response
      Ogre::Vector4 vcLightResponse;
      /// VClouds ambient factors
      Ogre::Vector4 vcAmbientFactors;
      /// VClouds wheater
      Ogre::Vector2 vcWheater;
      /// VClouds lightnings?
      bool vcLightnings;
      /// VClouds lightnings average aparition time
      Ogre::Real vcLightningsAT;
      /// VClouds lightnings color
      Ogre::Vector3 vcLightningsColor;
      /// VClouds lightnings time multiplier
      Ogre::Real vcLightningsTM;
  };
  
  /** Demo presets
      @remarks The best way of determinate each parameter value is by using a real-time editor.
               These presets have been quickly designed using the Paradise Editor, which is a commercial solution.
               At the time I'm writting these lines, SkyX 0.1 is supported by Ogitor. Hope that the Ogitor team will 
               support soon SkyX 0.3, this way you all are going to be able to quickly create cool SkyX configurations.
   */
  SkyXSettings mPresets[] = {
      // Sunset
      SkyXSettings(Ogre::Vector3(8.85f, 7.5f, 20.5f),  -0.08f, 0, SkyX::AtmosphereManager::Options(9.77501f, 10.2963f, 0.01f, 0.0022f, 0.000675f, 30, Ogre::Vector3(0.57f, 0.52f, 0.44f), -0.991f, 3, 4), false, true, 300, false, Ogre::Radian(270), Ogre::Vector3(0.63f,0.63f,0.7f), Ogre::Vector4(0.35, 0.2, 0.92, 0.1), Ogre::Vector4(0.4, 0.7, 0, 0), Ogre::Vector2(0.8,1)),
      // Clear
      SkyXSettings(Ogre::Vector3(17.16f, 7.5f, 20.5f), 0, 0, SkyX::AtmosphereManager::Options(9.77501f, 10.2963f, 0.01f, 0.0017f, 0.000675f, 30, Ogre::Vector3(0.57f, 0.54f, 0.44f), -0.991f, 2.5f, 4), false),
      // Thunderstorm 1
      SkyXSettings(Ogre::Vector3(12.23, 7.5f, 20.5f),  0, 0, SkyX::AtmosphereManager::Options(9.77501f, 10.2963f, 0.01f, 0.00545f, 0.000375f, 30, Ogre::Vector3(0.55f, 0.54f, 0.52f), -0.991f, 1, 4), false, true, 300, false, Ogre::Radian(0), Ogre::Vector3(0.63f,0.63f,0.7f), Ogre::Vector4(0.25, 0.4, 0.5, 0.1), Ogre::Vector4(0.45, 0.3, 0.6, 0.1), Ogre::Vector2(1,1), true, 0.5, Ogre::Vector3(1,0.976,0.92), 2),
      // Thunderstorm 2
      SkyXSettings(Ogre::Vector3(10.23, 7.5f, 20.5f),  0, 0, SkyX::AtmosphereManager::Options(9.77501f, 10.2963f, 0.01f, 0.00545f, 0.000375f, 30, Ogre::Vector3(0.55f, 0.54f, 0.52f), -0.991f, 0.5, 4), false, true, 300, false, Ogre::Radian(0), Ogre::Vector3(0.63f,0.63f,0.7f), Ogre::Vector4(0, 0.02, 0.34, 0.24), Ogre::Vector4(0.29, 0.3, 0.6, 1), Ogre::Vector2(1,1), true, 0.5, Ogre::Vector3(0.95,1,1), 2),
      // Desert
      SkyXSettings(Ogre::Vector3(7.59f, 7.5f, 20.5f), 0, -0.8f, SkyX::AtmosphereManager::Options(9.77501f, 10.2963f, 0.01f, 0.0072f, 0.000925f, 30, Ogre::Vector3(0.71f, 0.59f, 0.53f), -0.997f, 2.5f, 1), true),
      // Night
      SkyXSettings(Ogre::Vector3(21.5f, 7.5, 20.5), 0.03, -0.25, SkyX::AtmosphereManager::Options(), true)
  };
  
  void setPreset(const SkyXSettings&amp; preset)
  {
      mSkyX-&gt;setTimeMultiplier(preset.timeMultiplier);
      mBasicController-&gt;setTime(preset.time);
      mBasicController-&gt;setMoonPhase(preset.moonPhase);
      mSkyX-&gt;getAtmosphereManager()-&gt;setOptions(preset.atmosphereOpt);
  
      // Layered clouds
      if (preset.layeredClouds)
      {
          // Create layer cloud
          if (mSkyX-&gt;getCloudsManager()-&gt;getCloudLayers().empty())
          {
              mSkyX-&gt;getCloudsManager()-&gt;add(SkyX::CloudLayer::Options(/* Default options */));
          }
      }
      else
      {
          // Remove layer cloud
          if (!mSkyX-&gt;getCloudsManager()-&gt;getCloudLayers().empty())
          {
              mSkyX-&gt;getCloudsManager()-&gt;removeAll();
          }
      }
  
      mSkyX-&gt;getVCloudsManager()-&gt;setWindSpeed(preset.vcWindSpeed);
      mSkyX-&gt;getVCloudsManager()-&gt;setAutoupdate(preset.vcAutoupdate);
  
      SkyX::VClouds::VClouds* vclouds = mSkyX-&gt;getVCloudsManager()-&gt;getVClouds();
  
      vclouds-&gt;setWindDirection(preset.vcWindDir);
      vclouds-&gt;setAmbientColor(preset.vcAmbientColor);
      vclouds-&gt;setLightResponse(preset.vcLightResponse);
      vclouds-&gt;setAmbientFactors(preset.vcAmbientFactors);
      vclouds-&gt;setWheater(preset.vcWheater.x, preset.vcWheater.y, false);
  
      if (preset.volumetricClouds)
      {
          // Create VClouds
          if (!mSkyX-&gt;getVCloudsManager()-&gt;isCreated())
          {
              // SkyX::MeshManager::getSkydomeRadius(...) works for both finite and infinite(=0) camera far clip distances
              mSkyX-&gt;getVCloudsManager()-&gt;create(mSkyX-&gt;getMeshManager()-&gt;getSkydomeRadius(mRenderingCamera));
          }
      }
      else
      {
          // Remove VClouds
          if (mSkyX-&gt;getVCloudsManager()-&gt;isCreated())
          {
              mSkyX-&gt;getVCloudsManager()-&gt;remove();
          }
      }
  
      vclouds-&gt;getLightningManager()-&gt;setEnabled(preset.vcLightnings);
      vclouds-&gt;getLightningManager()-&gt;setAverageLightningApparitionTime(preset.vcLightningsAT);
      vclouds-&gt;getLightningManager()-&gt;setLightningColor(preset.vcLightningsColor);
      vclouds-&gt;getLightningManager()-&gt;setLightningTimeMultiplier(preset.vcLightningsTM);
  
      //mTextArea-&gt;setCaption(buildInfoStr());
  
      // Reset camera position/orientation
      //mRenderingCamera-&gt;setPosition(0,0,0);
      //mRenderingCamera-&gt;setDirection(0,0,1);
  
      mSkyX-&gt;update(0);
  }
  </code></pre>
  
  <p>I am not using ExampleApplication framework or any other framework. I have wrtitten my own small class with my needs.</p>
  
  <p>I can only see lightnings and they seem to be too close compared to demos. Also, all the lightnings' origin is constantly at the top of the camera, moving with it.</p>
  
  <p>I only have a few boxes and a camera attached to one of them in my scene.</p>
  
  <p>I have compiled SkyX 0.3.1 as seperate DLL, with the same boost and ogre libraries(with the application, all conf'ed as debug) as debug conf' set.</p>
  
  <p>Debug output mentioning SkyX follows as:</p>
  
  <pre><code>Creating resource group Terrain
  Added resource location '.\Media\Terrain\programs' of type 'FileSystem' to resource group 'Terrain'
  Added resource location '.\Media\Terrain\scripts' of type 'FileSystem' to resource group 'Terrain'
  Added resource location '.\Media\Terrain\textures' of type 'FileSystem' to resource group 'Terrain'
  Initialising resource group Terrain
  Parsing scripts for resource group Terrain
  Parsing script Terrain.material
  Finished parsing scripts for resource group Terrain
  Creating resources for group Terrain
  All done
  Loading resource group 'Terrain' - Resources: 1 World Geometry: 1
  Texture: TerrainAmbientMap.jpg: Loading 1 faces(PF_L8,512x512x1) Internal format is PF_L8,512x512x1.
  Texture: TerrainTex0.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) Internal format is PF_X8R8G8B8,512x512x1.
  Texture: TerrainTex1.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) Internal format is PF_X8R8G8B8,512x512x1.
  Finished loading resource group Terrain
  Creating resource group SkyX
  Added resource location '.\Media\SkyX' of type 'FileSystem' to resource group 'SkyX'
  Initialising resource group SkyX
  Parsing scripts for resource group SkyX
  Parsing script SkyX.material
  Finished parsing scripts for resource group SkyX
  Creating resources for group SkyX
  All done
  Loading resource group 'SkyX' - Resources: 1 World Geometry: 1
  Texture: Noise.jpg: Loading 1 faces(PF_R8G8B8,1024x1024x1) Internal format is PF_X8R8G8B8,1024x1024x1.
  Texture: SkyX_Starfield.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) Internal format is PF_A8R8G8B8,512x512x1.
  Texture: SkyX_Moon.png: Loading 1 faces(PF_A8R8G8B8,512x512x1) Internal format is PF_A8R8G8B8,512x512x1.
  Texture: SkyX_MoonHalo.png: Loading 1 faces(PF_A8R8G8B8,512x256x1) Internal format is PF_A8R8G8B8,512x256x1.
  Finished loading resource group SkyX
  ...
  
  Can't assign material _NULL_ to SubEntity of SkyXMeshEnt because this Material does not exist. Have you forgotten to define it in a .material script?
  [SkyX] VClouds warning: unregistered camera registered, manual unregistering is needed before camera destruction
  </code></pre>
  
  <p>Thanks.</p>