本文整理汇总了C++中TriMesh::calcBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ TriMesh::calcBoundingBox方法的具体用法?C++ TriMesh::calcBoundingBox怎么用?C++ TriMesh::calcBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriMesh
的用法示例。
在下文中一共展示了TriMesh::calcBoundingBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regenerateVboMesh
void BatchedMesh::regenerateVboMesh(MaterialRef material) {
// cout << "BatchedMesh::regenerateVboMesh(): Regenerating VboMesh for
// material:"
// << material << endl;
TriMesh combinedMesh;
vector<Vec3f> vertices;
vector<ColorAf> colors;
vector<Vec2f> texCoords;
vector<uint32_t> indices;
uint32_t vertCount = 0;
_materialBounds[material] = AxisAlignedBox3f();
for (BatchInfoRef batchInfo : _meshes[material]) {
TriMesh *internalMesh = batchInfo->mesh->getInternalMesh(
batchInfo->transform->getTransformMatrixLocal());
vertices = internalMesh->getVertices();
combinedMesh.appendVertices(vertices.data(), vertices.size());
colors = internalMesh->getColorsRGBA();
combinedMesh.appendColorsRgba(colors.data(), colors.size());
texCoords = internalMesh->getTexCoords();
combinedMesh.appendTexCoords(texCoords.data(), texCoords.size());
indices = internalMesh->getIndices();
std::transform(std::begin(indices), std::end(indices), std::begin(indices),
[vertCount](uint32_t x) { return x + vertCount; });
combinedMesh.appendIndices(indices.data(), indices.size());
vertCount += vertices.size();
_materialBounds[material].include(internalMesh->calcBoundingBox());
}
_vboMeshes[material] = gl::VboMesh::create(combinedMesh);
// Recalculate master bounds
_bounds = AxisAlignedBox3f();
for (auto &kvp : _materialBounds) {
_bounds.include(kvp.second);
}
}
示例2: generateQuad
BaseMeshRef SimpleMesh::generateQuad(Rectf dimensions,
Rectf uvCoords = Rectf(0.0f, 0.0f, 1.0f,
1.0f)) {
// cout << "SimpleMesh::GenerateQuad(); dims: " << dimensions
// << " uvCoords: " << uvCoords << endl;
TriMesh mesh;
mesh.clear();
// Vertexes
mesh.appendVertex(Vec3f(dimensions.x1, dimensions.y1, 0));
mesh.appendVertex(Vec3f(dimensions.x1, dimensions.y2, 0));
mesh.appendVertex(Vec3f(dimensions.x2, dimensions.y2, 0));
mesh.appendVertex(Vec3f(dimensions.x2, dimensions.y1, 0));
// Vertex Colors
mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
// Tex coords
mesh.appendTexCoord(Vec2f(uvCoords.x1, uvCoords.y1));
mesh.appendTexCoord(Vec2f(uvCoords.x1, uvCoords.y2));
mesh.appendTexCoord(Vec2f(uvCoords.x2, uvCoords.y2));
mesh.appendTexCoord(Vec2f(uvCoords.x2, uvCoords.y1));
int vert0 = mesh.getNumVertices() - 4;
int vert1 = mesh.getNumVertices() - 1;
int vert2 = mesh.getNumVertices() - 2;
int vert3 = mesh.getNumVertices() - 3;
mesh.appendTriangle(vert0, vert1, vert3);
mesh.appendTriangle(vert3, vert1, vert2);
mesh.recalculateNormals();
SimpleMeshRef meshWrapper = make_shared<SimpleMesh>(mesh);
meshWrapper->_bounds = mesh.calcBoundingBox();
return dynamic_pointer_cast<BaseMesh>(meshWrapper);
}