Revision: 7731
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7731&view=rev
Author:   asadat
Date:     2009-05-28 00:47:31 +0000 (Thu, 28 May 2009)

Log Message:
-----------
implemented websim CountRobots and GetSayString methods

Modified Paths:
--------------
    code/stage/trunk/webstage/webstage.cc

Modified: code/stage/trunk/webstage/webstage.cc
===================================================================
--- code/stage/trunk/webstage/webstage.cc       2009-05-28 00:46:01 UTC (rev 
7730)
+++ code/stage/trunk/webstage/webstage.cc       2009-05-28 00:47:31 UTC (rev 
7731)
@@ -332,14 +332,64 @@
                }
                else
                {
-                 printf("Warning: attemp ti get the extent of unrecognized 
model \"%s\"\n", name.c_str());
+                 printf("Warning: attemp to get the extent of unrecognized 
model \"%s\"\n", name.c_str());
                  return false;         
                }
        }
+        GetModelTree();
+       return true;
+  }
 
+   static int CountRobots(Model * mod, int* n ){
+ 
+       if(n && mod->GetModelType() == MODEL_TYPE_POSITION)
+               (*n)++;
+  
+       return 0;
+   } 
+  
+   virtual bool GetNumberOfRobots(unsigned int& n)
+   {
+       
+       
+       world->ForEachDescendant((stg_model_callback_t)CountRobots, &n);        
        return true;
+
+   }
+
+   virtual bool GetModelTree()
+  {
+       
+//     world->ForEachDescendant((stg_model_callback_t)printname, NULL);        
+
+       return true;
   }
+  
+  virtual bool GetSayStrings(std::vector<std::string>& sayings)
+  {
+       unsigned int n=0;
+       this->GetNumberOfRobots(n);
+       
+       for(int i=0;i<n;i++){
+               char temp[128];
+               sprintf(temp,"position:%d",i);
+               Model *mod = world->GetModel(temp);
+               if(mod->GetSayString())
+               {       
+                       
+                       std::string str = temp;
+                       str += " says: \" ";
+                       str += mod->GetSayString();
+                       str += " \"\n ";
+                       
+                       sayings.push_back(str);
+                       
+               }
+       }
 
+       return true;
+  }
+
   virtual websim::Time GetTime()
   {
         stg_usec_t stgtime = world->SimTimeNow();


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

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to