...
 
Commits (4)
......@@ -23,6 +23,7 @@ void CCommandShipControl::execute(int iButton, int iState)
case 2:
l_poShooterApplication->getShip()->rotate(6);
break;
default: break;
}
}
......
......@@ -19,21 +19,15 @@ namespace OpenViBESSVEP
~CShooterApplication() override;
bool setup(OpenViBE::Kernel::IKernelContext* poKernelContext) override;
CStarShip* getShip() { return m_poShip; }
void startExperiment() override;
void addTarget(uint32_t ui32TargetPosition);
bool m_bTargetRequest = false;
private:
bool m_bActive = false;
void processFrame(uint32_t ui32CurrentFrame) override;
CEGUI::Window* m_poInstructionsReady = nullptr;
CStarShip* m_poShip = nullptr;
std::vector<CShooterTarget*> m_oTargets;
......
......@@ -32,7 +32,7 @@ bool CTrainerApplication::setup(IKernelContext* poKernelContext)
// paint targets
uint32_t l_ui32TargetCount = (uint32_t)(l_poConfigurationManager->expandAsUInteger("${SSVEP_TargetCount}"));
uint32_t l_ui32TargetCount = uint32_t(l_poConfigurationManager->expandAsUInteger("${SSVEP_TargetCount}"));
for (uint32_t i = 0; i < l_ui32TargetCount; i++)
{
......@@ -91,12 +91,12 @@ void CTrainerApplication::addObject(CTrainerFlickeringObject* poObject)
poObject->setVisible(true);
}
void CTrainerApplication::setTarget(int32_t i32Target)
void CTrainerApplication::setTarget(int i32Target)
{
uint32_t l_ui32CurrentTime = (int32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = int(time(nullptr) - m_ttStartTime);
(*m_poLogManager) << LogLevel_Info << l_ui32CurrentTime << " > Target set to " << i32Target << "\n";
for (int32_t i = 0; i < int(m_oObjects.size()); i++) { m_oObjects[i]->setTarget(i32Target == i); }
for (int i = 0; i < int(m_oObjects.size()); i++) { m_oObjects[i]->setTarget(i32Target == i); }
}
void CTrainerApplication::startExperiment()
......@@ -111,14 +111,14 @@ void CTrainerApplication::startExperiment()
void CTrainerApplication::startFlickering()
{
uint32_t l_ui32CurrentTime = (uint32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = uint32_t(time(nullptr) - m_ttStartTime);
(*m_poLogManager) << LogLevel_Info << l_ui32CurrentTime << " > Starting Visual Stimulation\n";
m_bActive = true;
}
void CTrainerApplication::stopFlickering()
{
uint32_t l_ui32CurrentTime = (uint32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = uint32_t(time(nullptr) - m_ttStartTime);
(*m_poLogManager) << LogLevel_Info << l_ui32CurrentTime << " > Stopping Visual Stimulation\n";
m_bActive = false;
......
......@@ -15,7 +15,7 @@ namespace OpenViBESSVEP
~CTrainerApplication() override {}
bool setup(OpenViBE::Kernel::IKernelContext* poKernelContext) override;
void setTarget(int32_t i32Target);
void setTarget(int i32Target);
void startExperiment() override;
void startFlickering() override;
......
......@@ -118,7 +118,7 @@ bool CApplication::setup(IKernelContext* poKernelContext)
// create the vector of stimulation frequencies
m_f64ScreenRefreshRate = (uint32_t)(l_poConfigurationManager->expandAsUInteger("${SSVEP_ScreenRefreshRate}"));
m_f64ScreenRefreshRate = uint32_t(l_poConfigurationManager->expandAsUInteger("${SSVEP_ScreenRefreshRate}"));
(*m_poLogManager) << LogLevel_Info << "Specified screen refresh rate :" << m_f64ScreenRefreshRate << "Hz\n";
......@@ -136,7 +136,7 @@ bool CApplication::setup(IKernelContext* poKernelContext)
double l_f64CurrentFrequency;
l_f64CurrentFrequency = (double)(l_poConfigurationManager->expandAsFloat("${SSVEP_Frequency_${SSVEP_FrequencyId}}"));
l_f64CurrentFrequency = double(l_poConfigurationManager->expandAsFloat("${SSVEP_Frequency_${SSVEP_FrequencyId}}"));
double l_f64ApproximatedFrameCount = m_f64ScreenRefreshRate / l_f64CurrentFrequency;
......
......@@ -16,10 +16,10 @@ CVRPNServer::CVRPNServer(CApplication* poApplication)
{
m_poApplication = poApplication;
int l_iPort = (int32_t)(m_poApplication->getConfigurationManager()->expandAsInteger("${VRPN_ExternalServerPort}"));
int port = int(m_poApplication->getConfigurationManager()->expandAsInteger("${VRPN_ExternalServerPort}"));
m_poApplication->getLogManager() << LogLevel_Debug << "VRPN SERVER PORT :" << l_iPort << "\n";
m_poConnection = vrpn_create_server_connection(l_iPort);
m_poApplication->getLogManager() << LogLevel_Debug << "VRPN SERVER PORT :" << port << "\n";
m_poConnection = vrpn_create_server_connection(port);
}
CVRPNServer* CVRPNServer::getInstance(CApplication* poApplication)
......
......@@ -14,7 +14,7 @@ namespace
{
void VRPN_CALLBACK ssvep_vrpn_callback_button(void* command, vrpn_BUTTONCB button)
{
((ICommandVRPNButton*)command)->execute(button.button, button.state);
static_cast<ICommandVRPNButton*>(command)->execute(button.button, button.state);
}
}
......
......@@ -16,17 +16,14 @@ int main(int argc, char** argv)
{
if (argc != 2)
{
printf("Usage : %s [trainer|shooter]\n", argv[0]);
std::cout << "Usage: " << argv[0] << " [trainer|shooter]\n";
exit(1);
}
// initialize the OpenViBE kernel
CKernelLoader l_oKernelLoader;
Kernel::IKernelDesc* l_poKernelDesc = nullptr;
Kernel::IKernelContext* l_poKernelContext = nullptr;
Kernel::ILogManager* l_poLogManager = nullptr;
Kernel::IConfigurationManager* l_poConfigurationManager = nullptr;
Kernel::IKernelDesc* l_poKernelDesc = nullptr;
CString l_sError;
#if defined TARGET_OS_Windows
......@@ -51,7 +48,7 @@ int main(int argc, char** argv)
}
std::cout << "[ INF ] Got kernel descriptor, trying to create kernel\n";
l_poKernelContext = l_poKernelDesc->createKernel("ssvep-demo", Directories::getDataDir() + "/kernel/openvibe.conf");
Kernel::IKernelContext* l_poKernelContext = l_poKernelDesc->createKernel("ssvep-demo", Directories::getDataDir() + "/kernel/openvibe.conf");
if (!l_poKernelContext)
{
......@@ -62,13 +59,13 @@ int main(int argc, char** argv)
OpenViBEToolkit::initialize(*l_poKernelContext);
l_poConfigurationManager = &(l_poKernelContext->getConfigurationManager());
Kernel::IConfigurationManager* l_poConfigurationManager = &(l_poKernelContext->getConfigurationManager());
l_poConfigurationManager->createConfigurationToken("SSVEP_ApplicationDescriptor", CString(argv[1]));
CString l_sConfigFile = l_poConfigurationManager->expand("${Path_Data}/applications/ssvep-demo/openvibe-ssvep-demo.conf");
l_poConfigurationManager->addConfigurationFromFile(l_sConfigFile);
l_poLogManager = &(l_poKernelContext->getLogManager());
Kernel::ILogManager* l_poLogManager = &(l_poKernelContext->getLogManager());
if (l_poConfigurationManager->expand("$Env{OGRE_HOME}").length() == 0)
{
......@@ -83,10 +80,9 @@ int main(int argc, char** argv)
l_poConfigurationManager->addOrReplaceConfigurationToken("BuildType", "Release");
#endif
OpenViBESSVEP::CApplication* app = nullptr;
CString l_sApplicationType = l_poConfigurationManager->expand("${SSVEP_ApplicationType}");
OpenViBESSVEP::CApplication* app;
const CString l_sApplicationType = l_poConfigurationManager->expand("${SSVEP_ApplicationType}");
(*l_poLogManager) << Kernel::LogLevel_Info << "Selected Application : '" << l_sApplicationType.toASCIIString() << "'\n";
......@@ -128,7 +124,7 @@ int main(int argc, char** argv)
int main(int argc, char** argv)
{
printf("SSVEP demo has not been compiled as it depends on Ogre (missing/disabled)\n");
std::cout << "SSVEP demo has not been compiled as it depends on Ogre (missing/disabled)\n";
return -1;
}
......
......@@ -43,7 +43,7 @@ bool CGenericStimulatorApplication::setup(IKernelContext* poKernelContext)
// paint targets
uint32_t l_ui32TargetCount = (uint32_t)(l_poConfigurationManager->expandAsUInteger("${SSVEP_TargetCount}"));
uint32_t l_ui32TargetCount = uint32_t(l_poConfigurationManager->expandAsUInteger("${SSVEP_TargetCount}"));
for (uint32_t i = 0; i < l_ui32TargetCount; i++)
{
......@@ -101,12 +101,12 @@ void CGenericStimulatorApplication::addObject(CGenericStimulatorFlickeringObject
poObject->setVisible(true);
}
void CGenericStimulatorApplication::setTarget(int32_t i32Target)
void CGenericStimulatorApplication::setTarget(int i32Target)
{
uint32_t l_ui32CurrentTime = (int32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = int(time(nullptr) - m_ttStartTime);
(*m_logManager) << LogLevel_Info << l_ui32CurrentTime << " > Target set to " << i32Target << "\n";
for (int32_t i = 0; i < int(m_oObjects.size()); i++) { m_oObjects[i]->setTarget(i32Target == i); }
for (int i = 0; i < int(m_oObjects.size()); i++) { m_oObjects[i]->setTarget(i32Target == i); }
}
void CGenericStimulatorApplication::startExperiment()
......@@ -121,14 +121,14 @@ void CGenericStimulatorApplication::startExperiment()
void CGenericStimulatorApplication::startFlickering()
{
uint32_t l_ui32CurrentTime = (uint32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = uint32_t(time(nullptr) - m_ttStartTime);
(*m_logManager) << LogLevel_Info << l_ui32CurrentTime << " > Starting Visual Stimulation\n";
m_bActive = true;
}
void CGenericStimulatorApplication::stopFlickering()
{
uint32_t l_ui32CurrentTime = (uint32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = uint32_t(time(nullptr) - m_ttStartTime);
(*m_logManager) << LogLevel_Info << l_ui32CurrentTime << " > Stopping Visual Stimulation\n";
m_bActive = false;
......
......@@ -15,7 +15,7 @@ namespace OpenViBESSVEPMindShooter
~CGenericStimulatorApplication() override {}
bool setup(OpenViBE::Kernel::IKernelContext* poKernelContext) override;
void setTarget(int32_t i32Target) override;
void setTarget(int i32Target) override;
void startExperiment() override;
void startFlickering() override;
......
......@@ -69,15 +69,14 @@ void ParseStringVector(Ogre::String& str, Ogre::StringVector& list)
{
list.clear();
Ogre::StringUtil::trim(str, true, true);
if (str == "")
return;
if (str == "") { return; }
size_t pos = str.find(";");
size_t pos = str.find(';');
while (pos != -1)
{
list.push_back(str.substr(0, pos));
str.erase(0, pos + 1);
pos = str.find(";");
pos = str.find(';');
}
if (str != "") { list.push_back(str); }
......@@ -965,7 +964,6 @@ void DotSceneLoader::processEntity(rapidxml::xml_node<>* XMLNode, Ogre::SceneNod
void DotSceneLoader::processSubEntity(rapidxml::xml_node<>* XMLNode, Ogre::Entity* pEntity)
{
int index = 0;
Ogre::String materialName;
Ogre::String sIndex;
......@@ -982,7 +980,7 @@ void DotSceneLoader::processSubEntity(rapidxml::xml_node<>* XMLNode, Ogre::Entit
if (!sIndex.empty() && !materialName.empty())
{
index = Ogre::StringConverter::parseInt(sIndex);
int index = Ogre::StringConverter::parseInt(sIndex);
try
{
pEntity->getSubEntity(index)->setMaterialName(materialName);
......@@ -1157,26 +1155,18 @@ void DotSceneLoader::processFog(rapidxml::xml_node<>* XMLNode)
Ogre::Real linearStart = getAttribReal(XMLNode, "start", 0.0);
Ogre::Real linearEnd = getAttribReal(XMLNode, "end", 1.0);
Ogre::FogMode mode = Ogre::FOG_NONE;
Ogre::FogMode mode;
Ogre::String sMode = getAttrib(XMLNode, "mode");
if (sMode == "none")
mode = Ogre::FOG_NONE;
else if (sMode == "exp")
mode = Ogre::FOG_EXP;
else if (sMode == "exp2")
mode = Ogre::FOG_EXP2;
else if (sMode == "linear")
{
mode = Ogre::FOG_LINEAR;
}
else
mode = (Ogre::FogMode)Ogre::StringConverter::parseInt(sMode);
if (sMode == "none") mode = Ogre::FOG_NONE;
else if (sMode == "exp") mode = Ogre::FOG_EXP;
else if (sMode == "exp2") mode = Ogre::FOG_EXP2;
else if (sMode == "linear") { mode = Ogre::FOG_LINEAR; }
else mode = (Ogre::FogMode)Ogre::StringConverter::parseInt(sMode);
// Process colourDiffuse (?)
Ogre::ColourValue colourDiffuse = Ogre::ColourValue::White;
rapidxml::xml_node<>* pElement = XMLNode->first_node("colour");
if (pElement)
colourDiffuse = parseColour(pElement);
if (pElement) colourDiffuse = parseColour(pElement);
// Setup the fog
m_pSceneMgr->setFog(mode, colourDiffuse, expDensity, linearStart, linearEnd);
......
......@@ -180,6 +180,7 @@ void CCommandControlAnalog::commandeerShip(const double* pProbs)
}
if (l_f64Sum <= 0) { l_f64Sum = 1; }
/*
const bool l_bParalyzed = false;
if (l_bParalyzed)
{
......@@ -196,6 +197,7 @@ void CCommandControlAnalog::commandeerShip(const double* pProbs)
return;
}
*/
// In principle here we could do different things with the probabilities. If we predict just the
// maximum, this can be expected to be identical to the Classifier Processor box label output,
......@@ -223,12 +225,12 @@ void CCommandControlAnalog::commandeerShip(const double* pProbs)
else if (l_ui32MaxIdx == MOVE_LEFT && m_poApplication->getShip()->getTargetState(1) != CImpactShip::TS_OFF)
{
m_vCommandStates[1] = 1;
l_poShip->move(static_cast<int>(-6 * l_f64Strength));
l_poShip->move(int(-6 * l_f64Strength));
}
else if (l_ui32MaxIdx == MOVE_RIGHT && m_poApplication->getShip()->getTargetState(2) != CImpactShip::TS_OFF)
{
m_vCommandStates[2] = 1;
l_poShip->move(static_cast<int>(6 * l_f64Strength));
l_poShip->move(int(6 * l_f64Strength));
}
/*
......
......@@ -23,6 +23,7 @@ void CCommandControlDiscrete::execute(int iButton, int iState)
CImpactApplication* l_poImpactApplication = dynamic_cast<CImpactApplication*>(m_poApplication);
/*
const bool l_bParalyzed = false;
if (l_bParalyzed)
{
......@@ -39,6 +40,7 @@ void CCommandControlDiscrete::execute(int iButton, int iState)
return;
}
*/
switch (iButton)
{
......
......@@ -48,37 +48,37 @@ bool CImpactApplication::setup(IKernelContext* poKernelContext)
{
if (!CApplication::setup(poKernelContext)) { return false; }
IConfigurationManager* l_poConfigurationManager = &(m_kernelContext->getConfigurationManager());
IConfigurationManager* configurationManager = &(m_kernelContext->getConfigurationManager());
if (m_sApplicationSubtype == CString("shooter"))
{
// A config file appended for the online session
const CString l_sConfigFile = m_ScenarioDir + "/appconf/shooter-configuration.conf";
if (!l_poConfigurationManager->addConfigurationFromFile(l_sConfigFile))
const CString configFile = m_ScenarioDir + "/appconf/shooter-configuration.conf";
if (!configurationManager->addConfigurationFromFile(configFile))
{
this->getLogManager() << LogLevel_Error << "Unable to open [" << l_sConfigFile << "]. Has the shooter-controller.lua been run?\n";
this->getLogManager() << LogLevel_Error << "Unable to open [" << configFile << "]. Has the shooter-controller.lua been run?\n";
return false;
}
}
const uint64_t l_ui64LogLevel = poKernelContext->getTypeManager().getEnumerationEntryValueFromName(OV_TypeId_LogLevel, l_poConfigurationManager->expand("${SSVEP_LogLevel}"));
this->getLogManager() << LogLevel_Info << "Parsed loglevel is " << l_ui64LogLevel << "\n";
if (l_ui64LogLevel != 0xffffffffffffffffLL)
const uint64_t logLevel = poKernelContext->getTypeManager().getEnumerationEntryValueFromName(OV_TypeId_LogLevel, configurationManager->expand("${SSVEP_LogLevel}"));
this->getLogManager() << LogLevel_Info << "Parsed loglevel is " << logLevel << "\n";
if (logLevel != 0xffffffffffffffffLL)
{
poKernelContext->getLogManager().activate(ELogLevel(l_ui64LogLevel), LogLevel_Last, true);
poKernelContext->getLogManager().activate(ELogLevel(logLevel), LogLevel_Last, true);
}
ILogListener* l_poLogListenerFileBuffered = new CLogListenerFileBuffered(*poKernelContext, "ssvep-mind-shooter-stimulator",
l_poConfigurationManager->expand("${SSVEP_UserDataFolder}/mind-shooter-[$core{date}-$core{time}]-app.log"));
poKernelContext->getLogManager().addListener(l_poLogListenerFileBuffered);
ILogListener* logListenerFileBuffered = new CLogListenerFileBuffered(*poKernelContext, "ssvep-mind-shooter-stimulator",
configurationManager->expand("${SSVEP_UserDataFolder}/mind-shooter-[$core{date}-$core{time}]-app.log"));
poKernelContext->getLogManager().addListener(logListenerFileBuffered);
m_poSceneLoader = new DotSceneLoader();
std::stringstream l_sEnemyOrder;
l_sEnemyOrder << l_poConfigurationManager->expand("${SSVEP_EnemyOrder}");
l_sEnemyOrder << configurationManager->expand("${SSVEP_EnemyOrder}");
(*m_logManager) << LogLevel_Info << "Enemy order: " << l_poConfigurationManager->expand("${SSVEP_EnemyOrder}") << "\n";
(*m_logManager) << LogLevel_Info << "Enemy order: " << configurationManager->expand("${SSVEP_EnemyOrder}") << "\n";
while (l_sEnemyOrder.peek() != EOF)
{
......@@ -90,14 +90,14 @@ bool CImpactApplication::setup(IKernelContext* poKernelContext)
(*m_logManager) << LogLevel_Debug << "Adding Impact game resources\n";
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact")).toASCIIString(), "FileSystem", "SSVEPImpact", true);
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/battleship")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/battleship-destroyed")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/enemy1")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/enemy2")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/enemy3")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/ships")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(l_poConfigurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/starsky")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact")).toASCIIString(), "FileSystem", "SSVEPImpact", true);
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/battleship")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/battleship-destroyed")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/enemy1")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/enemy2")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/enemy3")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/ships")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().addResourceLocation(CString(configurationManager->expand("${Path_Data}/applications/${SSVEP_MindShooterFolderName}/resources/impact/starsky")).toASCIIString(), "FileSystem", "SSVEPImpact");
ResourceGroupManager::getSingleton().initialiseResourceGroup("SSVEPImpact");
setupScene();
......@@ -105,11 +105,11 @@ bool CImpactApplication::setup(IKernelContext* poKernelContext)
// Create the StarShip object
(*m_logManager) << LogLevel_Debug << "+ m_poShip = new CStarShip(...)\n";
m_poShip = new CImpactShip(this, m_sceneNode, &m_frequencies);
m_poShip->activatePilotAssist(l_poConfigurationManager->expandAsBoolean("${SSVEP_PilotAssist}"));
m_poShip->activateTargetLockdown(l_poConfigurationManager->expandAsBoolean("${SSVEP_TargetLockdown}") && (m_sApplicationSubtype == CString("shooter")));
m_poShip->activatePilotAssist(configurationManager->expandAsBoolean("${SSVEP_PilotAssist}"));
m_poShip->activateTargetLockdown(configurationManager->expandAsBoolean("${SSVEP_TargetLockdown}") && (m_sApplicationSubtype == CString("shooter")));
m_poShip->setFeedbackLevels(0, 0, 0);
m_poShip->activateFeedback(l_poConfigurationManager->expandAsBoolean("${SSVEP_Feedback}") && (m_sApplicationSubtype == CString("shooter")));
m_poShip->activateFocusPoint(l_poConfigurationManager->expandAsBoolean("${SSVEP_FocusPoint}"));
m_poShip->activateFeedback(configurationManager->expandAsBoolean("${SSVEP_Feedback}") && (m_sApplicationSubtype == CString("shooter")));
m_poShip->activateFocusPoint(configurationManager->expandAsBoolean("${SSVEP_FocusPoint}"));
// Initialize the Target class
......@@ -156,7 +156,7 @@ bool CImpactApplication::setup(IKernelContext* poKernelContext)
}
else
{
if (l_poConfigurationManager->expandAsBoolean("${SSVEP_OneByOne}", false))
if (configurationManager->expandAsBoolean("${SSVEP_OneByOne}", false))
{
(*m_logManager) << LogLevel_Debug << "+ addCommand(new CCommandTargetControl(...)\n";
this->addCommand(new CCommandImpactTargetControl(this));
......@@ -167,7 +167,7 @@ bool CImpactApplication::setup(IKernelContext* poKernelContext)
this->addCommand(new CCommandImpactCustomTargetControl(this));
}
const bool l_bAnalogControls = l_poConfigurationManager->expandAsBoolean("${SSVEP_AnalogControl}", false);
const bool l_bAnalogControls = configurationManager->expandAsBoolean("${SSVEP_AnalogControl}", false);
(*m_logManager) << LogLevel_Debug << "+ addCommand(new CCommandControlAnalog(...))\n";
this->addCommand(new CCommandControlAnalog(this, l_bAnalogControls));
......@@ -384,6 +384,7 @@ void CImpactApplication::addTarget(uint32_t ui32TargetPosition)
m_poInstructionWindow->setText("Focus on the RIGHT WING to turn the ship to the right");
this->m_StimulusSender->sendStimulation(OVTK_StimulationId_Label_03);
break;
default: break;
}
m_poInstructionWindow->setSize(CEGUI::USize(CEGUI::UDim(l_fTextSize, 0), CEGUI::UDim(0.10f, 0)));
......@@ -415,14 +416,14 @@ void CImpactApplication::insertEnemy(int ui32TargetPosition)
void CImpactApplication::startFlickering()
{
m_poInstructionWindow->hide();
uint32_t l_ui32CurrentTime = (uint32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = uint32_t(time(nullptr) - m_ttStartTime);
(*m_logManager) << LogLevel_Info << l_ui32CurrentTime << " > Starting Visual Stimulation\n";
m_bActive = true;
}
void CImpactApplication::stopFlickering()
{
uint32_t l_ui32CurrentTime = (uint32_t)(time(nullptr) - m_ttStartTime);
uint32_t l_ui32CurrentTime = uint32_t(time(nullptr) - m_ttStartTime);
(*m_logManager) << LogLevel_Info << l_ui32CurrentTime << " > Stopping Visual Stimulation\n";
m_bActive = false;
m_poShip->setAllTargetsVisibility(true);
......
......@@ -33,9 +33,6 @@ CImpactEnemyShip* CImpactEnemyShip::createTarget(Real rPosition)
}
CImpactEnemyShip::CImpactEnemyShip(Real rPosition)
: m_shipWidth(0.1f),
m_destructionStatus(0),
m_pointValue(100)
{
m_bEnemyLeaving = false;
int l_iType = m_application->getNextTargetType();
......@@ -51,7 +48,7 @@ CImpactEnemyShip::CImpactEnemyShip(Real rPosition)
m_enemyNode = m_application->getSceneManager()->getSceneNode("v2_vaisseau");
m_enemyNode->scale(1.0f, 1.0f, 1.0f);
m_shipWidth = 0.5f;
m_iLeaveCountdown = (int)(2.0f * 3600);
m_iLeaveCountdown = int(2.0f * 3600);
m_pointValue = 100;
break;
case 2:
......@@ -60,7 +57,7 @@ CImpactEnemyShip::CImpactEnemyShip(Real rPosition)
m_enemyNode = m_application->getSceneManager()->getSceneNode("v1_vaisseau");
m_enemyNode->scale(1.9f, 1.9f, 1.9f);
m_shipWidth = 0.45f;
m_iLeaveCountdown = (int)(1.5f * 3600);
m_iLeaveCountdown = int(1.5f * 3600);
m_pointValue = 200;
break;
case 3:
......@@ -69,7 +66,7 @@ CImpactEnemyShip::CImpactEnemyShip(Real rPosition)
m_enemyNode = m_application->getSceneManager()->getSceneNode("v3_vaisseau");
m_enemyNode->scale(2.2f, 2.0f, 2.0f);
m_shipWidth = 0.4f;
m_iLeaveCountdown = (int)(1.0f * 3600);
m_iLeaveCountdown = int(1.0f * 3600);
m_pointValue = 400;
break;
case 4:
......@@ -95,7 +92,7 @@ CImpactEnemyShip::CImpactEnemyShip(Real rPosition)
{
m_enemyNode->scale(1.2f, 1.2f, 1.2f);
m_shipWidth = 0.3f;
m_iLeaveCountdown = (int)(1.0f * 3600);
m_iLeaveCountdown = int(1.0f * 3600);
}
......@@ -184,7 +181,7 @@ void CImpactEnemyShip::processFrame()
l_iSinOscillator++;
l_iSinOscillator = l_iSinOscillator % 360;
// m_enemyNode->roll(Radian(Math::Sin(Degree(sin_oscillator)) / 80));
m_enemyNode->translate(Math::Sin(Degree((Real)l_iSinOscillator)) / 20.0f * 0, Math::Sin(Degree((Real)(l_iSinOscillator * 2 + 90))) / 20, 0.0f, Node::TS_LOCAL);
m_enemyNode->translate(Math::Sin(Degree((Real)l_iSinOscillator)) / 20.0f * 0, Math::Sin(Degree(Real(l_iSinOscillator * 2 + 90))) / 20, 0.0f, Node::TS_LOCAL);
m_hitBox->translate(Math::Sin(Degree((Real)l_iSinOscillator)) / 20.0f / 50.0f * 0, 0.0f, 0.0f, Node::TS_LOCAL);
......
......@@ -47,7 +47,6 @@ namespace OpenViBESSVEPMindShooter
Ogre::SceneNode* m_enemyNode = nullptr;
Ogre::SceneNode* m_hitBox = nullptr;
Ogre::SceneNode* m_fragments[4];
Ogre::Real m_incomingStatus = 0;
Ogre::Real m_shipWidth = 0.1f;
Ogre::uint32 m_destructionStatus = 0;
......
......@@ -18,8 +18,7 @@ using namespace OpenViBESSVEPMindShooter;
using namespace Ogre;
//SP CImpactShip::CImpactShip(CImpactApplication* poApplication, Ogre::SceneNode* poParentNode, std::vector<std::pair<uint32_t, uint32_t> >* pFrequencies) :
CImpactShip::CImpactShip(CImpactApplication* poApplication, SceneNode* poParentNode, std::vector<uint64_t>* pFrequencies) : m_application(poApplication),
m_currentAngle(0)
CImpactShip::CImpactShip(CImpactApplication* poApplication, SceneNode* poParentNode, std::vector<uint64_t>* pFrequencies) : m_application(poApplication), m_currentAngle(0)
{
m_application->getLogManager() << OpenViBE::Kernel::LogLevel_Info << "Loading ship\n";
......
......@@ -79,9 +79,7 @@ namespace OpenViBESSVEPMindShooter
bool m_focusPointActive = false;
bool m_cannonInhibited = false;
Ogre::Real m_angularSpeed = 0;
Ogre::Radian m_currentAngle = 0;
int m_currentRotationCount = 0;
int m_currentDisplacementCount = 0;
int m_shootingCooldown = 0;
......
......@@ -11,9 +11,8 @@ using namespace Kernel;
using namespace std;
CLogListenerFileBuffered::CLogListenerFileBuffered(const IKernelContext& rKernelContext, const CString& sApplicationName, const CString& sLogFilename)
: m_sApplicationName(sApplicationName)
, m_sLogFilename(sLogFilename)
CLogListenerFileBuffered::CLogListenerFileBuffered(const IKernelContext& context, const CString& applicationName, const CString& logFilename)
: m_sApplicationName(applicationName), m_sLogFilename(logFilename)
{
m_f = fopen(m_sLogFilename.toASCIIString(), "wt");
if (m_f == nullptr)
......@@ -24,8 +23,7 @@ CLogListenerFileBuffered::CLogListenerFileBuffered(const IKernelContext& rKernel
CLogListenerFileBuffered::~CLogListenerFileBuffered()
{
if (m_f != nullptr)
fclose(m_f);
if (m_f != nullptr) { fclose(m_f); }
}
bool CLogListenerFileBuffered::isActive(ELogLevel eLogLevel)
......@@ -82,7 +80,7 @@ void CLogListenerFileBuffered::log(const int64_t value)
if (m_f != nullptr) { fprintf(m_f, "%lli", value); }
}
void CLogListenerFileBuffered::log(const int32_t value)
void CLogListenerFileBuffered::log(const int value)
{
if (m_f != nullptr) {fprintf(m_f, "%i", value); }
}
......
......@@ -16,7 +16,7 @@ namespace OpenViBE
{
public:
CLogListenerFileBuffered(const IKernelContext& rKernelContext, const CString& sApplicationName, const CString& sLogFilename);
CLogListenerFileBuffered(const IKernelContext& context, const CString& applicationName, const CString& logFilename);
~CLogListenerFileBuffered() override;
bool isActive(ELogLevel eLogLevel) override;
......@@ -32,7 +32,7 @@ namespace OpenViBE
void log(const uint8_t value) override;
void log(const int64_t value) override;
void log(const int32_t value) override;
void log(const int value) override;
void log(const int16_t value) override;
void log(const int8_t value) override;
......
......@@ -148,7 +148,7 @@ bool CApplication::setup(IKernelContext* poKernelContext)
// create the vector of stimulation frequencies
m_screenRefreshRate = (uint32_t)(l_poConfigurationManager->expandAsUInteger("${SSVEP_ScreenRefreshRate}", 60));
m_screenRefreshRate = uint32_t(l_poConfigurationManager->expandAsUInteger("${SSVEP_ScreenRefreshRate}", 60));
(*m_logManager) << LogLevel_Info << "Specified screen refresh rate :" << m_screenRefreshRate << "Hz\n";
if (m_screenRefreshRate > 64)
......@@ -172,7 +172,7 @@ bool CApplication::setup(IKernelContext* poKernelContext)
// Load pre-defined stimulation patterns (binary encoded dark/light frames inside a 64bit integer)
while (l_poConfigurationManager->lookUpConfigurationTokenIdentifier(l_poConfigurationManager->expand("SSVEP_Pattern_${SSVEP_FrequencyId}")) != OV_UndefinedIdentifier)
{
uint64_t l_ui64StimulationPattern = (uint64_t)(l_poConfigurationManager->expandAsInteger("${SSVEP_Pattern_${SSVEP_FrequencyId}}"));
uint64_t l_ui64StimulationPattern = uint64_t(l_poConfigurationManager->expandAsInteger("${SSVEP_Pattern_${SSVEP_FrequencyId}}"));
(*m_logManager) << LogLevel_Info << "Pattern number " << i << " pattern : " << l_ui64StimulationPattern << "\n";
m_frequencies[i] = l_ui64StimulationPattern;
......@@ -192,11 +192,11 @@ bool CApplication::setup(IKernelContext* poKernelContext)
// Load frequencies
while (l_poConfigurationManager->lookUpConfigurationTokenIdentifier(l_poConfigurationManager->expand("SSVEP_Frequency_${SSVEP_FrequencyId}")) != OV_UndefinedIdentifier)
{
const double l_f64CurrentFrequency = (double)(l_poConfigurationManager->expandAsFloat("${SSVEP_Frequency_${SSVEP_FrequencyId}}"));
const double l_f64CurrentFrequency = double(l_poConfigurationManager->expandAsFloat("${SSVEP_Frequency_${SSVEP_FrequencyId}}"));
const double l_f64ApproximatedFrameCount = m_screenRefreshRate / l_f64CurrentFrequency;
const uint32_t l_ui32RoundedFrameCount = static_cast<uint32_t>(floor(l_f64ApproximatedFrameCount + 0.5));
const uint32_t l_ui32RoundedFrameCount = uint32_t(floor(l_f64ApproximatedFrameCount + 0.5));
// test if the desired frequency can be reasonably created on the screen
if (fabs(l_f64ApproximatedFrameCount - l_ui32RoundedFrameCount) < 0.003)
......
......@@ -24,6 +24,6 @@ namespace OpenViBESSVEPMindShooter
void updateCamera();
std::map<OIS::KeyCode, bool> m_vKeyPressed;
bool m_bCameraMode = 0;
bool m_bCameraMode = false;
};
}
......@@ -16,10 +16,10 @@ CVRPNServer::CVRPNServer(CApplication* poApplication)
{
m_poApplication = poApplication;
int l_iPort = (int32_t)(m_poApplication->getConfigurationManager()->expandAsInteger("${VRPN_ExternalServerPort}"));
int port = int(m_poApplication->getConfigurationManager()->expandAsInteger("${VRPN_ExternalServerPort}"));
m_poApplication->getLogManager() << LogLevel_Debug << "VRPN SERVER PORT :" << l_iPort << "\n";
m_poConnection = vrpn_create_server_connection(l_iPort);
m_poApplication->getLogManager() << LogLevel_Debug << "VRPN SERVER PORT :" << port << "\n";
m_poConnection = vrpn_create_server_connection(port);
}
CVRPNServer* CVRPNServer::getInstance(CApplication* poApplication)
......
......@@ -14,7 +14,7 @@ namespace
{
void VRPN_CALLBACK ssvep_vrpn_callback_analog(void* command, vrpn_ANALOGCB analog)
{
((ICommandVRPNAnalog*)command)->execute(analog.num_channel, analog.channel);
static_cast<ICommandVRPNAnalog*>(command)->execute(analog.num_channel, analog.channel);
}
}
......
......@@ -14,7 +14,7 @@ namespace
{
void VRPN_CALLBACK ssvep_vrpn_callback_button(void* command, vrpn_BUTTONCB button)
{
((ICommandVRPNButton*)command)->execute(button.button, button.state);
static_cast<ICommandVRPNButton*>(command)->execute(button.button, button.state);
}
}
......
......@@ -36,7 +36,6 @@ int main(int argc, char** argv)
Kernel::IKernelDesc* l_poKernelDesc = nullptr;
Kernel::IKernelContext* l_poKernelContext = nullptr;
Kernel::ILogManager* l_poLogManager = nullptr;
Kernel::IConfigurationManager* l_poConfigurationManager = nullptr;
CString l_sApplicationString = CString(argv[1]);
CString l_sScenarioFolder = CString(argv[2]);
......@@ -100,7 +99,7 @@ int main(int argc, char** argv)
OpenViBEToolkit::initialize(*l_poKernelContext);
l_poConfigurationManager = &(l_poKernelContext->getConfigurationManager());
Kernel::IConfigurationManager* l_poConfigurationManager = &(l_poKernelContext->getConfigurationManager());
l_poConfigurationManager->addConfigurationFromFile(l_poConfigurationManager->expand("${Path_Data}/kernel/openvibe.conf"));
/*
l_poConfigurationManager->createConfigurationToken("SSVEP_ApplicationDescriptor", CString(argv[1]));
......@@ -129,19 +128,19 @@ int main(int argc, char** argv)
}
OpenViBESSVEPMindShooter::CApplication* l_pApp = nullptr;
OpenViBESSVEPMindShooter::CApplication* app;
if (l_sApplicationType == CString("generic"))
{
(*l_poLogManager) << Kernel::LogLevel_Debug << "+ app = new OpenViBESSVEPMindShooter::CGenericStimulatorApplication(...)\n";
l_pApp = new OpenViBESSVEPMindShooter::CGenericStimulatorApplication(l_sScenarioFolder);
app = new OpenViBESSVEPMindShooter::CGenericStimulatorApplication(l_sScenarioFolder);
}
else if (l_sApplicationType == CString("impact"))
{
(*l_poLogManager) << Kernel::LogLevel_Debug << "+ app = new OpenViBESSVEPMindShooter::CImpactApplication(...)\n";
(*l_poLogManager) << Kernel::LogLevel_Info << "application subtype " << l_sApplicationSubtype << "\n";
l_pApp = new OpenViBESSVEPMindShooter::CImpactApplication(l_sScenarioFolder, l_sApplicationSubtype);
app = new OpenViBESSVEPMindShooter::CImpactApplication(l_sScenarioFolder, l_sApplicationSubtype);
}
else
{
......@@ -150,18 +149,18 @@ int main(int argc, char** argv)
exit(1);
}
if (!l_pApp->setup(l_poKernelContext))
if (!app->setup(l_poKernelContext))
{
(*l_poLogManager) << Kernel::LogLevel_Error << "Cannot proceed, exiting\n";
exit(2);
}
l_pApp->go();
app->go();
(*l_poLogManager) << Kernel::LogLevel_Debug << "- app\n";
delete l_pApp;
delete app;
return 0;
}
......@@ -172,7 +171,7 @@ int main(int argc, char** argv)
int main(int argc, char** argv)
{
printf("SSVEP Mind Shooter has not been compiled as it depends on Ogre (missing/disabled)\n");
std::cout << "SSVEP Mind Shooter has not been compiled as it depends on Ogre (missing/disabled)\n";
return -1;
}
......
......@@ -286,6 +286,7 @@ bool CHandballBCI::process(double timeSinceLastProcess)
std::cout << std::endl;*/
break;
default: break;
}
}
......@@ -316,6 +317,7 @@ bool CHandballBCI::process(double timeSinceLastProcess)
if (m_iMark == Mark_Right && m_dFeedback > 0) { m_iClassificationScore++; }
break;
default: break;
}
m_fBallOrientation += m_fBallSpeed;
......
......@@ -57,7 +57,7 @@ namespace OpenViBEVRDemos
int m_iMark = 0;
int m_iLastMark = 0;
bool m_bGoalMarkedAtThisPhase = 0;
bool m_bGoalMarkedAtThisPhase = false;
float m_fBallSpeed = 0;
float m_fBallPosition = 0; // n.b. The coordinate system of this seems to be inverted wrt the [-left,+right] convention
......
......@@ -577,7 +577,7 @@ void CSpaceshipBCI::processStageFreetime(double timeSinceLastProcess)
m_vShipOrientation[0] += g_fRotationSpeed * ((rand() & 1) == 0 ? -1 : 1);
m_vShipOrientation[1] += g_fRotationSpeed * ((rand() & 1) == 0 ? -1 : 1);
m_vShipOrientation[2] += g_fRotationSpeed * ((rand() & 1) == 0 ? -1 : 1);
m_fShipHeight += (float)((m_dFeedback - m_dBetaOffset) * g_fMoveSpeed);
m_fShipHeight += float((m_dFeedback - m_dBetaOffset) * g_fMoveSpeed);
if (m_bShouldIncrementStat) { m_dStat_SpaceshipLiftTime += timeSinceLastProcess; }
if (m_vShipOrientation[0] > 5) { m_vShipOrientation[0] = 5; }
......
......@@ -11,8 +11,8 @@ class CDeviceInfo
public:
std::string m_sAddress;
vrpn_Button_Remote* m_pButton;
vrpn_Analog_Remote* m_pAnalog;
vrpn_Button_Remote* m_pButton = nullptr;
vrpn_Analog_Remote* m_pAnalog = nullptr;
};
namespace
......
......@@ -18,11 +18,10 @@ int main(int argc, char** argv)
{
if (argc < 2)
{
printf("Syntax: %s demo-name\n", argv[0]);
printf("\n");
printf("where demo-name could be one of the following :\n");
printf(" - spaceship\n");
printf(" - handball\n");
std::cout << "Syntax: " << argv[0] << " demo-name\n\n";
std::cout << "where demo-name could be one of the following :\n";
std::cout << " - spaceship\n";
std::cout << " - handball\n";
return 1;
}
......@@ -32,39 +31,39 @@ int main(int argc, char** argv)
std::string l_slocalization = "eng";
if (argc != 3)
{
printf("No language selected. Default is: english (eng).\n\n");
std::cout << "No language selected. Default is: english (eng).\n\n";
}
else
{
l_slocalization = argv[2];
printf("User defined language: l_slocalization \n");
printf("WARNING: if the language keyword is not found, default language will be loaded (eng).\n\n");
std::cout << "User defined language: " << l_slocalization << "\n";
std::cout << "WARNING: if the language keyword is not found, default language will be loaded (eng).\n\n";
}
printf("\n");
std::cout << std::endl;
printf(" ___ _.'\\ /'._ ___ \n");
printf("/ b__--- | .'\"'. | ---__d \\\n");
printf("\\ p\"\"---_| '._.' |_---\"\"q /\n");
printf(" / / ./ \\. \\ \\ \n");
printf(" / / '---' \\ \\ \n");
printf(" /_/ \\_\\ \n");
printf(" \n\n");
printf("Application started! Lift 'em!\n\n");
std::cout << " ___ _.'\\ /'._ ___ \n";
std::cout << "/ b__--- | .'\"'. | ---__d \\\n";
std::cout << "\\ p\"\"---_| '._.' |_---\"\"q /\n";
std::cout << " / / ./ \\. \\ \\ \n";
std::cout << " / / '---' \\ \\ \n";
std::cout << " /_/ \\_\\ \n";
std::cout << " \n\n";
std::cout << "Application started! Lift 'em!\n\n";
app = new OpenViBEVRDemos::CSpaceshipBCI(l_slocalization);
}
else if (strcmp(argv[1], "handball") == 0)
{
printf("Handball application started !\n");
std::cout << "Handball application started !\n";
app = new OpenViBEVRDemos::CHandballBCI();
}
else
{
printf("ERROR: the application specified does not exist (%s).\n", argv[1]);
printf("Please use one of the following applications:\n");
printf(" - spaceship\n");
printf(" - handball\n");
std::cout << "ERROR: the application specified does not exist (" << argv[1] << ").\n";
std::cout << "Please use one of the following applications:\n";
std::cout << " - spaceship\n";
std::cout << " - handball\n";
return 2;
}
......@@ -79,7 +78,7 @@ int main(int argc, char** argv)
int main(int argc, char** argv)
{
printf("VR demo has not been compiled as it depends on Ogre (missing/disabled)\n");
std::cout << "VR demo has not been compiled as it depends on Ogre (missing/disabled)\n";
return -1;
}
......
......@@ -100,7 +100,7 @@ bool C3DEntityManipulator::processEvent(OMK::Event* pEvent)
if(l_pEvent)
{
const VrpnButtonState& l_rVrpnButtonState=l_pEvent->value;
if(l_rVrpnButtonState.first<(int)(sizeof(m_bButton)/sizeof(m_bButton[0])))
if(l_rVrpnButtonState.first<int(sizeof(m_bButton)/sizeof(m_bButton[0])))
{
m_bButton[l_rVrpnButtonState.first]=(l_rVrpnButtonState.second?true:false);
}
......
......@@ -56,7 +56,7 @@ void CManipulable3DEntity::compute()
if(l_iDelta>duration-fadeout)
{
double l_dCoef=(l_iDelta-duration+fadeout)/(double)(fadeout); // 0-1
double l_dCoef=(l_iDelta-duration+fadeout)/double(fadeout); // 0-1
double l_dRotation=3*180*pow(l_dCoef, 4);
m_oOrientation[0]=l_dRotation;
m_oOrientation[1]=3*l_dRotation*sin(M_PI*pow(l_dCoef, 3)*2);
......
......@@ -34,7 +34,7 @@ void CNeurofeedbackScoreCounter::init()
void CNeurofeedbackScoreCounter::compute()
{
double l_dSpeed=.01;
m_oScale=(float)l_dSpeed*m_oScaleTarget+(float)(1-l_dSpeed)*m_oScale;
m_oScale=(float)l_dSpeed*m_oScaleTarget+float(1-l_