request-to-SIGServer-from-theSIGViewer
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
*How to add a request to server from the Viewer [#m1a54945]
- This document is written by Mickael Nicolaccini
Example case: Add a new element/ parameter in world xml f...
+ Add a element to parse in the Xml file
#ref(1.png)
+ Prepare where how to store your new data, and how to a...
++ Variable
#ref(2a.png)
++ Accessor: get/set
#ref(2b.png)
+ Modify WorldXMLReader.cpp, add the new Tags in the pars...
++ Use the set accessor
#ref(3.png)
+ Add in WordSimulator.h, a ID and a name for your event
++ Be carefull to REQUEST_SIZE
#ref(4.png)
+ Add a request to Winmain.h (viewer side)
#ref(5.png)
+ Add to WordSimulator.cpp a case when answer to your req...
++ Use the get accessor
++ Convert datas in string
++ Use the socket: s
+++ send first the size of the message (size is store in ...
+++ then send the message
case REQUEST_VIEWER_GET_MAIN_CAM:
{
// std::cout <<"FROM WorldSimulator" << m_posMcam.x...
std::ostringstream sstream;
if(w->posMcam())
{
Vector3d m_posMcam = w->get_posMcam();
sstream << m_posMcam.x() << " " << m_posMcam.y() ...
}
if(w->dirMcam())
{
Vector3d m_lookAtMcam = w->get_lookAtMcam();
sstream << " lookAt: " <<m_lookAtMcam.x() << " "...
}
else if(w->quartMcam())
{
double * quart =w->get_quaternionMcam();
sstream << " quaternion: " <<quart[0]<< " " << qu...
}
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...
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;
}
+ Viewer side, Add to Winmain.cpp a case to send your re...
++ Use the function: sendRequest(),
++ the socket mSock to receive the contain
++ Parse the contain
++ Apply the contain
if(sendRequest(GET_MAIN_CAM)) // get the position and th...
{
mLog->printf(Sgv::LogBase::INFO, "GET_MAIN_CAM succee...
mLog->info("GET_MAIN_CAM: OK");
char hbuf[6];
memset(hbuf, '\0', sizeof(hbuf)); // to avoid memory ...
if(!mSock->recvData(hbuf, 6)){// receive size of the ...
delete [] &hbuf;
MessageBox( NULL,"the Loading of the size of the ...
return false;
}
int nbyte = atoi(hbuf);
// MessageBox( NULL,hbuf, _T("Error"), MB_OK); // D...
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 o...
delete [] &buf;
MessageBox( NULL,"the Loading of camera parra...
return false;
}
// MessageBox( NULL,buf, _T("Error"), MB_OK); /...
applySettingMCam(buf);
delete [] &buf;
}
}
#counter
End:
*How to add a request to server from the Viewer [#m1a54945]
- This document is written by Mickael Nicolaccini
Example case: Add a new element/ parameter in world xml f...
+ Add a element to parse in the Xml file
#ref(1.png)
+ Prepare where how to store your new data, and how to a...
++ Variable
#ref(2a.png)
++ Accessor: get/set
#ref(2b.png)
+ Modify WorldXMLReader.cpp, add the new Tags in the pars...
++ Use the set accessor
#ref(3.png)
+ Add in WordSimulator.h, a ID and a name for your event
++ Be carefull to REQUEST_SIZE
#ref(4.png)
+ Add a request to Winmain.h (viewer side)
#ref(5.png)
+ Add to WordSimulator.cpp a case when answer to your req...
++ Use the get accessor
++ Convert datas in string
++ Use the socket: s
+++ send first the size of the message (size is store in ...
+++ then send the message
case REQUEST_VIEWER_GET_MAIN_CAM:
{
// std::cout <<"FROM WorldSimulator" << m_posMcam.x...
std::ostringstream sstream;
if(w->posMcam())
{
Vector3d m_posMcam = w->get_posMcam();
sstream << m_posMcam.x() << " " << m_posMcam.y() ...
}
if(w->dirMcam())
{
Vector3d m_lookAtMcam = w->get_lookAtMcam();
sstream << " lookAt: " <<m_lookAtMcam.x() << " "...
}
else if(w->quartMcam())
{
double * quart =w->get_quaternionMcam();
sstream << " quaternion: " <<quart[0]<< " " << qu...
}
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...
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;
}
+ Viewer side, Add to Winmain.cpp a case to send your re...
++ Use the function: sendRequest(),
++ the socket mSock to receive the contain
++ Parse the contain
++ Apply the contain
if(sendRequest(GET_MAIN_CAM)) // get the position and th...
{
mLog->printf(Sgv::LogBase::INFO, "GET_MAIN_CAM succee...
mLog->info("GET_MAIN_CAM: OK");
char hbuf[6];
memset(hbuf, '\0', sizeof(hbuf)); // to avoid memory ...
if(!mSock->recvData(hbuf, 6)){// receive size of the ...
delete [] &hbuf;
MessageBox( NULL,"the Loading of the size of the ...
return false;
}
int nbyte = atoi(hbuf);
// MessageBox( NULL,hbuf, _T("Error"), MB_OK); // D...
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 o...
delete [] &buf;
MessageBox( NULL,"the Loading of camera parra...
return false;
}
// MessageBox( NULL,buf, _T("Error"), MB_OK); /...
applySettingMCam(buf);
delete [] &buf;
}
}
#counter
Page: