skyx demo inside baseaplication class

nevarim

18-11-2014 18:18:10

hi all

i have a little question about skyx:

i made a baseapplication with skyx, but i have a little problem with struct SkyXSettings

so

header


#ifndef __BaseApplication_h_
#define __BaseApplication_h_

#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>

#include <SdkTrays.h>
#include <SdkCameraMan.h>
#include <SkyX.h>

// ----------------------------------------------------------------------------
// Include the main OGRE header files
// Ogre.h just expands to including lots of individual OGRE header files
// ----------------------------------------------------------------------------
#include <Overlay/OgreTextAreaOverlayElement.h>
#include <ExampleApplication.h>

class BaseApplication : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener, OgreBites::SdkTrayListener
{
public:
BaseApplication(void);
virtual ~BaseApplication(void);

virtual void go(void);

protected:
virtual bool setup();
virtual bool configure(void);
virtual void chooseSceneManager(void);
virtual void createCamera(void);
virtual void createFrameListener(void);
virtual void createScene(void); // Override me!
virtual void destroyScene(void);
virtual void createViewports(void);
virtual void setupResources(void);
virtual void createResourceListener(void);
virtual void loadResources(void);

// Ogre::FrameListener
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);

// OIS::KeyListener
virtual bool keyPressed( const OIS::KeyEvent &arg );
virtual bool keyReleased( const OIS::KeyEvent &arg );
// OIS::MouseListener
virtual bool mouseMoved( const OIS::MouseEvent &arg );
virtual bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
virtual bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id );

// Ogre::WindowEventListener
//Adjust mouse clipping area
virtual void windowResized(Ogre::RenderWindow* rw);
//Unattach OIS before window shutdown (very important under Linux)
virtual void windowClosed(Ogre::RenderWindow* rw);

Ogre::Root *mRoot;
Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;
Ogre::String mResourcesCfg;
Ogre::String mPluginsCfg;

//Fix for 1.9
Ogre::OverlaySystem *mOverlaySystem;

// OgreBites
OgreBites::SdkTrayManager* mTrayMgr;
OgreBites::SdkCameraMan* mCameraMan; // basic camera controller
OgreBites::ParamsPanel* mDetailsPanel; // sample details panel

//Fix for 1.9:
OgreBites::InputContext mInputContext;

bool mCursorWasVisible; // was cursor visible before dialog appeared
bool mShutDown;

//OIS Input devices
OIS::InputManager* mInputManager;
OIS::Mouse* mMouse;
OIS::Keyboard* mKeyboard;

void createTextArea(void);
// ----------------------------------------------------------------------------
// SkyX-related ptrs
// ----------------------------------------------------------------------------
SkyX::SkyX* mSkyX;
SkyX::BasicController* mBasicController;

// ----------------------------------------------------------------------------
// Misc
// ----------------------------------------------------------------------------
Ogre::TextAreaOverlayElement* mTextArea;
Ogre::uint32 mCurrentPreset;
Ogre::Camera* mRenderingCamera;

void prepareskyx(void);

struct SkyXSettings
{
SkyXSettings(const Ogre::Vector3 t, const Ogre::Real& tm, const Ogre::Real& mp, const SkyX::AtmosphereManager::Options& atmOpt,
const bool& lc, const bool& vc, const Ogre::Real& vcws, const bool& vcauto, const Ogre::Radian& vcwd,
const Ogre::Vector3& vcac, const Ogre::Vector4& vclr, const Ogre::Vector4& vcaf, const Ogre::Vector2& vcw,
const bool& vcl, const Ogre::Real& vclat, const Ogre::Vector3& vclc, const Ogre::Real& 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)
{}

SkyXSettings(const Ogre::Vector3 t, const Ogre::Real& tm, const Ogre::Real& mp, const SkyX::AtmosphereManager::Options& atmOpt,
const bool& lc, const bool& vc, const Ogre::Real& vcws, const bool& vcauto, const Ogre::Radian& vcwd,
const Ogre::Vector3& vcac, const Ogre::Vector4& vclr, const Ogre::Vector4& vcaf, const Ogre::Vector2& 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)
{}


SkyXSettings(const Ogre::Vector3 t, const Ogre::Real& tm, const Ogre::Real& mp, const SkyX::AtmosphereManager::Options& atmOpt, const bool& 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;
};

SkyXSettings mPresets[5];
void setPreset(const SkyXSettings& preset);
Ogre::String buildInfoStr(void);
void prepareStruct(void);

Real mKeyBuffer;



};




#endif // #ifndef __BaseApplication_h_







and cpp


#include "BaseApplication.h"

//-------------------------------------------------------------------------------------
BaseApplication::BaseApplication(void)
: mRoot(0),
mCamera(0),
mSceneMgr(0),
mWindow(0),
mResourcesCfg(Ogre::StringUtil::BLANK),
mPluginsCfg(Ogre::StringUtil::BLANK),
mTrayMgr(0),
mCameraMan(0),
mDetailsPanel(0),
mCursorWasVisible(false),
mShutDown(false),
mInputManager(0),
mMouse(0),
mKeyboard(0),
mOverlaySystem(0),

{
}


//-------------------------------------------------------------------------------------
BaseApplication::~BaseApplication(void)
{
//Fix for 1.9
if (mTrayMgr) delete mTrayMgr;
if (mCameraMan) delete mCameraMan;
if (mOverlaySystem) delete mOverlaySystem;

//Remove ourself as a Window listener
Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
windowClosed(mWindow);
delete mRoot;
}

//-------------------------------------------------------------------------------------
bool BaseApplication::configure(void)
{
// Show the configuration dialog and initialise the system
// You can skip this and use root.restoreConfig() to load configuration
// settings if you were sure there are valid ones saved in ogre.cfg
if(mRoot->showConfigDialog())
{
// If returned true, user clicked OK so initialise
// Here we choose to let the system create a default rendering window by passing 'true'
mWindow = mRoot->initialise(true, "TutorialApplication Render Window");

return true;
}
else
{
return false;
}
}
//-------------------------------------------------------------------------------------
void BaseApplication::chooseSceneManager(void)
{
// Get the SceneManager, in this case a generic one
mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
//Fix for 1.9
mOverlaySystem = new Ogre::OverlaySystem();
mSceneMgr->addRenderQueueListener(mOverlaySystem);
}
//-------------------------------------------------------------------------------------
void BaseApplication::createCamera(void)
{
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");

// Position it at 500 in Z direction
mCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mCamera->lookAt(Ogre::Vector3(0,0,-300));
mCamera->setNearClipDistance(5);

mCameraMan = new OgreBites::SdkCameraMan(mCamera); // create a default camera controller
}
//-------------------------------------------------------------------------------------

void BaseApplication::createFrameListener(void)
{
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;

mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

mInputManager = OIS::InputManager::createInputSystem( pl );

mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));

//Fix for 1.9
mInputContext.mKeyboard = mKeyboard;
mInputContext.mMouse = mMouse;

mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);

//Set initial mouse clipping size
windowResized(mWindow);

//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);




// create a params panel for displaying sample details
mRoot->addFrameListener(this);
}
//-------------------------------------------------------------------------------------
void BaseApplication::destroyScene(void)
{
}
//-------------------------------------------------------------------------------------
void BaseApplication::createViewports(void)
{
// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
//-------------------------------------------------------------------------------------
void BaseApplication::setupResources(void)
{
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load(mResourcesCfg);

// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
//-------------------------------------------------------------------------------------
void BaseApplication::createResourceListener(void)
{

}
//-------------------------------------------------------------------------------------
void BaseApplication::loadResources(void)
{
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
//-------------------------------------------------------------------------------------
void BaseApplication::go(void)
{
#ifdef _DEBUG
mResourcesCfg = "resources_d.cfg";
mPluginsCfg = "plugins_d.cfg";
#else
mResourcesCfg = "resources.cfg";
mPluginsCfg = "plugins.cfg";
#endif

if (!setup())
return;

mRoot->startRendering();

// clean up
destroyScene();
}
//-------------------------------------------------------------------------------------
bool BaseApplication::setup(void)
{
mRoot = new Ogre::Root(mPluginsCfg);

setupResources();

bool carryOn = configure();
if (!carryOn) return false;

chooseSceneManager();
createCamera();
createViewports();

// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

// Create any resource listeners (for loading screens)
createResourceListener();
// Load resources
loadResources();

// Create the scene
createScene();

createFrameListener();

return true;
};
//-------------------------------------------------------------------------------------
bool BaseApplication::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
return false;

if(mShutDown)
return false;

mKeyboard->capture();
mMouse->capture();
mInputContext.capture();

// Clamp camera height
if (mCamera->getDerivedPosition().y < -400)
{
mCamera->setPosition(Ogre::Vector3(mCamera->getDerivedPosition().x, -400, mCamera->getDerivedPosition().z));
}

// Switch presets
if (mKeyboard->isKeyDown(OIS::KC_1) && mKeyBuffer < 0)
{
mCurrentPreset = 0;
setPreset(mPresets[mCurrentPreset]);

mKeyBuffer = 0.25f;
}
else if (mKeyboard->isKeyDown(OIS::KC_2) && mKeyBuffer < 0)
{
mCurrentPreset = 1;
setPreset(mPresets[mCurrentPreset]);

mKeyBuffer = 0.25f;
}
else if (mKeyboard->isKeyDown(OIS::KC_3) && mKeyBuffer < 0)
{
mCurrentPreset = 2;
setPreset(mPresets[mCurrentPreset]);

mKeyBuffer = 0.25f;
}
else if (mKeyboard->isKeyDown(OIS::KC_4) && mKeyBuffer < 0)
{
mCurrentPreset = 3;
setPreset(mPresets[mCurrentPreset]);

mKeyBuffer = 0.25f;
}
else if (mKeyboard->isKeyDown(OIS::KC_5) && mKeyBuffer < 0)
{
mCurrentPreset = 4;
setPreset(mPresets[mCurrentPreset]);

mKeyBuffer = 0.25f;
}
else if (mKeyboard->isKeyDown(OIS::KC_6) && mKeyBuffer < 0)
{
mCurrentPreset = 5;
setPreset(mPresets[mCurrentPreset]);

mKeyBuffer = 0.25f;
}

mKeyBuffer -= evt.timeSinceLastFrame;


return true;
}
//-------------------------------------------------------------------------------------
bool BaseApplication::keyPressed( const OIS::KeyEvent &arg )
{
if (arg.key == OIS::KC_ESCAPE)
{
mShutDown = true;
}

mCameraMan->injectKeyDown(arg);
return true;
}

bool BaseApplication::keyReleased( const OIS::KeyEvent &arg )
{
mCameraMan->injectKeyUp(arg);
return true;
}

bool BaseApplication::mouseMoved( const OIS::MouseEvent &arg )
{
if (mTrayMgr->injectMouseMove(arg)) return true;
mCameraMan->injectMouseMove(arg);
return true;
}

bool BaseApplication::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if (mTrayMgr->injectMouseDown(arg, id)) return true;
mCameraMan->injectMouseDown(arg, id);
return true;
}

bool BaseApplication::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if (mTrayMgr->injectMouseUp(arg, id)) return true;
mCameraMan->injectMouseUp(arg, id);
return true;
}

//Adjust mouse clipping area
void BaseApplication::windowResized(Ogre::RenderWindow* rw)
{
unsigned int width, height, depth;
int left, top;
rw->getMetrics(width, height, depth, left, top);

const OIS::MouseState &ms = mMouse->getMouseState();
ms.width = width;
ms.height = height;
}

//Unattach OIS before window shutdown (very important under Linux)
void BaseApplication::windowClosed(Ogre::RenderWindow* rw)
{
//Only close for window that created OIS (the main window in these demos)
if( rw == mWindow )
{
if( mInputManager )
{
mInputManager->destroyInputObject( mMouse );
mInputManager->destroyInputObject( mKeyboard );

OIS::InputManager::destroyInputSystem(mInputManager);
mInputManager = 0;
}
}
}
void BaseApplication::prepareskyx(void)
{

// ----------------------------------------------------------------------------
// SkyX-related ptrs
// ----------------------------------------------------------------------------
SkyX::SkyX* mSkyX = 0;
SkyX::BasicController* mBasicController = 0;

// ----------------------------------------------------------------------------
// Misc
// ----------------------------------------------------------------------------
Ogre::TextAreaOverlayElement* mTextArea = 0;
Ogre::uint32 mCurrentPreset = 0;
Ogre::Camera* mRenderingCamera = 0;
prepareStruct();
}

void BaseApplication::prepareStruct(void)
{
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)
};
}

Ogre::String BaseApplication::buildInfoStr(void)
{
Ogre::String str = "SkyX 0.4 demo - Select preset: [1] Desert, [2] Clear, [3] Thunderstorm (1), [4] Thunderstorm (2), [5] Sunset, [6] Night\nCurrent preset: ";

switch (mCurrentPreset)
{
case 0: {str += "1 - Sunset";} break;
case 1: {str += "2 - Clear";} break;
case 2: {str += "3 - Thunderstorm (1)";} break;
case 3: {str += "4 - Thunderstorm (2)";} break;
case 4: {str += "5 - Desert";} break;
case 5: {str += "6 - Night";} break;
}

return str;
}

void BaseApplication::setPreset(const SkyXSettings& preset)
{
mSkyX->setTimeMultiplier(preset.timeMultiplier);
mBasicController->setTime(preset.time);
mBasicController->setMoonPhase(preset.moonPhase);
mSkyX->getAtmosphereManager()->setOptions(preset.atmosphereOpt);

// Layered clouds
if (preset.layeredClouds)
{
// Create layer cloud
if (mSkyX->getCloudsManager()->getCloudLayers().empty())
{
mSkyX->getCloudsManager()->add(SkyX::CloudLayer::Options(/* Default options */));
}
}
else
{
// Remove layer cloud
if (!mSkyX->getCloudsManager()->getCloudLayers().empty())
{
mSkyX->getCloudsManager()->removeAll();
}
}

mSkyX->getVCloudsManager()->setWindSpeed(preset.vcWindSpeed);
mSkyX->getVCloudsManager()->setAutoupdate(preset.vcAutoupdate);

SkyX::VClouds::VClouds* vclouds = mSkyX->getVCloudsManager()->getVClouds();

vclouds->setWindDirection(preset.vcWindDir);
vclouds->setAmbientColor(preset.vcAmbientColor);
vclouds->setLightResponse(preset.vcLightResponse);
vclouds->setAmbientFactors(preset.vcAmbientFactors);
vclouds->setWheater(preset.vcWheater.x, preset.vcWheater.y, false);

if (preset.volumetricClouds)
{
// Create VClouds
if (!mSkyX->getVCloudsManager()->isCreated())
{
// SkyX::MeshManager::getSkydomeRadius(...) works for both finite and infinite(=0) camera far clip distances
mSkyX->getVCloudsManager()->create(mSkyX->getMeshManager()->getSkydomeRadius(mRenderingCamera));
}
}
else
{
// Remove VClouds
if (mSkyX->getVCloudsManager()->isCreated())
{
mSkyX->getVCloudsManager()->remove();
}
}

vclouds->getLightningManager()->setEnabled(preset.vcLightnings);
vclouds->getLightningManager()->setAverageLightningApparitionTime(preset.vcLightningsAT);
vclouds->getLightningManager()->setLightningColor(preset.vcLightningsColor);
vclouds->getLightningManager()->setLightningTimeMultiplier(preset.vcLightningsTM);

mTextArea->setCaption(buildInfoStr());

// Reset camera position/orientation
mRenderingCamera->setPosition(0,0,0);
mRenderingCamera->setDirection(0,0,1);

mSkyX->update(0);
}


void BaseApplication::createTextArea(void)
{
// Create a panel
Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "SkyXParametersPanel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setPosition(10, 10);
panel->setDimensions(400, 400);

// Create a text area
mTextArea = static_cast<Ogre::TextAreaOverlayElement*>(
Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", "SkyXParametersTextArea"));
mTextArea->setMetricsMode(Ogre::GMM_PIXELS);
mTextArea->setPosition(0, 0);
mTextArea->setDimensions(100, 100);
mTextArea->setCaption("SkyX plugin demo");
mTextArea->setCharHeight(16);
mTextArea->setFontName("BlueHighway");
mTextArea->setColourBottom(Ogre::ColourValue(0.3, 0.5, 0.3));
mTextArea->setColourTop(Ogre::ColourValue(0.5, 0.7, 0.5));

// Create an overlay, and add the panel
Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create("OverlayName");
overlay->add2D(panel);

// Add the text area to the panel
panel->addChild(mTextArea);

// Show the overlay
overlay->show();
}

void BaseApplication::createScene(void)
{
// Set camera far/near clip distances
mCamera->setFarClipDistance(30000);
mCamera->setNearClipDistance(20);

// Create our text area for display SkyX parameters
createTextArea();

// Create SkyX
mBasicController = new SkyX::BasicController();
mSkyX = new SkyX::SkyX(mSceneMgr, mBasicController);
mSkyX->create();

// Distance geometry falling is a feature introduced in SkyX 0.2
// When distance falling is enabled, the geometry linearly falls with the distance and the
// amount of falling in world units is determinated by the distance between the cloud field "plane"
// and the camera height multiplied by the falling factor.
// For this demo, a falling factor of two is good enough for the point of view we're using. That means that if the camera
// is at a distance of 100 world units from the cloud field, the fartest geometry will fall 2*100 = 200 world units.
// This way the cloud field covers a big part of the sky even if the camera is in at a very low altitude.
// The second parameter is the max amount of falling distance in world units. That's needed when for example, you've an
// ocean and you don't want to have the volumetric cloud field geometry falling into the water when the camera is underwater.
// -1 means that there's not falling limit.
mSkyX->getVCloudsManager()->getVClouds()->setDistanceFallingParams(Ogre::Vector2(2,-1));

// Register SkyX listeners
mRoot->addFrameListener(mSkyX);
mWindow->addListener(mSkyX);

mRenderingCamera = mCamera;

setPreset(mPresets[mCurrentPreset]);

}

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
BaseApplication app;

try {
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}

return 0;
}

#ifdef __cplusplus
}
#endif




can help me with this error?

1>i:\development\project\sky_mng\sky_mng\src\baseapplication.cpp(21): error C2512: 'BaseApplication::SkyXSettings' : no appropriate default constructor available


thanks
Neva

nevarim

20-11-2014 08:02:12

someone to help me? :)

nevarim

06-12-2014 11:47:27

:( always same error and i cannot get out from here

while im searching i'm making otherpiece ofprogram, but if somone can elp i appreciate :)


thanks

Neva

Anthea

12-12-2014 15:54:23

Hey there,

The error says, there is something wrong with the way you call the skyXSettings Constructor.
I assume line 21, where your error occurs is this:

// 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)),


or any of the other presets.

Here are my ideas how you can fix it:

1. Make sure that the way you define matches the way you call the constructors.
Since it has a lot of parameters it might be a load of work. Check if the number of parameter and types match the definition in the struct in the headerfile.

2. If this doesnt help: Check a working example, like this: viewtopic.php?f=20&t=29815