summaryrefslogtreecommitdiff
path: root/glgrav.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2010-08-23 17:56:37 +0000
committerIan C <ianc@noddybox.co.uk>2010-08-23 17:56:37 +0000
commitdf40de3b564062c1bba93332d08e86f3691e6b00 (patch)
tree1133062c0664a1c3c04b991d1415a431eae821dc /glgrav.cpp
parentaf34bad8b39e95276b0d4e08ccdc26f89df2d2ec (diff)
Added output of XML file with universe states per tick.
Diffstat (limited to 'glgrav.cpp')
-rw-r--r--glgrav.cpp53
1 files changed, 53 insertions, 0 deletions
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 << "<?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++)