本文整理汇总了C++中Hash::getVector方法的典型用法代码示例。如果您正苦于以下问题:C++ Hash::getVector方法的具体用法?C++ Hash::getVector怎么用?C++ Hash::getVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hash
的用法示例。
在下文中一共展示了Hash::getVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBody
// Create a body (planet, moon, spacecraft, etc.) using the values from a
// property list. The usePlanetsUnits flags specifies whether period and
// semi-major axis are in years and AU rather than days and kilometers.
static Body* CreateBody(const string& name,
PlanetarySystem* system,
Universe& universe,
Body* existingBody,
Hash* planetData,
const string& path,
Disposition disposition,
BodyType bodyType)
{
Body* body = NULL;
if (disposition == ModifyObject || disposition == ReplaceObject)
{
body = existingBody;
}
if (body == NULL)
{
body = new Body(system, name);
// If the body doesn't exist, always treat the disposition as 'Add'
disposition = AddObject;
// Set the default classification for new objects based on the body type.
// This may be overridden by the Class property.
if (bodyType == SurfaceObject)
{
body->setClassification(Body::SurfaceFeature);
}
}
if (!CreateTimeline(body, system, universe, planetData, path, disposition, bodyType))
{
// No valid timeline given; give up.
if (body != existingBody)
delete body;
return NULL;
}
// Three values control the shape and size of an ellipsoidal object:
// semiAxes, radius, and oblateness. It is an error if neither the
// radius nor semiaxes are set. If both are set, the radius is
// multipled by each of the specified semiaxis to give the shape of
// the body ellipsoid. Oblateness is ignored if semiaxes are provided;
// otherwise, the ellipsoid has semiaxes: ( radius, radius, 1-radius ).
// These rather complex rules exist to maintain backward compatibility.
//
// If the body also has a mesh, it is always scaled in x, y, and z by
// the maximum semiaxis, never anisotropically.
double radius = (double) body->getRadius();
bool radiusSpecified = false;
if (planetData->getLength("Radius", radius))
{
body->setSemiAxes(Vector3f::Constant((float) radius));
radiusSpecified = true;
}
Vector3d semiAxes = Vector3d::Ones();
if (planetData->getVector("SemiAxes", semiAxes))
{
if (radiusSpecified)
{
// if the radius has been specified, treat SemiAxes as dimensionless
// (i.e. ignore units) and multiply the radius by the SemiAxes
semiAxes *= radius;
}
else
{
double semiAxesScale = 1.0;
planetData->getLengthScale("SemiAxes", semiAxesScale);
semiAxes *= semiAxesScale;
}
// Swap y and z to match internal coordinate system
body->setSemiAxes(Vector3f((float) semiAxes.x(), (float) semiAxes.z(), (float) semiAxes.y()));
}
else
{
double oblateness = 0.0;
if (planetData->getNumber("Oblateness", oblateness))
{
body->setSemiAxes((float) body->getRadius() * Vector3f(1.0f, 1.0f - (float) oblateness, 1.0f));
}
}
int classification = body->getClassification();
string classificationName;
if (planetData->getString("Class", classificationName))
classification = GetClassificationId(classificationName);
if (classification == Body::Unknown)
{
// Try to guess the type
if (system->getPrimaryBody() != NULL)
{
if(radius > 0.1)
classification = Body::Moon;
else
//.........这里部分代码省略.........
示例2: ReadFavoritesList
FavoritesList* ReadFavoritesList(istream& in)
{
FavoritesList* favorites = new FavoritesList();
Tokenizer tokenizer(&in);
Parser parser(&tokenizer);
while (tokenizer.nextToken() != Tokenizer::TokenEnd)
{
if (tokenizer.getTokenType() != Tokenizer::TokenString)
{
DPRINTF(0, "Error parsing favorites file.\n");
for_each(favorites->begin(), favorites->end(), deleteFunc<FavoritesEntry*>());
delete favorites;
return NULL;
}
FavoritesEntry* fav = new FavoritesEntry();
fav->name = tokenizer.getStringValue();
Value* favParamsValue = parser.readValue();
if (favParamsValue == NULL || favParamsValue->getType() != Value::HashType)
{
DPRINTF(0, "Error parsing favorites entry %s\n", fav->name.c_str());
for_each(favorites->begin(), favorites->end(), deleteFunc<FavoritesEntry*>());
delete favorites;
if (favParamsValue != NULL)
delete favParamsValue;
return NULL;
}
Hash* favParams = favParamsValue->getHash();
//If this is a folder, don't get any other params.
if(!favParams->getBoolean("isFolder", fav->isFolder))
fav->isFolder = false;
if(fav->isFolder)
{
favorites->insert(favorites->end(), fav);
continue;
}
// Get parentFolder
favParams->getString("parentFolder", fav->parentFolder);
// Get position
Vec3d base(0.0, 0.0, 0.0);
Vec3d offset(0.0, 0.0, 0.0);
favParams->getVector("base", base);
favParams->getVector("offset", offset);
base *= 1e6;
fav->position = UniversalCoord(Point3d(base.x, base.y, base.z)) + offset;
// Get orientation
Vec3d axis(1.0, 0.0, 0.0);
double angle = 0.0;
favParams->getVector("axis", axis);
favParams->getNumber("angle", angle);
fav->orientation.setAxisAngle(Vec3f((float) axis.x, (float) axis.y, (float) axis.z),
(float) angle);
// Get time
fav->jd = 0.0;
favParams->getNumber("time", fav->jd);
// Get the selected object
favParams->getString("selection", fav->selectionName);
string coordSysName;
favParams->getString("coordsys", coordSysName);
if (coordSysName == "ecliptical")
fav->coordSys = ObserverFrame::Ecliptical;
else if (coordSysName == "equatorial")
fav->coordSys = ObserverFrame::Equatorial;
else if (coordSysName == "geographic")
fav->coordSys = ObserverFrame::BodyFixed;
else
fav->coordSys = ObserverFrame::Universal;
favorites->insert(favorites->end(), fav);
}
return favorites;
}