Index: branches/simulator/lib/bin/libsim.a
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: branches/simulator/projects/simulator/libsim/libsim.a
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: branches/simulator/projects/simulator/libsim/libsim.c
===================================================================
--- branches/simulator/projects/simulator/libsim/libsim.c	(revision 1046)
+++ branches/simulator/projects/simulator/libsim/libsim.c	(revision 1047)
@@ -13,13 +13,9 @@
 
 void *tick(int sig)
 {
-  printf("robot paused. suspending\n"); 
-
   if(raise(SIGTSTP)<0)
     printf("could not kill self!\n");
 
-  printf("robot resumed\n");
-
   return NULL;
 }
 
@@ -33,8 +29,8 @@
 
   if(shared_state < 0)
   {
-    printf("unable to get shared memory region\n");
-    return 1;
+    fprintf(stderr, "unable to get shared memory region\n");
+    return;
   }
 
                                              
@@ -50,7 +46,7 @@
 
   ret = setitimer(ITIMER_VIRTUAL, &iv, NULL);
 
-  printf("setitimer returned %d.\n waiting...\n", ret);
+  //printf("setitimer returned %d.\n waiting...\n", ret);
   fflush(stdout);
 
   //TODO: clean up code??
Index: branches/simulator/projects/simulator/simulator/gui/gtk_environment_view.c
===================================================================
--- branches/simulator/projects/simulator/simulator/gui/gtk_environment_view.c	(revision 1046)
+++ branches/simulator/projects/simulator/simulator/gui/gtk_environment_view.c	(revision 1047)
@@ -10,6 +10,7 @@
 #include "gtk_environment_view.h"
 
 #include "robot.h"
+#include "world.h"
 
 #define ENVIRONMENT_VIEW_MIN_WIDTH		100
 #define ENVIRONMENT_VIEW_MIN_HEIGHT		50
@@ -38,6 +39,7 @@
 				GdkEventMotion* event);
 
 
+static void draw_world(GdkDrawable* drawable, GdkGC* gc, world_t* world);
 static void draw_robot(GdkDrawable* drawable, GdkGC* gc, 
                         float x, float y, float angle);
 
@@ -191,12 +193,12 @@
 		return FALSE;
 	
 	view = GTK_ENVIRONMENT_VIEW(widget);
+
+	draw_world(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], &world);
 	
 	robot_iterator_reset();
 	Robot* r;
 	while ((r = robot_iterator_next()) != NULL) {
-        printf("x: %f, y:%f, Theta: %f\n",
-            r->pose.x, r->pose.y, r->pose.theta);
 		draw_robot(widget->window, 
 			widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 
             r->pose.x, r->pose.y, r->pose.theta);
@@ -352,6 +354,63 @@
 	gdk_threads_leave();
 }
 
+static void draw_world(GdkDrawable* drawable, GdkGC* gc, world_t* world)
+{
+	int i, j;
+	GdkPoint* points;
+	poly_t* p;
+
+	if (!drawable || !gc || !world)
+		return;
+
+	double leftx = world->win.p1.x;
+	double upy = world->win.p1.x;
+	double xwidth = world->win.p2.x - leftx;
+	double yheight = world->win.p2.y - upy;
+
+
+	int width, height;
+	gdk_drawable_get_size(drawable, &width, &height);
+	
+	if (xwidth / width < yheight / height)
+		width = (int)(height / yheight * xwidth);
+	else
+		height = (int)(width / xwidth * yheight);
+
+	for (i = 0 ; i < world->max_objs; i++)
+	{
+		object_t* o = &(world->objs[i]);
+		switch (o->id)
+		{
+			case ID_POLY:
+				p = (poly_t*)o->props;
+				points = (GdkPoint*)malloc(sizeof(GdkPoint) * p->num_pts);
+				for (j = 0; j < p->num_pts; j++)
+				{
+					points[j].x = (int)((p->pts[j].x - leftx) / xwidth * width);
+					points[j].y = (int)((p->pts[j].y - upy) / yheight * height);
+				}
+				switch(p->type)
+				{
+					case POLY_CONNECTED:
+						gdk_draw_polygon(drawable, gc, 1, points, p->num_pts);
+						break;
+					default:
+						fprintf(stderr, "Detected unexpected type of polygon.\n");
+						break;
+				}
+				free(points);
+				break;
+			// no object
+			case ID_NULL:
+				break;
+			default:
+				fprintf(stderr, "Unexpected object type %d in world.\n", o->id);
+				break;
+		}
+	}
+}
+
 static void draw_robot(GdkDrawable* drawable, GdkGC* gc, 
                         float x, float y, float angle) 
 {
Index: branches/simulator/projects/simulator/simulator/core/main.c
===================================================================
--- branches/simulator/projects/simulator/simulator/core/main.c	(revision 1046)
+++ branches/simulator/projects/simulator/simulator/core/main.c	(revision 1047)
@@ -27,7 +27,7 @@
 		exit(-1);
 	}
 
-	load_world("../../test/world.txt", 100);
+	load_world("../test/world.txt", 100);
 
 
 	robot_create(argv[1]);
Index: branches/simulator/projects/simulator/simulator/core/robot.c
===================================================================
--- branches/simulator/projects/simulator/simulator/core/robot.c	(revision 1046)
+++ branches/simulator/projects/simulator/simulator/core/robot.c	(revision 1047)
@@ -75,7 +75,6 @@
   int pid,i;
 	int id = first_available_id;
 	Robot* r = &robots[id];
-	printf("ID: %d\n", id);
 	// do shared memory stuff here
 	key_t key = IPC_PRIVATE;
 	//Memory accessible only to children with r/w privileges
Index: branches/simulator/projects/simulator/simulator/core/world.c
===================================================================
--- branches/simulator/projects/simulator/simulator/core/world.c	(revision 1046)
+++ branches/simulator/projects/simulator/simulator/core/world.c	(revision 1047)
@@ -24,7 +24,8 @@
     world.objs = calloc(max_objs,  sizeof(object_t));
     world.win = b;
     /* Add a polygon surrounding the world */
-    create(ID_POLY,4,POLY_CONNECTED,pts);
+	// this devours the world - brian
+    //create(ID_POLY,4,POLY_CONNECTED,pts);
 }
 int destroy_world()
 {
@@ -245,7 +246,7 @@
     {
 	rf.d = rf_thetas[ir];
 	x = collide_world(&rf);
-	printf("[%d] = %g\n", ir, x);
+	//printf("[%d] = %g\n", ir, x);
 	bot->shared->ranges.d[ir] = x;
     }
 }
Index: branches/simulator/projects/simulator/test/world.txt
===================================================================
--- branches/simulator/projects/simulator/test/world.txt	(revision 1046)
+++ branches/simulator/projects/simulator/test/world.txt	(revision 1047)
@@ -1,2 +1,8 @@
-WORLD 0 0 512 512
-POLYGON 4 CONNECTED -1 -1 -1 1 1 1 1 -1
+WORLD -1 -1 1 1
+POLYGON 4 CONNECTED -1 -1 -1 1 -0.99 1 -0.99 -1
+POLYGON 4 CONNECTED -0.99 -1 -0.99 -0.99 0.99 -0.99 0.99 -1
+POLYGON 4 CONNECTED -0.99 1 -0.99 0.99 0.99 0.99 0.99 1
+POLYGON 4 CONNECTED 1 -1 1 1 0.99 1 0.99 -1
+
+POLYGON 4 CONNECTED -0.2 -0.2 -0.2 0.2 0.2 0.2 0.2 -0.2
+
