summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaik Teurlings <mteur@gmx.net>2008-05-28 08:32:53 (GMT)
committerMaik Teurlings <mteur@gmx.net>2008-05-28 08:32:53 (GMT)
commit0d3724db99f586dc252f36ca89502641e58d9887 (patch)
tree31f41e3e9921b9dfd97f449fefaf2eae406fd661
parentec069f23d73cea4ae3db177a62e83a3fc2179347 (diff)
download2iv55-0d3724db99f586dc252f36ca89502641e58d9887.zip
2iv55-0d3724db99f586dc252f36ca89502641e58d9887.tar.gz
2iv55-0d3724db99f586dc252f36ca89502641e58d9887.tar.bz2
Settings
-rw-r--r--matchblox/engine/typedefs.h1
-rw-r--r--matchblox/main.cpp85
-rw-r--r--matchblox/settings.ini13
3 files changed, 96 insertions, 3 deletions
diff --git a/matchblox/engine/typedefs.h b/matchblox/engine/typedefs.h
index 867b85a..9f58998 100644
--- a/matchblox/engine/typedefs.h
+++ b/matchblox/engine/typedefs.h
@@ -175,6 +175,7 @@ typedef struct FrustumParms
double m_dScreenHeightWorld; //the height of the screen (in world coordinates)
double m_dEyeDistMM; //distance between the eyes (in mm)
double m_dDefHeadDistMM; //default distance between head and display (in mm)
+ double m_dSensorbarLedDistMM; //default distance between the leds on the sensorbar
} FrustumParms_t;
typedef enum EyeOrigin {
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;
diff --git a/matchblox/settings.ini b/matchblox/settings.ini
new file mode 100644
index 0000000..f34b3f9
--- /dev/null
+++ b/matchblox/settings.ini
@@ -0,0 +1,13 @@
+[FrustumParameters]
+HeadTrackLedDistance=205.0;
+RadiansPerCameraPixel=0.00069881347003679211576046212410189
+CameraXCenter=1024.0/2.0
+CameraYCenter=768.0/2.0
+YAngleCorrection=0.0
+CameraYOffset=130.0
+ScreenHeightMM=210.0
+ScreenAspect=4.0/3.0
+ScreenHeightWorld=20.0
+EyeDistanceMM=70.0
+DefHeadDistanceMM=1000.0
+SensorbarLedDistanceMM=21.0 \ No newline at end of file