本文整理汇总了C++中SimpleXMLTransfer::attributeAsDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleXMLTransfer::attributeAsDouble方法的具体用法?C++ SimpleXMLTransfer::attributeAsDouble怎么用?C++ SimpleXMLTransfer::attributeAsDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLTransfer
的用法示例。
在下文中一共展示了SimpleXMLTransfer::attributeAsDouble方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void T_AxisMapper::init(SimpleXMLTransfer* cfgfile, std::string childname)
{
#if DEBUG_TX_INTERFACE > 0
printf("T_AxisMapper::init(cfg, child)\n");
printf(" <-- %s\n", childname.c_str());
#endif
SimpleXMLTransfer* inter;
SimpleXMLTransfer* bindings;
SimpleXMLTransfer* group;
SimpleXMLTransfer* item;
child_in_cfg = childname;
// try to load config
try
{
inter = cfgfile->getChild(childname, true);
bindings = inter->getChild("bindings", true);
group = bindings->getChild("axes", true);
for (int i = T_AxisMapper::AILERON; i <= T_AxisMapper::PITCH; i++)
{
int default_axis = -1;
float default_polarity = 1.0;
// special handling for some default values
if (i == T_AxisMapper::AILERON)
{
default_axis = 0;
}
else if (i == T_AxisMapper::ELEVATOR)
{
default_axis = 1;
if (iface->inputMethod() != T_TX_Interface::eIM_joystick)
{
default_polarity = -1.0;
}
}
item = group->getChild(Global::inputDev->AxisStringsXML[i], true);
c_func[i] = item->attributeAsInt("axis", default_axis);
c_inv[i] = item->attributeAsDouble("polarity", default_polarity);
}
std::string radio =
strU(bindings->attribute("radio_type", RadioTypeStrings[CUSTOM]));
for (int n=0; n < NR_OF_RADIO_TYPES; n++)
{
if (radio.compare(strU(RadioTypeStrings[n])) == 0)
{
setRadioType(n);
}
}
}
catch (XMLException e)
{
fprintf(stderr, "*** T_AxisMapper: XMLException: %s\n", e.what());
}
}
示例2: SimpleXMLTransfer
void Power::Propeller::ReloadParams(SimpleXMLTransfer* xml)
{
Gearing::ReloadParams(xml);
SimpleXMLTransfer* prop;
bool fExtern = true;
if (xml->indexOfAttribute("filename") >= 0)
{
prop = new SimpleXMLTransfer(FileSysTools::getDataPath("models/propeller/" + xml->getString("filename") + ".xml", true));
}
else
{
prop = xml;
fExtern = false;
}
// Der Sturz wird in jedem Fall aus der Modelldatei gelesen, ansonsten muss man ja eine
// Propellerdatei fuer jeden Sturz extra haben.
CalcDownthrust(xml);
D = prop->getDouble("D");
H = prop->getDouble("H");
J = prop->getDouble("J");
omega_fold = prop->attributeAsDouble("n_fold", -1)*2*M_PI;
std::cout << " Propeller: D=" << D << " m, H=" << H << " m, J=" << J << " kg m^2";
if (fExtern)
delete prop;
}
示例3: CalcDownthrust
void Power::Propeller::ReloadParams_automagic(SimpleXMLTransfer* xml)
{
SimpleXMLTransfer* p = xml->getChild("battery.shaft.propeller");
D = p->getDouble("D");
H = p->getDouble("H");
J = p->getDouble("J");
double F = xml->getDouble("F");
double V = xml->getDouble("V");
// Der Sturz wird in jedem Fall aus der Modelldatei gelesen, ansonsten muss man ja eine
// Propellerdatei fuer jeden Sturz extra haben.
CalcDownthrust(p);
{
// Calculate rotational speed and torque needed:
// F = M_PI * 0.25 * D*D * RHO * (V_X + filter.val/2) * filter.val * ETA_PROP;
// F = M_PI * 0.25 * D*D * RHO * (V + (Hn-V)/2) * (Hn-V) * ETA_PROP;
// F = M_PI * 0.25 * D*D * RHO * (V/2 + Hn/2) * (Hn-V) * ETA_PROP;
double n = sqrt( (8*F/(M_PI*D*D*RHO*ETA_PROP)) + V*V)/H;
double M = F * (V + (V + H*n)/2) / (2*M_PI*n) * i;
// Save these values so the engine can adjust itself to them:
p->setAttribute("automagic.n_P", doubleToString(n));
p->setAttribute("automagic.M_P", doubleToString(M));
}
omega_fold = p->attributeAsDouble("n_fold", -1)*2*M_PI;
}
示例4: runtime_error
CRRCAirplaneV2::CRRCAirplaneV2(SimpleXMLTransfer* xml)
{
printf("CRRCAirplaneV2(xml)\n");
// initialize the airplane's sound
initSound(xml);
// initialize the visual representation
// first collect all relevant information from the model file
std::string s;
s = XMLModelFile::getGraphics(xml)->getString("model");
// Offset of center of gravity
CRRCMath::Vector3 pCG;
pCG = CRRCMath::Vector3(0, 0, 0);
if (xml->indexOfChild("CG") >= 0)
{
SimpleXMLTransfer* i;
i = xml->getChild("CG");
pCG.r[0] = i->attributeAsDouble("x", 0);
pCG.r[1] = i->attributeAsDouble("y", 0);
pCG.r[2] = i->attributeAsDouble("z", 0);
if (i->attributeAsInt("units") == 1)
pCG *= M_TO_FT;
}
// 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/" + s);
// compile and set relative texture path
std::string tp = of.substr(0, of.length()-s.length()-1-7) + "textures";
lVisID = Video::new_visualization(of, tp, pCG, xml);
if (lVisID == INVALID_AIRPLANE_VISUALIZATION)
{
std::string msg = "Unable to open airplane model file \"";
msg += s;
msg += "\"\nspecified in \"";
msg += xml->getSourceDescr();
msg += "\"";
throw std::runtime_error(msg);
}
}
示例5: runtime_error
/** \brief The constructor.
*
* Loads an airplane model from an xml description. The 3D model
* will be added to the specified scenegraph.
*
* \param xml XML model description file
* \param graph Pointer to the scenegraph which shall render the model
*/
CRRCAirplaneLaRCSimSSG::CRRCAirplaneLaRCSimSSG(SimpleXMLTransfer* xml, ssgBranch *graph)
: CRRCAirplaneLaRCSim(xml), initial_trans(NULL),
model_trans(NULL), model(NULL),
shadow(NULL), shadow_trans(NULL)
{
printf("CRRCAirplaneLaRCSimSSG(xml, branch)\n");
std::string s;
s = XMLModelFile::getGraphics(xml)->getString("model");
// 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/" + s);
// compile and set relative texture path
std::string tp = of.substr(0, of.length()-s.length()-1-7) + "textures";
ssgTexturePath(tp.c_str());
// load model
model = ssgLoad(of.c_str());
}
if (model != NULL)
{
// Offset of center of gravity
CRRCMath::Vector3 pCG;
pCG = CRRCMath::Vector3(0, 0, 0);
if (xml->indexOfChild("CG") >= 0)
{
SimpleXMLTransfer* i;
i = xml->getChild("CG");
pCG.r[0] = i->attributeAsDouble("x", 0);
pCG.r[1] = i->attributeAsDouble("y", 0);
pCG.r[2] = i->attributeAsDouble("z", 0);
if (i->attributeAsInt("units") == 1)
pCG *= M_TO_FT;
}
// transform model from SSG coordinates to CRRCsim coordinates
initial_trans = new ssgTransform();
model_trans = new ssgTransform();
graph->addKid(model_trans);
model_trans->addKid(initial_trans);
initial_trans->addKid(model);
sgMat4 it = { {1.0, 0.0, 0.0, 0},
{0.0, 0.0, -1.0, 0},
{0.0, 1.0, 0.0, 0},
{pCG.r[1], pCG.r[2], -pCG.r[0], 1.0} };
initial_trans->setTransform(it);
// add a simple shadow
shadow = (ssgEntity*)initial_trans->clone(SSG_CLONE_RECURSIVE | SSG_CLONE_GEOMETRY | SSG_CLONE_STATE);
makeShadow(shadow);
shadow_trans = new ssgTransform();
graph->addKid(shadow_trans);
shadow_trans->addKid(shadow);
// add animations ("real" model only, without shadow)
initAnimations(xml, model, &Global::inputs, animations);
}
else
{
std::string msg = "Unable to open airplane model file \"";
msg += s;
msg += "\"\nspecified in \"";
msg += xml->getSourceDescr();
msg += "\"";
throw std::runtime_error(msg);
}
}
示例6: 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
{
//.........这里部分代码省略.........