diff options
author | Ian C <ianc@noddybox.co.uk> | 2010-08-23 17:56:37 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2010-08-23 17:56:37 +0000 |
commit | df40de3b564062c1bba93332d08e86f3691e6b00 (patch) | |
tree | 1133062c0664a1c3c04b991d1415a431eae821dc | |
parent | af34bad8b39e95276b0d4e08ccdc26f89df2d2ec (diff) |
Added output of XML file with universe states per tick.
-rw-r--r-- | config.cpp | 12 | ||||
-rw-r--r-- | config.h | 6 | ||||
-rw-r--r-- | dat | 5 | ||||
-rw-r--r-- | depend.mak | 8 | ||||
-rw-r--r-- | glgrav.cpp | 53 | ||||
-rw-r--r-- | test1.dat | 4 | ||||
-rw-r--r-- | test2.dat | 2 |
7 files changed, 84 insertions, 6 deletions
@@ -733,6 +733,10 @@ bool Config::read(const string& fname,vector<Mass>& 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 // @@ -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, @@ -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; @@ -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 @@ -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 << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << endl; + output << "<simulation>" << 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 << "</simulation>" << endl; + output.close(); + } + exit(EXIT_SUCCESS); break; } @@ -875,11 +895,44 @@ static void Update(void) new_mass=mass; + if (output) + { + output << "<step tick=\"" << tick++ << "\">" << endl; + } + for(f=0;f<mass.size();f++) { + if (output) + { + GLfloat r,g,b; + double x,y,z; + double dx,dy,dz; + + mass[f].getPosition(x, y, z); + mass[f].getColour(r, g, b); + mass[f].getDelta(dx, dy, dz); + + output << "<mass name=\"" << mass[f].getName() << "\" " + << "r=\"" << r << "\" " + << "g=\"" << g << "\" " + << "b=\"" << b << "\" " + << "x=\"" << x << "\" " + << "y=\"" << y << "\" " + << "z=\"" << z << "\" " + << "dx=\"" << dx << "\" " + << "dy=\"" << dy << "\" " + << "dz=\"" << dz << "\" " + << "/>" << endl; + } + del_mass.push_back(false); } + if (output) + { + output << "</step>" << endl; + } + for(f=0;f<mass.size();f++) { for(r=0;r<mass.size();r++) @@ -7,7 +7,7 @@ enable solid; enable lighting; disable texture; -collide none; +collide shatter; const 1; @@ -51,3 +51,5 @@ look mass2; look_at centre; particles 0.0001,0.0,1.0; + +shatter 10,5.0,1,2000,100; @@ -48,3 +48,5 @@ look mass2; look_at centre; particles 0.001,0.0,1.0; + +output output.xml; |