Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

graphicClient.cc

Go to the documentation of this file.
00001 /*
00002   svas_server -- virtual World Server of Svas
00003   Copyright (c) 2001, 2002 David Moreno Montero
00004  
00005  
00006   This program is free software; you can redistribute it and/or modify
00007   it under the terms of the GNU General Public License as published by
00008   the Free Software Foundation; either version 2 of the License, or
00009   (at your option) any later version.
00010  
00011   This program is distributed in the hope that it will be useful, but
00012   WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   General Public License for more details.
00015  
00016   You should have received a copy of the GNU General Public License
00017   along with this program; if not, write to the Free Software
00018   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019   02111-1307, USA.  
00020 
00021 */
00022 
00023 
00024 #include <thread.h>
00025 #include <math.h>
00026 #include <socket.h>
00027 #include "world.h"
00028 #include "graphicClient.h"
00029 #include "log.h"
00030 #include "cylinder.h"
00031 #include "agent.h"
00032 
00033 GraphicClient::GraphicClient(ost::TCPSocket &sock, World *w) : baseClient(sock, w){
00034   ;
00035 }
00036 
00037 void GraphicClient::Run(void){
00038   log <<"Running new Graphic Client"<<endl;
00039 
00040   bool quit=false;
00041   while(!quit){
00042     
00043     if (stream->isPending(ost::SOCKET_PENDING_INPUT,0)){
00044       string st;
00045       *stream >> st;
00046       if (st==""){
00047     quit=true;
00048     continue;
00049       }
00050       else if (st=="BYE"){
00051     quit=true;
00052     continue;
00053       }
00054 
00055       float a,b,c,d,e,f;
00056       int n=sscanf(st.data(),"(%g, %g, %g)(%g, %g, %g)",&a,&b,&c,&d,&e,&f);
00057       if (n!=6){
00058     log <<"Not valid vectors for graphicClient ("<<st.data()<<")"<<endl;
00059     continue;
00060       }
00061 
00062       unsigned int j;
00063       for (j=world->getNumCylinders();j--;){
00064     Cylinder *cyl=world->getCylinder(j);
00065     if (NULL!=cyl){
00066       *stream <<(cyl->getPosition()).toString()
00067           <<Vector3d(cyl->getWidth(),cyl->getHeight(),cyl->getEnergy()/cyl->getMass()).toString()
00068           <<cyl->getOrientation().toString()<<endl;
00069     }
00070       }
00071       
00072       *stream <<"OK"<<endl;
00073       stream->flush();
00074 
00075     }
00076     dontWalk();
00077   }
00078 
00079   log <<"End of Graphic Client"<<endl;
00080   alive=false;
00081 }

Generated on Mon Jun 17 19:53:44 2002 for Svas Server by doxygen1.2.16