Example case: Add a new element/ parameter in world xml file and load this parameter using a new request.
case REQUEST_VIEWER_GET_MAIN_CAM: { // std::cout <<"FROM WorldSimulator" << m_posMcam.x() << " " << m_posMcam.y() << " "<< m_posMcam.z() << std::endl ; //DISPLAY DEBUG std::ostringstream sstream; if(w->posMcam()) { Vector3d m_posMcam = w->get_posMcam(); sstream << m_posMcam.x() << " " << m_posMcam.y() << " " << m_posMcam.z() ; } if(w->dirMcam()) { Vector3d m_lookAtMcam = w->get_lookAtMcam(); sstream << " lookAt: " <<m_lookAtMcam.x() << " " << m_lookAtMcam.y() << " " << m_lookAtMcam.z() ; } else if(w->quartMcam()) { double * quart =w->get_quaternionMcam(); sstream << " quaternion: " <<quart[0]<< " " << quart[1] << " " << quart[2] << " " << quart[3] ; } std::string msg = sstream.str(); char bsize[6]; int nbyte = (int)msg.size() ; sprintf(bsize, "%.6d", nbyte); msg = std::string(bsize) + msg; //std::cout <<"Message From WSim: "<< msg << " size: " << nbyte<<std::endl; // DEBUG DISPLAY if(!sendData(s, msg.c_str(), nbyte+6)){ std::cout << "fail to send pos cam"; return false; } // else // std::cout << "send succefully " << std::endl ; continue; }
if(sendRequest(GET_MAIN_CAM)) // get the position and the direction of the main camera from the server { mLog->printf(Sgv::LogBase::INFO, "GET_MAIN_CAM succeeded %s", ipString.c_str()); mLog->info("GET_MAIN_CAM: OK"); char hbuf[6]; memset(hbuf, '\0', sizeof(hbuf)); // to avoid memory bug if(!mSock->recvData(hbuf, 6)){// receive size of the message delete [] &hbuf; MessageBox( NULL,"the Loading of the size of the message containning camera parrameters has failed ", _T("Error"), MB_OK); // DEBUG display return false; } int nbyte = atoi(hbuf); // MessageBox( NULL,hbuf, _T("Error"), MB_OK); // DEBUG display if(nbyte > 0 ) { char *buf(NULL); buf = new char[nbyte]; memset(buf, 0, sizeof(buf)); // to avoid memory bug if(!mSock->recvData(buf,nbyte)){// receive size of the message delete [] &buf; MessageBox( NULL,"the Loading of camera parrameters has failed ", _T("Error"), MB_OK); return false; } // MessageBox( NULL,buf, _T("Error"), MB_OK); // DEBUG display applySettingMCam(buf); delete [] &buf; } }