本文整理汇总了C++中AACube::getCorner方法的典型用法代码示例。如果您正苦于以下问题:C++ AACube::getCorner方法的具体用法?C++ AACube::getCorner怎么用?C++ AACube::getCorner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AACube
的用法示例。
在下文中一共展示了AACube::getCorner方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例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: 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;
}
示例4: touches
bool AABox::touches(const AACube& otherCube) const {
glm::vec3 relativeCenter = _corner - otherCube.getCorner() + ((_scale - otherCube.getDimensions()) * 0.5f);
glm::vec3 totalHalfScale = (_scale + otherCube.getDimensions()) * 0.5f;
return fabsf(relativeCenter.x) <= totalHalfScale.x &&
fabsf(relativeCenter.y) <= totalHalfScale.y &&
fabsf(relativeCenter.z) <= totalHalfScale.z;
}
示例5: 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;
}
示例6: getProjectedPolygon
OctreeProjectedPolygon ViewFrustum::getProjectedPolygon(const AACube& box) const {
const glm::vec3& bottomNearRight = box.getCorner();
glm::vec3 topFarLeft = box.calcTopFarLeft();
int lookUp = ((_position.x < bottomNearRight.x) ) // 1 = right | compute 6-bit
+ ((_position.x > topFarLeft.x ) << 1) // 2 = left | code to
+ ((_position.y < bottomNearRight.y) << 2) // 4 = bottom | classify camera
+ ((_position.y > topFarLeft.y ) << 3) // 8 = top | with respect to
+ ((_position.z < bottomNearRight.z) << 4) // 16 = front/near | the 6 defining
+ ((_position.z > topFarLeft.z ) << 5); // 32 = back/far | planes
int vertexCount = hullVertexLookup[lookUp][0]; //look up number of vertices
OctreeProjectedPolygon projectedPolygon(vertexCount);
bool pointInView = true;
bool allPointsInView = false; // assume the best, but wait till we know we have a vertex
bool anyPointsInView = false; // assume the worst!
if (vertexCount) {
allPointsInView = true; // assume the best!
for(int i = 0; i < vertexCount; i++) {
int vertexNum = hullVertexLookup[lookUp][i+1];
glm::vec3 point = box.getVertex((BoxVertex)vertexNum);
glm::vec2 projectedPoint = projectPoint(point, pointInView);
allPointsInView = allPointsInView && pointInView;
anyPointsInView = anyPointsInView || pointInView;
projectedPolygon.setVertex(i, projectedPoint);
}
/***
// Now that we've got the polygon, if it extends beyond the clipping window, then let's clip it
// NOTE: This clipping does not improve our overall performance. It basically causes more polygons to
// end up in the same quad/half and so the polygon lists get longer, and that's more calls to polygon.occludes()
if ( (projectedPolygon.getMaxX() > PolygonClip::RIGHT_OF_CLIPPING_WINDOW ) ||
(projectedPolygon.getMaxY() > PolygonClip::TOP_OF_CLIPPING_WINDOW ) ||
(projectedPolygon.getMaxX() < PolygonClip::LEFT_OF_CLIPPING_WINDOW ) ||
(projectedPolygon.getMaxY() < PolygonClip::BOTTOM_OF_CLIPPING_WINDOW) ) {
CoverageRegion::_clippedPolygons++;
glm::vec2* clippedVertices;
int clippedVertexCount;
PolygonClip::clipToScreen(projectedPolygon.getVertices(), vertexCount, clippedVertices, clippedVertexCount);
// Now reset the vertices of our projectedPolygon object
projectedPolygon.setVertexCount(clippedVertexCount);
for(int i = 0; i < clippedVertexCount; i++) {
projectedPolygon.setVertex(i, clippedVertices[i]);
}
delete[] clippedVertices;
lookUp += PROJECTION_CLIPPED;
}
***/
}
// set the distance from our camera position, to the closest vertex
float distance = glm::distance(getPosition(), box.calcCenter());
projectedPolygon.setDistance(distance);
projectedPolygon.setAnyInView(anyPointsInView);
projectedPolygon.setAllInView(allPointsInView);
projectedPolygon.setProjectionType(lookUp); // remember the projection type
return projectedPolygon;
}
示例7:
AABox::AABox(const AACube& other) :
_corner(other.getCorner()), _scale(other.getScale(), other.getScale(), other.getScale()) {
}
示例8: 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");
//.........这里部分代码省略.........