本文整理汇总了C++中AACube::getScale方法的典型用法代码示例。如果您正苦于以下问题:C++ AACube::getScale方法的具体用法?C++ AACube::getScale怎么用?C++ AACube::getScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AACube
的用法示例。
在下文中一共展示了AACube::getScale方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::VisibleElement& next,
const DiffTraversal::View& view, const DiffTraversal::View& lastView) {
if (_nextIndex == -1) {
// root case is special
++_nextIndex;
EntityTreeElementPointer element = _weakElement.lock();
next.element = element;
next.intersection = ViewFrustum::INTERSECT;
return;
} else if (_nextIndex < NUMBER_OF_CHILDREN) {
EntityTreeElementPointer element = _weakElement.lock();
if (element) {
while (_nextIndex < NUMBER_OF_CHILDREN) {
EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex);
++_nextIndex;
if (nextElement) {
AACube cube = nextElement->getAACube();
// check for LOD truncation
float distance = glm::distance(view.viewFrustum.getPosition(), cube.calcCenter()) + MIN_VISIBLE_DISTANCE;
float angularDiameter = cube.getScale() / distance;
if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) {
if (view.viewFrustum.calculateCubeKeyholeIntersection(cube) != ViewFrustum::OUTSIDE) {
next.element = nextElement;
next.intersection = ViewFrustum::OUTSIDE;
return;
}
}
}
}
}
}
next.element.reset();
next.intersection = ViewFrustum::OUTSIDE;
}
示例2: getFurthestPointFromCamera
// Similar strategy to getProjectedPolygon() we use the knowledge of camera position relative to the
// axis-aligned voxels to determine which of the voxels vertices must be the furthest. No need for
// squares and square-roots. Just compares.
void ViewFrustum::getFurthestPointFromCamera(const AACube& box, glm::vec3& furthestPoint) const {
const glm::vec3& bottomNearRight = box.getCorner();
float scale = box.getScale();
float halfScale = scale * 0.5f;
if (_position.x < bottomNearRight.x + halfScale) {
// we are to the right of the center, so the left edge is furthest
furthestPoint.x = bottomNearRight.x + scale;
} else {
furthestPoint.x = bottomNearRight.x;
}
if (_position.y < bottomNearRight.y + halfScale) {
// we are below of the center, so the top edge is furthest
furthestPoint.y = bottomNearRight.y + scale;
} else {
furthestPoint.y = bottomNearRight.y;
}
if (_position.z < bottomNearRight.z + halfScale) {
// we are to the near side of the center, so the far side edge is furthest
furthestPoint.z = bottomNearRight.z + scale;
} else {
furthestPoint.z = bottomNearRight.z;
}
}
示例3: getAngularSize
float ConicalViewFrustum::getAngularSize(const AACube& cube) const {
auto radius = 0.5f * SQRT_THREE * cube.getScale(); // radius of bounding sphere
auto position = cube.calcCenter() - _position; // position of bounding sphere in view-frame
float distance = glm::length(position);
return getAngularSize(distance, radius);
}
示例4: getMyChildContaining
int OctreeElement::getMyChildContaining(const AACube& cube) const {
float ourScale = getScale();
float cubeScale = cube.getScale();
// TODO: consider changing this to assert()
if (cubeScale > ourScale) {
qCDebug(octree) << "UNEXPECTED -- OctreeElement::getMyChildContaining() -- (cubeScale > ourScale)";
qCDebug(octree) << " cube=" << cube;
qCDebug(octree) << " elements AACube=" << _cube;
qCDebug(octree) << " cubeScale=" << cubeScale;
qCDebug(octree) << " ourScale=" << ourScale;
assert(false);
}
// Determine which of our children the minimum and maximum corners of the cube live in...
glm::vec3 cubeCornerMinimum = glm::clamp(cube.getCorner(), (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
glm::vec3 cubeCornerMaximum = glm::clamp(cube.calcTopFarLeft(), (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
if (_cube.contains(cubeCornerMinimum) && _cube.contains(cubeCornerMaximum)) {
int childIndexCubeMinimum = getMyChildContainingPoint(cubeCornerMinimum);
int childIndexCubeMaximum = getMyChildContainingPoint(cubeCornerMaximum);
// If the minimum and maximum corners of the cube are in two different children's cubes, then we are the containing element
if (childIndexCubeMinimum != childIndexCubeMaximum) {
return CHILD_UNKNOWN;
}
return childIndexCubeMinimum; // either would do, they are the same
}
return CHILD_UNKNOWN; // since cube is not contained in our element, it can't be in one of our children
}
示例5: aaCubeToScriptValue
QScriptValue aaCubeToScriptValue(QScriptEngine* engine, const AACube& aaCube) {
QScriptValue obj = engine->newObject();
const glm::vec3& corner = aaCube.getCorner();
obj.setProperty("x", corner.x);
obj.setProperty("y", corner.y);
obj.setProperty("z", corner.z);
obj.setProperty("scale", aaCube.getScale());
return obj;
}
示例6: appendValue
bool OctreePacketData::appendValue(const AACube& aaCube) {
aaCubeData cube { aaCube.getCorner(), aaCube.getScale() };
const unsigned char* data = (const unsigned char*)&cube;
int length = sizeof(aaCubeData);
bool success = append(data, length);
if (success) {
_bytesOfValues += length;
_totalBytesOfValues += length;
}
return success;
}
示例7: updateVoxels
void VoxelShapeManager::updateVoxels(const quint64& now, CubeList& cubes) {
const quint64 VOXEL_UPDATE_PERIOD = 100000; // usec
_updateExpiry = now + VOXEL_UPDATE_PERIOD;
PhysicsSimulation* simulation = getSimulation();
if (!simulation) {
return;
}
int numChanges = 0;
VoxelPool::iterator voxelItr = _voxels.begin();
while (voxelItr != _voxels.end()) {
// look for this voxel in cubes
CubeList::iterator cubeItr = cubes.find(voxelItr.key());
if (cubeItr == cubes.end()) {
// did not find it --> remove the voxel
simulation->removeShape(voxelItr.value()._shape);
voxelItr = _voxels.erase(voxelItr);
++numChanges;
} else {
// found it --> remove the cube
cubes.erase(cubeItr);
voxelItr++;
}
}
// add remaining cubes to _voxels
glm::vec3 simulationOrigin = simulation->getTranslation();
CubeList::const_iterator cubeItr = cubes.constBegin();
while (cubeItr != cubes.constEnd()) {
AACube cube = cubeItr.value();
AACubeShape* shape = new AACubeShape(cube.getScale(), cube.calcCenter() - simulationOrigin);
shape->setEntity(this);
VoxelInfo voxel = {cube, shape };
_voxels.insert(cubeItr.key(), voxel);
++numChanges;
++cubeItr;
}
if (numChanges > 0) {
buildShapes();
}
}
示例8:
AABox::AABox(const AACube& other) :
_corner(other.getCorner()), _scale(other.getScale(), other.getScale(), other.getScale()) {
}
示例9: recalculateCollisionShape
void EntityItem::recalculateCollisionShape() {
AACube entityAACube = getMinimumAACube();
entityAACube.scale(TREE_SCALE); // scale to meters
_collisionShape.setTranslation(entityAACube.calcCenter());
_collisionShape.setScale(entityAACube.getScale());
}
示例10: entityTreeTests
void EntityTests::entityTreeTests(bool verbose) {
bool extraVerbose = false;
int testsTaken = 0;
int testsPassed = 0;
int testsFailed = 0;
if (verbose) {
qDebug() << "******************************************************************************************";
}
qDebug() << "EntityTests::entityTreeTests()";
// Tree, id, and entity properties used in many tests below...
EntityTree tree;
QUuid id = QUuid::createUuid();
EntityItemID entityID(id);
entityID.isKnownID = false; // this is a temporary workaround to allow local tree entities to be added with known IDs
EntityItemProperties properties;
float oneMeter = 1.0f;
//float halfMeter = oneMeter / 2.0f;
float halfOfDomain = TREE_SCALE * 0.5f;
glm::vec3 positionNearOriginInMeters(oneMeter, oneMeter, oneMeter); // when using properties, these are in meter not tree units
glm::vec3 positionAtCenterInMeters(halfOfDomain, halfOfDomain, halfOfDomain);
glm::vec3 positionNearOriginInTreeUnits = positionNearOriginInMeters / (float)TREE_SCALE;
glm::vec3 positionAtCenterInTreeUnits = positionAtCenterInMeters / (float)TREE_SCALE;
{
testsTaken++;
QString testName = "add entity to tree and search";
if (verbose) {
qDebug() << "Test" << testsTaken <<":" << qPrintable(testName);
}
properties.setPosition(positionAtCenterInMeters);
// TODO: Fix these unit tests.
//properties.setRadius(halfMeter);
//properties.setModelURL("http://s3.amazonaws.com/hifi-public/ozan/theater.fbx");
tree.addEntity(entityID, properties);
float targetRadius = oneMeter * 2.0 / (float)TREE_SCALE; // in tree units
const EntityItem* foundEntityByRadius = tree.findClosestEntity(positionAtCenterInTreeUnits, targetRadius);
const EntityItem* foundEntityByID = tree.findEntityByEntityItemID(entityID);
EntityTreeElement* containingElement = tree.getContainingElement(entityID);
AACube elementCube = containingElement ? containingElement->getAACube() : AACube();
if (verbose) {
qDebug() << "foundEntityByRadius=" << foundEntityByRadius;
qDebug() << "foundEntityByID=" << foundEntityByID;
qDebug() << "containingElement=" << containingElement;
qDebug() << "containingElement.box="
<< elementCube.getCorner().x * TREE_SCALE << ","
<< elementCube.getCorner().y * TREE_SCALE << ","
<< elementCube.getCorner().z * TREE_SCALE << ":"
<< elementCube.getScale() * TREE_SCALE;
qDebug() << "elementCube.getScale()=" << elementCube.getScale();
//containingElement->printDebugDetails("containingElement");
}
bool passed = foundEntityByRadius && foundEntityByID && (foundEntityByRadius == foundEntityByID);
if (passed) {
testsPassed++;
} else {
testsFailed++;
qDebug() << "FAILED - Test" << testsTaken <<":" << qPrintable(testName);
}
}
entityID.isKnownID = true; // this is a temporary workaround to allow local tree entities to be added with known IDs
{
testsTaken++;
QString testName = "change position of entity in tree";
if (verbose) {
qDebug() << "Test" << testsTaken <<":" << qPrintable(testName);
}
glm::vec3 newPosition = positionNearOriginInMeters;
properties.setPosition(newPosition);
tree.updateEntity(entityID, properties);
float targetRadius = oneMeter * 2.0 / (float)TREE_SCALE; // in tree units
const EntityItem* foundEntityByRadius = tree.findClosestEntity(positionNearOriginInTreeUnits, targetRadius);
const EntityItem* foundEntityByID = tree.findEntityByEntityItemID(entityID);
EntityTreeElement* containingElement = tree.getContainingElement(entityID);
AACube elementCube = containingElement ? containingElement->getAACube() : AACube();
if (verbose) {
qDebug() << "foundEntityByRadius=" << foundEntityByRadius;
qDebug() << "foundEntityByID=" << foundEntityByID;
qDebug() << "containingElement=" << containingElement;
qDebug() << "containingElement.box="
<< elementCube.getCorner().x * TREE_SCALE << ","
<< elementCube.getCorner().y * TREE_SCALE << ","
<< elementCube.getCorner().z * TREE_SCALE << ":"
<< elementCube.getScale() * TREE_SCALE;
//containingElement->printDebugDetails("containingElement");
//.........这里部分代码省略.........