rasterize.cc
Go to the documentation of this file.
00001 
00008 // uncomment the line 'ctrl "rasterize"' in <stage source>/worlds/simple.world to try this example
00009 
00010 #include "stage.hh"
00011 using namespace Stg;
00012 
00013 
00014 // Stage calls this when the model starts up
00015 extern "C" int Init( Model* mod )
00016 {  
00017   const unsigned int dw = 40, dh = 20;
00018   
00019   uint8_t* data = new uint8_t[dw*dh*2];
00020   memset( data, 0, sizeof(uint8_t) * dw * dh );
00021   
00022   printf( "\n[Rasterize] Raster of model \"%s\":\n", 
00023           mod->Token() );
00024   
00025   Stg::Size modsz( mod->GetGeom().size );
00026 
00027   mod->Rasterize( data, dw, dh, 
00028                   modsz.x / (float)dw, 
00029                   modsz.y / (float)dh );
00030 
00031   for( unsigned int y=0; y<dh; y++ )
00032     {
00033       printf( "[Rasterize] " );
00034       for( unsigned int x=0; x<dw; x++ )
00035         putchar( data[x + ((dh-y-1)*dw)] ? 'O' : '.' );
00036       putchar( '\n' );
00037     }  
00038   delete data;
00039   puts( "[Rasterize] Done" );
00040 
00041   return 0; //ok
00042 }
00043 
00044 
00045 


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Thu Aug 27 2015 15:20:57