void RobotController::onRecvMessage(RecvMessageEvent &evt) { int n = evt.getSize(); if (n>0) { std::string strCmd = evt.getString(0); const char *cmd = strCmd.c_str(); LOG_MSG(("cmd : %s", cmd)); if (strcmp(cmd, "text") == 0) { std::string strTarget = evt.getString(1); const char *target = strTarget.c_str(); LOG_MSG(("target : (%s)", target)); std::string strText = evt.getString(2); const char *text = strText.c_str(); LOG_MSG(("text : (%s)", text)); sendText(0, target, text); } } }
void SetAttrController::onRecvMessage(RecvMessageEvent &evt) { double x, y, z; LOG_MSG(("message from : %s", evt.getSender())); int n = evt.getSize(); for (int i=0; i<n; i++) { LOG_MSG(("[%d] (%s)", i, evt.getString(i))); } SimObj *o = getObj(myname()); if (n>0 && o && !o->dynamics()) { const char *cmd = evt.getString(0); if (cmd) { if (strcmp(cmd, "p")==0) { // ---------------------------- // position set (x, y, z) // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set position (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->setPosition(x, y, z); } } } else if (strcmp(cmd, "vp")==0) { // ---------------------------- // view pos // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set view position (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->vpx(x); o->vpy(y); o->vpz(z); } } } else if (strcmp(cmd, "vv")==0) { // ---------------------------- // view vector // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set view vector (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->vvx(x); o->vvy(y); o->vvz(z); } } } else if (strcmp(cmd, "lep")==0) { // ---------------------------- // left eye pos // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set left eye position (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->lepx(x); o->lepy(y); o->lepz(z); } } } else if (strcmp(cmd, "lev")==0) { // ---------------------------- // left eye vector // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set left eye vector (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->levx(x); o->levy(y); o->levz(z); } } } else if (strcmp(cmd, "rep")==0) { // ---------------------------- // right eye pos // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set right eye position (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->repx(x); o->repy(y); o->repz(z); } } } else if (strcmp(cmd, "rev")==0) { // ---------------------------- // right eye vector // ---------------------------- const char *param = evt.getString(1); if (param) { LOG_MSG(("set right eye vector (param=%s)", param)); if (parseVector3(param, x, y, z)) { LOG_MSG(("(%f, %f, %f)", x, y, z)); o->revx(x); o->revy(y); o->revz(z); } } } } } }