summaryrefslogtreecommitdiffstats
path: root/matchblox/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'matchblox/main.cpp')
-rw-r--r--matchblox/main.cpp85
1 files changed, 82 insertions, 3 deletions
diff --git a/matchblox/main.cpp b/matchblox/main.cpp
index 3b92a22..528fcc0 100644
--- a/matchblox/main.cpp
+++ b/matchblox/main.cpp
@@ -11,6 +11,7 @@
#include <GL/glew.h>
#include <GL/glut.h>
#include <iostream>
+#include <fstream>
#include <math.h>
@@ -192,12 +193,90 @@ void process_passive_mouse(int x, int y)
MenuMouseMove(x, y);
} // process_passive_mouse
+void load_settings()
+{
+ fstream l_Stream;
+ string l_strLine, l_strValueName, l_strValue;
+ double l_dValue;
+ string::size_type l_posEqualSign,l_posDivideSign;
+ //Open file
+ l_Stream.open("settings.ini");
+ if(!l_Stream.is_open())
+ {
+ std::cout << "Error, settings-file was unable to be opened.";
+ }
+ else
+ {
+ //Go through whole file
+ while(!l_Stream.eof())
+ {
+ getline(l_Stream, l_strLine);
+
+ //Search for =
+ if (( l_posEqualSign = l_strLine.find_first_of("=")) != string::npos)
+ { //found one
+ l_strValueName = l_strLine.substr( 0, l_posEqualSign);
+ l_strValue = l_strLine.substr( l_posEqualSign + 1);
+ l_dValue = (41.0*(M_PI/180.0))/1024.0;
+ //Cast to double
+ if ((l_posDivideSign = l_strValue.find_first_of("/")) != string::npos) //Check if it has a dividesign
+ {
+ l_dValue = atof(l_strValue.substr(0,l_posDivideSign).c_str())/atof(l_strValue.substr(l_posDivideSign+1).c_str());
+ }
+ else
+ {
+ l_dValue = atof(l_strValue.c_str());
+ }
+
+ if (l_strValueName.compare("HeadTrackLedDistance") == 0)
+ g_GameState.m_FrustumParms.m_dHeadTrackLedDist = l_dValue;
+
+ if (l_strValueName.compare("RadiansPerCameraPixel") == 0)
+ g_GameState.m_FrustumParms.m_dRadPerCameraPixel = l_dValue;
+
+ if (l_strValueName.compare("YAngleCorrection") == 0)
+ g_GameState.m_FrustumParms.m_dYAngleCorrection = l_dValue;
+
+ if (l_strValueName.compare("CameraYOffset") == 0)
+ g_GameState.m_FrustumParms.m_dCameraYOffset = l_dValue;
+
+ if (l_strValueName.compare("ScreenHeightMM") == 0)
+ g_GameState.m_FrustumParms.m_dScreenHeightMM = l_dValue;
+
+ if (l_strValueName.compare("ScreenHeightWorld") == 0)
+ g_GameState.m_FrustumParms.m_dScreenHeightWorld = l_dValue;
+
+ if (l_strValueName.compare("EyeDistanceMM") == 0)
+ g_GameState.m_FrustumParms.m_dEyeDistMM = l_dValue;
+
+ if (l_strValueName.compare("DefHeadDistanceMM") == 0)
+ g_GameState.m_FrustumParms.m_dDefHeadDistMM = l_dValue;
+
+ if (l_strValueName.compare("CameraXCenter") == 0)
+ g_GameState.m_FrustumParms.m_dCameraXCenter = l_dValue;
+
+ if (l_strValueName.compare("CameraYCenter") == 0)
+ g_GameState.m_FrustumParms.m_dCameraYCenter = l_dValue;
+
+ if (l_strValueName.compare("ScreenAspect") == 0)
+ g_GameState.m_FrustumParms.m_dScreenAspect = l_dValue;
+
+ if (l_strValueName.compare("SensorbarLedDistanceMM") == 0)
+ g_GameState.m_FrustumParms.m_dSensorbarLedDistMM = l_dValue;
+ }//end found =-sign
+ }//end while
+
+ l_Stream.close();
+ }
+}
int main(int argc, char **argv)
{
messageq_init();
+ load_settings();
+
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
//glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT);
@@ -227,8 +306,8 @@ int main(int argc, char **argv)
MenuInit(SCREEN_WIDTH, SCREEN_HEIGHT);
InitWiiMotes();
- // initialise the stereo vision parameters << should be loaded from a textfile
- g_GameState.m_FrustumParms.m_dEyeDistMM = 70.0; //7 cm
+ // initialise the stereo vision parameters << should be loaded from a textfile IS DONE
+/* g_GameState.m_FrustumParms.m_dEyeDistMM = 70.0; //7 cm
g_GameState.m_FrustumParms.m_dDefHeadDistMM = 1000.0; //100 cm
g_GameState.m_FrustumParms.m_dHeadTrackLedDist = 205.0;
g_GameState.m_FrustumParms.m_dRadPerCameraPixel = (41.0*(M_PI/180.0))/1016.0;
@@ -238,7 +317,7 @@ int main(int argc, char **argv)
g_GameState.m_FrustumParms.m_dScreenHeightWorld = 20.0;
g_GameState.m_FrustumParms.m_dCameraYOffset = 130.0;
g_GameState.m_FrustumParms.m_dScreenHeightMM = 2100.0;
- g_GameState.m_FrustumParms.m_dScreenAspect = 4.0/3.0;
+ g_GameState.m_FrustumParms.m_dScreenAspect = 4.0/3.0;*/
g_GameState.m_GSConvScale[0] = 0.299;
g_GameState.m_GSConvScale[1] = 0.587;
g_GameState.m_GSConvScale[2] = 0.114;