Exemple #1
0
void RobotUpdator::releaseKey(char key){
   // std::string nodeName = namemap[key];
    std::string nodeName = commandMap[key]->nodeName;
    FindNodeVisitor finder(nodeName);
    robot->accept(finder);
    osg::MatrixTransform *pMt = dynamic_cast <osg::MatrixTransform *> (finder.getFirst());
    if (pMt) {
     osg::Switch *pSwitch = findSwitch(pMt);
        if (pSwitch) {
            pSwitch->setAllChildrenOff();
            pSwitch->setSingleChildOn(0);
        }
    }
    onRotCmd = NULL;            
}
Exemple #2
0
void readHosts(char *hostList, struct machine **retMachineList, struct netSwitch **retNsList)
/* Create list of all machines from hostList. */
{
struct lineFile *lf = lineFileOpen(hostList, TRUE);
struct machine *machList = NULL, *mach;
struct netSwitch *nsList = NULL, *ns;
char *line, *words[4];
int lineSize, wordCount;
char *switchName;

while (lineFileNext(lf, &line, &lineSize))
    {
    if (line[0] == '#')
	continue;
    wordCount = chopLine(line, words);
    if (wordCount < 1 || wordCount > 2)
	errAbort("Expecting one or two words line %d of %s", lf->lineIx, lf->fileName);
    AllocVar(mach);
    mach->name = cloneString(words[0]);
    if (wordCount > 1)
	switchName = words[1];
    else
    	switchName = "1";
    if ((ns = findSwitch(nsList, switchName)) == NULL)
	{
	AllocVar(ns);
	ns->name = cloneString(switchName);
	slAddHead(&nsList, ns);
	}
    mach->netSwitch = ns;
    ns->machCount += 1;
    slAddHead(&ns->machList, mach);
    }
for (ns = nsList; ns != NULL; ns = ns->next)
    slReverse(&ns->machList);
slSort(&nsList, netSwitchCmp);
machList = shuffleSwitches(nsList);
*retMachineList = machList;
*retNsList = nsList;
}
Exemple #3
0
void RobotUpdator::updateRotation()
{
    std::string nodeName =  onRotCmd->nodeName;//namemap[key];
    FindNodeVisitor finder(nodeName);
    robot->accept(finder);
    osg::MatrixTransform *mt = dynamic_cast <osg::MatrixTransform *> (finder.getFirst());
    if(mt){
    //    std::cout << nodeName << std::endl;
        
        osg::Switch *pSwitch = findSwitch(mt);
       if (pSwitch) {
         //  std::cout << nodeName<<"===" << std::endl;
        osg::Quat qrot = mt->getMatrix().getRotate();
        osg::Vec3f v3f;
        double angle;
        qrot.getRotate(angle, v3f);
        if(osg::RadiansToDegrees(angle)>onRotCmd->minDegree && osg::RadiansToDegrees(angle) < onRotCmd->maxDegree&&onRotCmd->blocked){
            pSwitch->setAllChildrenOff();
            pSwitch->setSingleChildOn(1);
        }
         //   setNodeColor(mt, RED);
        else{
            osg::Matrix mtx = osg::Matrix::rotate(osg::DegreesToRadians(onRotCmd->speed),onRotCmd->axis);
            mt->setMatrix(mt->getMatrix() * mtx);
            //commandMap[commandMap[key].speed > 0?key-32:key+32].blocked = false;
            commandMap[onRotCmd->speed > 0?toupper(onRotCmd->key):tolower(onRotCmd->key)]->blocked = false;
          //   std::cout<< commandMap[commandMap[onRotCmd->key].speed > 0?toupper(onRotCmd->key):tolower(onRotCmd->key)].speed<<std::endl;
        //    std::cout<<( onRotCmd->key) << std::endl;
            onRotCmd->blocked = true;
         //setNodeColor(mt,GREEN);
            pSwitch->setAllChildrenOff();
            pSwitch->setSingleChildOn(2);
        }
      }
    }
}