From df40de3b564062c1bba93332d08e86f3691e6b00 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 23 Aug 2010 17:56:37 +0000 Subject: Added output of XML file with universe states per tick. --- config.cpp | 12 +++++++++++- config.h | 6 +++++- dat | 5 +++++ depend.mak | 8 +++++--- glgrav.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test1.dat | 4 +++- test2.dat | 2 ++ 7 files changed, 84 insertions(+), 6 deletions(-) diff --git a/config.cpp b/config.cpp index 5c74954..a2fc3a8 100644 --- a/config.cpp +++ b/config.cpp @@ -733,6 +733,10 @@ bool Config::read(const string& fname,vector& mass) m_fog_light=toYesNo(arg[4]); break; + case output_cmd: + m_output = arg[0]; + break; + default: break; } @@ -873,6 +877,12 @@ string Config::error() const } +const string& Config::output() const +{ + return m_output; +} + + // ---------------------------------------- PRIVATE MEMBERS // bool Config::CompareNoCase(const string& s1, const string& s2) @@ -1032,6 +1042,7 @@ bool Config::getCommand(ifstream& file, Config::Command& cmd, {"ring_reuse",ring_reuse_cmd,2}, {"ring_mreuse",ring_mreuse_cmd,3}, {"fog",fog_cmd,5}, + {"output",output_cmd,1}, {"",cmd_error,1} }; @@ -1295,5 +1306,4 @@ string Config::makeName(string& name, int no) return n; } - // END OF FILE // diff --git a/config.h b/config.h index ea0fcc9..1b80dc2 100644 --- a/config.h +++ b/config.h @@ -66,6 +66,8 @@ public: size_t maxMass() const; + const string& output() const; + // Args set to -1 if undefined // void getLookAndTravel(int& look, int &travel) const; @@ -141,6 +143,8 @@ private: GLfloat m_fog_b; bool m_fog_light; + string m_output; + enum Command {enable_cmd, disable_cmd, collide_cmd, const_cmd, body_cmd, radial_cmd, light_cmd, camera_cmd, look_cmd, texture_cmd, num_texture_cmd, reuse_cmd, particles_cmd, @@ -148,7 +152,7 @@ private: scale_cmd, look_at_cmd, travel_as_cmd, window_size_cmd, sparks_cmd, max_mass_cmd, mlook_cmd, ring_cmd, mring_cmd, ring_texture_cmd, ring_reuse_cmd, - ring_mreuse_cmd, fog_cmd, + ring_mreuse_cmd, fog_cmd, output_cmd, cmd_eof, cmd_error}; enum GetWordStatus {GWOK, GWEof, GWSyntax, diff --git a/dat b/dat index 47b7d65..26cbc48 100644 --- a/dat +++ b/dat @@ -347,3 +347,8 @@ sparks 50,0.01,0.0,5,2.0; # light - Whether the light source is effected by fog (yes/no) # fog 1000.0,0.2,0.0,0.0,no; + + +# Record the state into the following XML file +# +output output.xml; diff --git a/depend.mak b/depend.mak index cac346a..86bde45 100644 --- a/depend.mak +++ b/depend.mak @@ -1,5 +1,7 @@ -glgrav.o: glgrav.cpp global.h config.h mass.h particles.h sparks.h -mass.o: mass.cpp mass.h global.h -config.o: config.cpp config.h global.h mass.h +glgrav.o: glgrav.cpp global.h config.h mass.h vec3d.h particles.h \ + sparks.h +mass.o: mass.cpp mass.h global.h vec3d.h +config.o: config.cpp config.h global.h mass.h vec3d.h particles.o: particles.cpp particles.h global.h sparks.o: sparks.cpp sparks.h global.h +vec3d.o: vec3d.cpp vec3d.h global.h diff --git a/glgrav.cpp b/glgrav.cpp index 95b00b4..5c08b90 100644 --- a/glgrav.cpp +++ b/glgrav.cpp @@ -83,6 +83,9 @@ static bool fog=false; static bool fog_light=false; static GLfloat fog_col[4]={0.0f,0.0f,0.0f,1.0f}; +static ofstream output; +unsigned long tick; + static struct { GLfloat x,y,z; @@ -180,6 +183,17 @@ int main(int argc, char *argv[]) render_sparks=false; } + if (!config.output().empty()) + { + output.open(config.output().c_str()); + + if (output) + { + output << "" << endl; + output << "" << endl; + } + } + config.windowSize(width,height); width=max(width,100); @@ -414,6 +428,12 @@ static void Menu(int item) break; case MENU_QUIT: + if (output) + { + output << "" << endl; + output.close(); + } + exit(EXIT_SUCCESS); break; } @@ -875,11 +895,44 @@ static void Update(void) new_mass=mass; + if (output) + { + output << "" << endl; + } + for(f=0;f" << endl; + } + del_mass.push_back(false); } + if (output) + { + output << "" << endl; + } + for(f=0;f