当前位置: 首页>>代码示例>>C++>>正文


C++ SimpleXMLTransfer::getName方法代码示例

本文整理汇总了C++中SimpleXMLTransfer::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleXMLTransfer::getName方法的具体用法?C++ SimpleXMLTransfer::getName怎么用?C++ SimpleXMLTransfer::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLTransfer的用法示例。


在下文中一共展示了SimpleXMLTransfer::getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

Power::Shaft::Shaft(SimpleXMLTransfer* xml)
{    
  for (int n=0; n<xml->getChildCount(); n++)
  {
    SimpleXMLTransfer* it = xml->getChildAt(n);
    Gearing*           s  = (Gearing*)0;
    if (it->getName().compare("engine") == 0)
      s = new Engine_DCM();
    else if (it->getName().compare("propeller") == 0)
      s = new Propeller();
    else if (it->getName().compare("simplethrust") == 0)
      s = new SimpleThrust();
    if (s != (Gearing*)0)
      gear.push_back(s);
  }
}
开发者ID:KISSMonX,项目名称:crrcsim-pprz,代码行数:16,代码来源:shaft.cpp

示例2:

void Power::Shaft::ReloadParams(SimpleXMLTransfer* xml)
{
  int      nChildCnt = 0;
  double   J_ges;
  
  fBrake = (xml->attributeAsInt("brake", 1) != 0);
  J_ges = xml->attributeAsDouble("J", 0);
  std::cout << "  Shaft: J=" << J_ges << " kg m^2\n";
      
  for (int n=0; n<xml->getChildCount(); n++)
  {
    SimpleXMLTransfer* it = xml->getChildAt(n);
    if (it->getName().compare("engine")       == 0 ||
        it->getName().compare("propeller")    == 0 ||
        it->getName().compare("simplethrust") == 0
        )
    {
      gear[nChildCnt]->ReloadParams(it);
      J_ges += gear[nChildCnt++]->getJ();
    }
  }
  
  J_inv = 1/J_ges;
}
开发者ID:KISSMonX,项目名称:crrcsim-pprz,代码行数:24,代码来源:shaft.cpp

示例3: initSound

void CRRCAirplaneLaRCSim::initSound(SimpleXMLTransfer* xml)
{
  SimpleXMLTransfer* cfg = XMLModelFile::getConfig(xml);
  SimpleXMLTransfer* sndcfg = cfg->getChild("sound", true);
  int children = sndcfg->getChildCount();
  int units = sndcfg->getInt("units", 0);
  
  for (int i = 0; i < children; i++)
  {
    SimpleXMLTransfer *child = sndcfg->getChildAt(i);
    std::string name = child->getName();
    
    if (name.compare("sample") == 0)
    {
      T_AirplaneSound *sample;

      // assemble relative path
      std::string soundfile;
      soundfile           = child->attribute("filename");

      // other sound attributes
      int sound_type      = child->getInt("type", SOUND_TYPE_GLIDER);
      double dPitchFactor = child->getDouble("pitchfactor", 0.002);
      double dMaxVolume   = child->getDouble("maxvolume", 1.0);
  
      if (dMaxVolume < 0.0)
      {
        dMaxVolume = 0.0;
      }
      else if (dMaxVolume > 1.0)
      {
        dMaxVolume = 1.0;
      }

  //~ if (cfg->indexOfChild("power") < 0)
    //~ max_thrust = 0;
  //~ else
    //~ max_thrust = 1;
  
      if (soundfile != "")
      {
        // Get full path (considering search paths). 
        soundfile = FileSysTools::getDataPath("sounds/" + soundfile);
      }
      
      // File ok? Use default otherwise.
      if (!FileSysTools::fileExists(soundfile))
        soundfile = FileSysTools::getDataPath("sounds/fan.wav");
    
      std::cout << "soundfile: " << soundfile << "\n";
      //~ std::cout << "max_thrust: " << max_thrust << "\n";
      std::cout << "soundserver: " << Global::soundserver << "\n";
  
      // Only make noise if a sound file is available
      if (soundfile != "" && Global::soundserver != (CRRCAudioServer*)0)
      {        
        std::cout << "Using airplane sound " << soundfile << ", type " << sound_type << ", max vol " << dMaxVolume << std::endl;
        
        if (sound_type == SOUND_TYPE_GLIDER)
        {
          T_GliderSound *glidersound;
          float flMinRelV, flMaxRelV, flMaxDist;
          flMinRelV = (float)child->getDouble("v_min", 1.5);
          flMaxRelV = (float)child->getDouble("v_max", 4.0);
          flMaxDist = (float)child->getDouble("dist_max", 300);
          
          if (units == 1)
          {
            // convert from metric units to ft.
            flMaxDist *= M_TO_FT;
          }
          
          glidersound = new T_GliderSound(soundfile.c_str(), Global::soundserver->getAudioSpec());
          glidersound->setMinRelVelocity(flMinRelV);
          glidersound->setMaxRelVelocity(flMaxRelV);
          glidersound->setMaxDistanceFeet(flMaxDist);
          sample = glidersound;
        }
        else
        {
          sample = new T_EngineSound(soundfile.c_str(), Global::soundserver->getAudioSpec());
        }
                
        sample->setType(sound_type);
        sample->setPitchFactor(dPitchFactor);
        sample->setMaxVolume(dMaxVolume);
        sample->setChannel(Global::soundserver->playSample((T_SoundSample*)sample));
        sound.push_back(sample);
      }
    }
  }
}
开发者ID:ajakubek,项目名称:crrcsim_extensions,代码行数:92,代码来源:crrc_loadair.cpp

示例4: if

/**
 *  Create a CRRCControlSurfaceAnimation object
 *
 *  Initialize the animation from an 
 *  <animation type="ControlSurface"> tag
 */
CRRCControlSurfaceAnimation::CRRCControlSurfaceAnimation(SimpleXMLTransfer *xml)
 : CRRCAnimation(new ssgTransform()), fallback_data(0.0f),
   eventAdapter(this, &CRRCControlSurfaceAnimation::axisValueCallback, Event::Input),
    aileron(0.0f), elevator(0.0f), rudder(0.0f), throttle(0.0f),
    spoiler(0.0f), flap(0.0f), retract(0.0f), pitch(0.0f)
{
  bool failed = false;
  
  // evaluate <object> tag
  SimpleXMLTransfer *map = xml->getChild("object", true);
  symbolic_name = map->getString("name", "no_name_set");
  max_angle = (float)(map->getDouble("max_angle", 0.0) * SG_RADIANS_TO_DEGREES);
  abs_max_angle = (float)fabs((double)max_angle);

  // find hinges and evaluate all <control> tags
  int num_controls = 0;
  int num_hinges = 0;
  for (int i = 0; i < xml->getChildCount(); i++)
  {
    SimpleXMLTransfer *child = xml->getChildAt(i);
    if (child->getName() == "hinge")
    {
      // found a <hinge> child
      sgVec3 pos;
      pos[SG_X] = (float)(-1 * child->getDouble("y", 0.0));
      pos[SG_Y] = (float)(-1 * child->getDouble("x", 0.0));
      pos[SG_Z] = (float)(-1 * child->getDouble("z", 0.0));
      if (num_hinges == 0)
      {
        sgCopyVec3(hinge_1, pos);
      }
      else if (num_hinges == 1)
      {
        sgCopyVec3(hinge_2, pos);
      }
      num_hinges++;
    }
    else if (child->getName() == "control")
    {
      // found a <control> child
      // The "*2" factor for each gain value scales the control input
      // values from -0.5...+0.5 to -1.0...+1.0. This saves one
      // float multiplication per mapping in the runtime update() routine.
      std::string mapping = child->getString("mapping", "NOTHING");
      float gain = (float)child->getDouble("gain", 1.0);
      if (mapping == "ELEVATOR")
      {
        datasource.push_back(&elevator);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "AILERON")
      {
        datasource.push_back(&aileron);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "THROTTLE")
      {
        datasource.push_back(&throttle);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "RUDDER")
      {
        datasource.push_back(&rudder);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "FLAP")
      {
        datasource.push_back(&flap);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "SPOILER")
      {
        datasource.push_back(&spoiler);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "RETRACT")
      {
        datasource.push_back(&retract);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "PITCH")
      {
        datasource.push_back(&pitch);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else
//.........这里部分代码省略.........
开发者ID:KISSMonX,项目名称:crrcsim-pprz,代码行数:101,代码来源:crrc_animation.cpp

示例5: if

ModelBasedScenery::ModelBasedScenery(SimpleXMLTransfer *xml, int sky_variant)
    : Scenery(xml, sky_variant), location(Scenery::MODEL_BASED)
{
  ssgEntity *model = NULL;
  SimpleXMLTransfer *scene = xml->getChild("scene", true);
  getHeight_mode = scene->attributeAsInt("getHeight_mode", DEFAULT_HEIGHT_MODE);
  //std::cout << "----getHeight_mode : " <<  getHeight_mode <<std::endl;
  SceneGraph = new ssgRoot();

  // Create an "invisible" state. This state actually makes a node
  // visible in a predefined way. This is used to visualize invisible
  // objects (e.g. collision boxes).
  invisible_state = new ssgSimpleState();
  invisible_state->disable(GL_COLOR_MATERIAL);
  invisible_state->disable(GL_TEXTURE_2D);
  invisible_state->enable(GL_LIGHTING);
  invisible_state->enable(GL_BLEND);
  //invisible_state->setShadeModel(GL_SMOOTH);
  //invisible_state->setShininess(0.0f);
  invisible_state->setMaterial(GL_EMISSION, 0.0, 0.0, 0.0, 0.0);
  invisible_state->setMaterial(GL_AMBIENT, 1.0, 0.0, 0.0, 0.5);
  invisible_state->setMaterial(GL_DIFFUSE, 1.0, 0.0, 0.0, 0.5);
  invisible_state->setMaterial(GL_SPECULAR, 1.0, 0.0, 0.0, 0.5);

  // transform everything from SSG coordinates to CRRCsim coordinates
  initial_trans = new ssgTransform();
  SceneGraph->addKid(initial_trans);
//10.76
  sgMat4 it = {  {1,  0.0,  0.0,   0},
    {0.0,  0.0, -1,   0},
    {0.0,  1,  0.0,   0},
    {0.0,  0.0,  0.0, 1.0}
  };

  initial_trans->setTransform(it);

  // find all "objects" defined in the file
  int num_children = scene->getChildCount();

  for (int cur_child = 0; cur_child < num_children; cur_child++)
  {
    SimpleXMLTransfer *kid = scene->getChildAt(cur_child);
    // only use "object" tags
    if (kid->getName() == "object")
    {
      std::string filename = kid->attribute("filename", "not_specified");
      bool is_terrain = (kid->attributeAsInt("terrain", 1) != 0);
      bool is_visible = (kid->attributeAsInt("visible", 1) != 0);

      // PLIB automatically loads the texture file,
      // but it does not know which directory to use.
      // Where is the object file?
      std::string    of  = FileSysTools::getDataPath("objects/" + filename, TRUE);
      // compile and set relative texture path
      std::string    tp  = of.substr(0, of.length()-filename.length()-1-7) + "textures";
      ssgTexturePath(tp.c_str());

      // load model
      std::cout << "Loading 3D object \"" << of.c_str() << "\"";
      if (is_terrain)
      {
        std::cout << " (part of terrain)";
      }
      if (!is_visible)
      {
        std::cout << " (invisible)";
      }
      std::cout << std::endl;
      model = ssgLoad(of.c_str());
      if (model != NULL)
      {
        if (!is_visible)
        {
          setToInvisibleState(model);
        }
        
        // The model may contain internal node attributes (e.g. for
        // integrated collision boxes). Parse these attributes now.
        evaluateNodeAttributes(model);
        
        
        // now parse the instances and place the model in the SceneGraph
        for (int cur_instance = 0; cur_instance < kid->getChildCount(); cur_instance++)
        {
          SimpleXMLTransfer *instance = kid->getChildAt(cur_instance);
          if (instance->getName() == "instance")
          {
            sgCoord coord;
            
            // try north/east/height first, then fallback to x/y/z
            try
            {
              coord.xyz[SG_X] = instance->attributeAsDouble("east");
            }
            catch (XMLException &e)
            {
              coord.xyz[SG_X] = instance->attributeAsDouble("y", 0.0);
            }
            try
            {
//.........这里部分代码省略.........
开发者ID:mayrit,项目名称:crrcsim,代码行数:101,代码来源:model_based_scenery.cpp

示例6: if

/**
 * Create a HardPointRotation
 *
 * \param xml <animation> part of the model file that contains the
 *            description of the animation
 */
HardPointRotation::HardPointRotation(SimpleXMLTransfer *xml, TSimInputs const& in)
{
  bool failed = false;
  
  // evaluate <object> tag
  SimpleXMLTransfer *map = xml->getChild("object", true);
  symbolic_name = map->getString("name", "no_name_set");
  max_angle_rad = (float)map->getDouble("max_angle", 0.0);
  abs_max_angle_rad = (float)fabs((double)max_angle_rad);

  // find hinges and evaluate all <control> tags
  int num_controls = 0;
  int num_hinges = 0;
  for (int i = 0; i < xml->getChildCount(); i++)
  {
    SimpleXMLTransfer *child = xml->getChildAt(i);
    if (child->getName() == "hinge")
    {
      // found a <hinge> child
      CRRCMath::Vector3 pos;
      pos.r[0] = (float)(child->getDouble("x", 0.0));
      pos.r[1] = (float)(child->getDouble("y", 0.0));
      pos.r[2] = (float)(child->getDouble("z", 0.0));
      if (num_hinges < 2)
      {
        hinge[num_hinges] = pos;
      }
      num_hinges++;
    }
    else if (child->getName() == "control")
    {
      // found a <control> child
      // The "*2" factor for each gain value scales the control input
      // values from -0.5...+0.5 to -1.0...+1.0. This saves one
      // float multiplication per mapping in the runtime update() routine.
      // NB: unsigned control (throttle, spoiler, retract) are not scaled,
      //     since control input is already in range 0.0...+1.0
      std::string mapping = child->getString("mapping", "NOTHING");
      float gain = (float)child->getDouble("gain", 1.0);
      std::cout << "  mapped to " << mapping << " with gain " << gain;
      std::cout << " and max_angle_rad " << max_angle_rad << std::endl;
      if (mapping == "ELEVATOR")
      {
        datasource.push_back(&in.elevator);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "AILERON")
      {
        datasource.push_back(&in.aileron);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "THROTTLE")
      {
        datasource.push_back(&in.throttle);
        source_gain.push_back(gain);
        num_controls++;
      }
      else if (mapping == "RUDDER")
      {
        datasource.push_back(&in.rudder);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "FLAP")
      {
        datasource.push_back(&in.flap);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else if (mapping == "SPOILER")
      {
        datasource.push_back(&in.spoiler);
        source_gain.push_back(gain);
        num_controls++;
      }
      else if (mapping == "RETRACT")
      {
        datasource.push_back(&in.retract);
        source_gain.push_back(gain);
        num_controls++;
      }
      else if (mapping == "PITCH")
      {
        datasource.push_back(&in.pitch);
        source_gain.push_back(gain * 2);
        num_controls++;
      }
      else
      {
        fprintf(stderr, "HardPointRotation: ignoring <control> tag without mapping.\n");
      }
      
//.........这里部分代码省略.........
开发者ID:mayrit,项目名称:crrcsim,代码行数:101,代码来源:gear.cpp

示例7: initAnimations

/** \brief Add animations to a model
 *
 *  This method reads animation description tags from a model file
 *  and tries to add the corresponding animations to the 3D model.
 *
 *  \todo Right now there's only one type of animation: movable control
 *  surfaces. Therefore this method receives a pointer to the control
 *  input class. If animations are added that need a different kind of
 *  input for their update() method, we need to decide how to pass all
 *  this stuff to initAnimations().
 *
 *  \param  model_file    XML model description file
 *  \param  model         scenegraph of the 3D model
 *  \param  fInputs       pointer to the control input class
 *  \param  anim_list     list of all created CRRCAnimation objects
 */
void initAnimations(SimpleXMLTransfer *model_file, ssgEntity* model, 
                    TSimInputs *fInput, std::vector<CRRCAnimation*>& anim_list)
{
  SimpleXMLTransfer *animations = model_file->getChild("animations", true);
  int num_anims = animations->getChildCount();
  fprintf(stdout, "initAnimations: found %d children\n", num_anims);
  
  for (int i = 0; i < num_anims; i++)
  {
    SimpleXMLTransfer *animation = animations->getChildAt(i);
    ssgEntity *node;
    
    if (animation->getName() != "animation")
    {
      fprintf(stderr, "initAnimations: invalid child <%s>\n", animation->getName().c_str());
    }
    else
    {
      std::string node_name = animation->getString("object.name", "default");
      std::string type      = animation->getString("type", "default");

      node = SSGUtil::findNamedNode(model, node_name.c_str());
      if (node != NULL)
      {
        CRRCAnimation *anim = NULL;
        printf("initAnimations: found animation node %s, type %s\n", 
                node_name.c_str(), type.c_str());
        
        if (type == "ControlSurface")
        {
          anim = new CRRCControlSurfaceAnimation(animation, fInput);
        }
        else
        {
          fprintf(stderr, "initAnimations: unknown animation type '%s'\n", type.c_str());
        }
        
        if (anim != NULL)
        {
          if (anim->getBranch() == NULL)
          {
            fprintf(stderr, "initAnimations: defunct animation class (animation branch is <NULL>)\n");
            exit(0);
          }
          else
          {
            SSGUtil::spliceBranch(anim->getBranch(), node);
            anim->init();
            anim->setName("Animation");
            anim->getBranch()->setUserData(anim);
            anim->getBranch()->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
            anim_list.push_back(anim);
          }
        }
        
      }
      else
      {
        fprintf(stderr, "initAnimations: node '%s' not found in 3D model\n", node_name.c_str());
      }
    }
  }
}
开发者ID:ajakubek,项目名称:crrcsim_extensions,代码行数:79,代码来源:crrc_animation.cpp


注:本文中的SimpleXMLTransfer::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。