Revision: 7904
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7904&view=rev
Author:   rtv
Date:     2009-06-25 19:40:16 +0000 (Thu, 25 Jun 2009)

Log Message:
-----------
added rasterize controller example

Added Paths:
-----------
    code/stage/trunk/examples/ctrl/rasterize.cc

Added: code/stage/trunk/examples/ctrl/rasterize.cc
===================================================================
--- code/stage/trunk/examples/ctrl/rasterize.cc                         (rev 0)
+++ code/stage/trunk/examples/ctrl/rasterize.cc 2009-06-25 19:40:16 UTC (rev 
7904)
@@ -0,0 +1,45 @@
+/**
+ * File: rasterize.cc
+ * Description: example of how to use the Stg::Model::Rasterize() method
+ * Date: 12 June 2009
+ * Author: Richard Vaughan
+*/
+
+// uncomment the line 'ctrl "rasterize"' in <stage source>/worlds/simple.world 
to try this example
+
+#include "stage.hh"
+using namespace Stg;
+
+
+// Stage calls this when the model starts up
+extern "C" int Init( Model* mod )
+{  
+  const unsigned int dw = 40, dh = 20;
+  
+  uint8_t* data = new uint8_t[dw*dh*2];
+  memset( data, 0, sizeof(uint8_t) * dw * dh );
+  
+  printf( "\n[Rasterize] Raster of model \"%s\":\n", 
+         mod->Token() );
+  
+  Size modsz( mod->GetGeom().size );
+
+  mod->Rasterize( data, dw, dh, 
+                 modsz.x / (float)dw, 
+                 modsz.y / (float)dh );
+
+  for( unsigned int y=0; y<dh; y++ )
+    {
+      printf( "[Rasterize] " );
+      for( unsigned int x=0; x<dw; x++ )
+       putchar( data[x + ((dh-y-1)*dw)] ? 'O' : '.' );
+      putchar( '\n' );
+    }  
+  delete data;
+  puts( "[Rasterize] Done" );
+
+  return 0; //ok
+}
+
+
+


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to