예제 #1
0
파일: Pod.cpp 프로젝트: emfb760/brain-game
void Pod::loadBasicShape()
{
    removeFromScene();
    
    entirePod = parentNode->createChildSceneNode("entirePodNode" + Util::toStringInt(podID));
    
    stem = entirePod->createChildSceneNode("stemNode" + Util::toStringInt(podID));
    
    Entity* stemEntity = stem->getCreator()->createEntity("stemEntity" + Util::toStringInt(podID), "cylinderMesh");
    stemEntity->setMaterialName("General/PodStem");
    stem->attachObject(stemEntity);
    
    Vector3 v = tip - base;
    stem->setOrientation(globals.tunnelReferenceUpward.getRotationTo(v));
    
    stem->translate(v / -2);
    
    head = entirePod->createChildSceneNode("headNode" + Util::toStringInt(podID));
    
    switch (podShape)
    {
        case POD_SHAPE_CONE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "cylinderMesh");
            head->scale(headRadius * 1.5, headRadius * 3, headRadius * 1.5);
            break;
        case POD_SHAPE_SPHERE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "sphereMesh");
            head->scale(headRadius, headRadius, headRadius);
//            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "column.mesh");
//            head->scale(0.1, 0.1, 0.1);
            break;
        case POD_SHAPE_DIAMOND:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "diamondMesh");
            head->scale(headRadius * 1.5, headRadius * 2, headRadius * 1.5);
            setRotateSpeed(Vector3(globals.podRotateSpeed, 0, 0));
            break;
        case POD_SHAPE_TRIANGLE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "boxMesh");
            head->scale(headRadius, headRadius, headRadius);
            setRotateSpeed(Vector3(globals.podRotateSpeed, 0, 0));
            break;
        default:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "cylinderMesh");
            head->scale(headRadius * 1.5, headRadius * 3, headRadius * 1.5);
            break;
    }
    materialName = "General/PodUnknown";
    headContentEntity->setMaterialName(materialName);
    head->attachObject(headContentEntity);
    head->setOrientation(globals.tunnelReferenceUpward.getRotationTo(v));
    
    setToGrowth(0.0);
}
void Camera::setFps( float fps )
{
    this->fps = fps;
    setPanSpeed();
    setRotateSpeed();
    setRevolveSpeed();
    setAcceleration();
}
예제 #3
0
TEST(PELCO_CRC, TST_ROTATE_ST2)
{
  PelcoCamera::PELCO_MSG msg = PelcoCamera::PELCO_MSG();
  begin(msg);
  setNumStation(msg, 1);
  setRotateSpeed(msg, -0x3F, 0);
  setCRC(msg);

  EXPECT_EQ(msg, msg6);
}
예제 #4
0
void PelcoCamera::rotateContinues(const double pan, const double tilt)
{
    PelcoCamera::PELCO_MSG msg = PelcoCamera::PELCO_MSG();
    begin(msg);
    setNumStation(msg, m_num);
    const int pan_pelco = fabs(pan) > 1.0 ? (fabs(pan) > 0 ? 0xFF : -0xFF) : fabs(pan) * 0x3F;
    const int tilt_pelco = fabs(tilt) > 1.0 ? (fabs(tilt) > 0 ? 0xFF : -0xFF) : fabs(tilt) * 0x3F;
    setRotateSpeed(msg, pan_pelco, tilt_pelco);
    setCRC(msg);

    send(msg);
}
예제 #5
0
파일: Pod.cpp 프로젝트: emfb760/brain-game
void Pod::loadFuelCell()
{
    removeFromScene();
    
	float stemLength = base.distance(tip);
    entirePod = parentNode->createChildSceneNode("entirePodNode" + Util::toStringInt(podID));
    Vector3 v = tip - base;
    
    head = entirePod->createChildSceneNode("headNode" + Util::toStringInt(podID));
    
    materialName = "General/PodUnknown";
    switch (podShape)
    {
        case POD_SHAPE_CONE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/fuelCylinder.mesh");
            break;
        case POD_SHAPE_SPHERE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/fuelSphere.mesh");
            break;
        case POD_SHAPE_DIAMOND:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/fuelCube.mesh");
            break;
        case POD_SHAPE_TRIANGLE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/fuelTri.mesh");
            break;
        case POD_SHAPE_HOLDOUT:
            generateIndicator();
            break;
        default:
            if( podSignal == POD_SIGNAL_UNKNOWN ) {
                materialName = "General/PodPurple";
            }
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/fuelPenta.mesh");
            headContentEntity->getSubEntity(1)->setMaterialName("General/PodMetal"); // Assign with no specular
            headContentEntity->getSubEntity(0)->setMaterialName(materialName);
            break;
    }
    if (podShape != POD_SHAPE_UNKNOWN && podShape != POD_SHAPE_HOLDOUT)
    {
        headContentEntity->getSubEntity(0)->setMaterialName("General/PodMetal"); // Assign with no specular
        headContentEntity->getSubEntity(1)->setMaterialName(materialName);
    }
    if( podShape != POD_SHAPE_HOLDOUT ) head->attachObject(headContentEntity);
    head->setOrientation(globals.tunnelReferenceUpward.getRotationTo(v));
    head->setPosition(base);
    head->translate(v / 2);
    setRotateSpeed(Vector3(globals.podRotateSpeed, 0, 0));
    
    setToGrowth(0.0);
}
예제 #6
0
void Pod::loadFlower()
{
    removeFromScene();
    
    float stemLength = base.distance(tip);
    entirePod = parentNode->createChildSceneNode("entirePodNode" + Util::toStringInt(podID));
    Vector3 v = tip - base;
    
    head = entirePod->createChildSceneNode("headNode" + Util::toStringInt(podID));
    headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "Flowers/rose.mesh");
    head->attachObject(headContentEntity);
    head->setOrientation(globals.tunnelReferenceUpward.getRotationTo(v));
    head->setPosition(base);
    head->translate(v / 2);
    setRotateSpeed(Vector3(globals.podRotateSpeed, 0, 0));
    
    setToGrowth(0.0);
}
예제 #7
0
파일: Pod.cpp 프로젝트: emfb760/brain-game
void Pod::loadPowerup()
{
    
    removeFromScene();
    
	float stemLength = base.distance(tip);
    entirePod = parentNode->createChildSceneNode("entirePodNode" + Util::toStringInt(podID));
    Vector3 v = tip - base;
    
    head = entirePod->createChildSceneNode("headNode" + Util::toStringInt(podID));
    switch (podColor)
    {
        case POD_COLOR_PINK:
//            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "Powerups/TractorBeam.mesh");
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "sphereMesh");
            headContentEntity->setMaterialName("General/PodRed");
            break;
        case POD_COLOR_GREEN:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "Powerups/slowdown.mesh");
            headContentEntity->getSubEntity(0)->setMaterialName("slowdown/Bubble");
            break;
        case POD_COLOR_BLUE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "Powerups/shields.mesh");
            headContentEntity->getSubEntity(0)->setMaterialName("General/VineShellActive");
            break;
        default:
            std::cout << "WARNING: Unknown Powerup Model Type!\n";
            break;
    }
    
    head->attachObject(headContentEntity);
    head->setOrientation(globals.tunnelReferenceUpward.getRotationTo(v));
    head->setPosition(base);
    head->translate(v);
    
    setRotateSpeed(Vector3(globals.podRotateSpeed, 0, 0));
    
    setToGrowth(0.0);
}
예제 #8
0
void Pod::loadCrystal()
{
    mtype = POD_CRYSTAL;
    removeFromScene();
    
    float stemLength = base.distance(tip);
    entirePod = parentNode->createChildSceneNode("entirePodNode" + Util::toStringInt(podID));
    Vector3 v = tip - base;
    
    head = entirePod->createChildSceneNode("headNode" + Util::toStringInt(podID));
    
    materialName = "General/PodUnknown";
    switch (podShape)
    {
        case POD_SHAPE_CONE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/cylinder.mesh");
            break;
        case POD_SHAPE_SPHERE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/cuboid.mesh");
            break;
        case POD_SHAPE_DIAMOND:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/star.mesh");
            break;
        case POD_SHAPE_TRIANGLE:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/tri.mesh");
            break;
        case POD_SHAPE_HOLDOUT:
            generateHoldoutEffect();
            break;
        default:
            headContentEntity = head->getCreator()->createEntity("headEntity" + Util::toStringInt(podID), "FuelCell/3Dstar.mesh");
            headContentEntity->getSubEntity(0)->setMaterialName(materialName);
            break;
    }
    if (podShape != POD_SHAPE_UNKNOWN && podShape != POD_SHAPE_HOLDOUT)
    {
        headContentEntity->getSubEntity(0)->setMaterialName(materialName);
        if (podShape != POD_SHAPE_TRIANGLE)
        {
            headContentEntity->getSubEntity(0)->setMaterialName(materialName);
            headContentEntity->getSubEntity(1)->setMaterialName("General/PodMetal");
            if (podShape == POD_SHAPE_SPHERE)
            {
                headContentEntity->getSubEntity(2)->setMaterialName(materialName);
                headContentEntity->getSubEntity(1)->setMaterialName("General/PodMetal");
                headContentEntity->getSubEntity(0)->setMaterialName("General/PodMetal");
            }
        }
        else
        {
            headContentEntity->getSubEntity(0)->setMaterialName("General/PodMetal");
            headContentEntity->getSubEntity(1)->setMaterialName(materialName);
        }
    }
    if( podShape != POD_SHAPE_HOLDOUT )
    {
        head->attachObject(headContentEntity);
        if( podSignal == POD_SIGNAL_UNKNOWN ) {
            uncloakPod();
        }
    }
    head->setOrientation(globals.tunnelReferenceUpward.getRotationTo(v));
    head->setPosition(base);
    head->translate(v / 2);
    
    //direction = (globals.tunnelReferenceForward).randomDeviant(Radian(rand() % 180));
    //direction.normalise();
    //std::cout << direction.x << " " << direction.y << " " << direction.z << std::endl;
    //setRotateSpeed(direction * 2);
    setRotateSpeed(Vector3(globals.podRotateSpeed, 0, 0));
    
    setToGrowth(0.0);
}
예제 #9
0
파일: IGV.cpp 프로젝트: jrd730/AVS
void IGV::runProgram ()
{
  addVisibleLinesToMap ();
  if (autonomousMode)
  {
    //cout << "current rotation: " << rotation << endl;
    // still have goals to reach
    if (env.waypoints.size () > 0){
      
      // a route to a goal has been mapped out already
      if (followingPath)
      {
        pathNode = pf.getCurPathNode ();
        
        // check if current node is close enough to move on to next
        float dist_to_node = position.distance (pathNode);
        if (dist_to_node < pf.getGoalDistance () )
        {
          // cout << "Reached the next node in the path\n";
          if (pf.path.size () > 1)
          {
            pf.setNextPathNode ();
            // cout << "Setting the next path node\n";
            // cout << "Nodes remaining: " << pf.path.size () << endl;
            //pathNode = pf.getCurPathNode ();
          } 
          // reached the end of current path to a waypoint
          else
          {
            // cout << "Reached the waypoint, going on to the next\n";
            fullStop ();
            pf.clear ();
            env.waypoints.pop_front();
            followingPath = false;
          }
        }

        else{
          // align to next node in the path
          float theta = angleTo (pathNode);

          //cout << "angle to next node: " << theta << endl;

          // check for a potential collision, if one might occur then the 
          // current path should be abandoned and a new one should be formed
          vector <pair <vertex, Line*> > closeWalls = env.lineMap->getObjectsInRegion (pathNode - pf.getWallDistance (), pathNode + pf.getWallDistance () );
          
          if (closeWalls.size () > 0){
            fullStop ();
            pf.clear ();
            followingPath = false;
            return;
          }

          // set a forward speed that is related to the angle to the next node
          // as well as the distance to the next node
          if (theta <= 45.0){
            setRotateSpeed ( max ( 0.0, sin (theta/DEGREES_PER_RADIAN) ) );
            setForwardSpeed ( max ( 0.0, cos (theta/DEGREES_PER_RADIAN) ) );
          }
          else if (theta >= 315.0){
            setRotateSpeed ( max ( 0.0, -sin (theta/DEGREES_PER_RADIAN) ) );
            setForwardSpeed ( max ( 0.0, cos (theta/DEGREES_PER_RADIAN) ) );
          }
          // turn left
          else if (theta < 180.0){
            setRotateSpeed (2.0);
            //setForwardSpeed (0);
            setForwardSpeed ( max ( 0.0, cos (theta/DEGREES_PER_RADIAN)/3.0 ) );
          }
          // turn right
          else {
            setRotateSpeed (-2.0);
            //setForwardSpeed (0);
            setForwardSpeed ( max ( 0.0, cos (theta/DEGREES_PER_RADIAN)/3.0 ) );
          }

          
        }     
      } 
      
      // generate a path to a goal
      else
      {
        // start a new path 
        if ( !pf.searching () ){
          findPath (env.waypoints.front());
        }

        // continue expanding on path search until a path is found or the 
        // specified waypoint is determined to be unreachable
        else{
          if ( !pf.done () ){
            pf.expand ();
            if (pf.pathImpossible ()){
              pf.clear ();
              env.waypoints.pop_front();
              //cout << "Mission impossible~\n";
            }
          }
          else{
            followingPath = true;
          }
        }
      }
    }
  }
}