本文整理汇总了C++中BBox::highCorner方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::highCorner方法的具体用法?C++ BBox::highCorner怎么用?C++ BBox::highCorner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBox
的用法示例。
在下文中一共展示了BBox::highCorner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNewEntity
void SpawnerProperty::createNewEntity(LocatedEntity * e, const Operation & op,
OpVector & res, const std::string& locId)
{
Anonymous create_arg;
if (!m_entity.empty()) {
create_arg = smart_dynamic_cast<Anonymous>(
Factories::instance()->createObject(m_entity));
if (!create_arg.isValid()) {
log(ERROR,
"Could not parse 'entity' data on spawner into Entity instance.");
return;
}
} else {
create_arg->setParents(std::list<std::string>(1, m_type));
}
create_arg->setLoc(locId);
WFMath::MTRand& rand = WFMath::MTRand::instance;
if (m_mode_external) {
if (!e->m_location.pos().isValid()) {
log(ERROR,
"Tried to spawn entity for which parent has no valid position.");
return;
}
//randomize position and rotation
float angle = rand.randf(WFMath::numeric_constants<float>::pi() * 2);
//place it between 0 and 2 meters away
float distance = rand.randf(2.0f);
//if we're solid we should make sure it's not within our own radius
if (e->m_location.isSolid() && e->m_location.bBox().isValid()) {
distance += e->m_location.radius();
}
//and finally make sure that it's not beyond the radius for checking
if (m_radius != 0.0f) {
distance = std::min(m_radius, distance);
}
float x = (distance * std::cos(angle));
float y = (distance * std::sin(angle));
::addToEntity(
WFMath::Point<3>(e->m_location.pos()).shift(
WFMath::Vector<3>(x, y, 0)), create_arg->modifyPos());
} else {
//If it's an internal spawner, spawn anywhere within the bounding box.
const BBox bbox = e->m_location.m_bBox;
if (bbox.isValid()) {
float x = rand.rand(bbox.highCorner().x() - bbox.lowCorner().x())
+ bbox.lowCorner().x();
float y = rand.rand(bbox.highCorner().y() - bbox.lowCorner().y())
+ bbox.lowCorner().y();
::addToEntity(WFMath::Point<3>(x, y, 0), create_arg->modifyPos());
} else {
::addToEntity(WFMath::Point<3>::ZERO(), create_arg->modifyPos());
}
}
float rotation = rand.randf(WFMath::numeric_constants<float>::pi() * 2);
WFMath::Quaternion orientation(WFMath::Vector<3>(0, 0, 1), rotation);
create_arg->setAttr("orientation", orientation.toAtlas());
Create create;
create->setTo(e->m_location.m_loc->getId());
create->setArgs1(create_arg);
res.push_back(create);
debug(log(NOTICE, compose("Spawner belonging to entity %1 creating new"
" entity of type %2", e->getId(), m_type))
;);