本文整理汇总了C++中TwoDScene::setFixed方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDScene::setFixed方法的具体用法?C++ TwoDScene::setFixed怎么用?C++ TwoDScene::setFixed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDScene
的用法示例。
在下文中一共展示了TwoDScene::setFixed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadParticles
//.........这里部分代码省略.........
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse vx attribute for particle " << particle << ". Exiting." << std::endl;
exit(1);
}
if( nd->first_attribute("vy") )
{
std::string attribute(nd->first_attribute("vy")->value());
if( !stringutils::extractFromString(attribute,vel.y()) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of vy attribute for particle " << particle << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse vy attribute for particle " << particle << ". Exiting." << std::endl;
exit(1);
}
if( nd->first_attribute("vz") )
{
std::string attribute(nd->first_attribute("vz")->value());
if( !stringutils::extractFromString(attribute,vel.z()) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of vz attribute for particle " << particle << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse vz attribute for particle " << particle << ". Exiting." << std::endl;
exit(1);
}
twodscene.setVelocity( particle, vel );
// Extract the particle's mass
scalar mass = std::numeric_limits<scalar>::signaling_NaN();
if( nd->first_attribute("m") )
{
std::string attribute(nd->first_attribute("m")->value());
if( !stringutils::extractFromString(attribute,mass) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of m attribute for particle " << particle << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse m attribute for particle " << particle << ". Exiting." << std::endl;
exit(1);
}
twodscene.setMass( particle, mass );
// Determine if the particle is fixed
bool fixed;
if( nd->first_attribute("fixed") )
{
std::string attribute(nd->first_attribute("fixed")->value());
if( !stringutils::extractFromString(attribute,fixed) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of fixed attribute for particle " << particle << ". Value must be boolean. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse fixed attribute for particle " << particle << ". Exiting." << std::endl;
exit(1);
}
twodscene.setFixed( particle, fixed );
// Extract the particle's radius, if present
scalar radius = 0.1;
if( nd->first_attribute("radius") )
{
std::string attribute(nd->first_attribute("radius")->value());
if( !stringutils::extractFromString(attribute,radius) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse radius attribute for particle " << particle << ". Value must be scalar. Exiting." << std::endl;
exit(1);
}
}
twodscene.setRadius( particle, radius );
// Extract the particle's tag, if present
if( nd->first_attribute("tag") )
{
std::string tag(nd->first_attribute("tag")->value());
tags[particle] = tag;
}
//std::cout << "Particle: " << particle << " x: " << pos.transpose() << " v: " << vel.transpose() << " m: " << mass << " fixed: " << fixed << std::endl;
//std::cout << tags[particle] << std::endl;
++particle;
}
}