本文整理汇总了C++中TriMesh::compute_areas方法的典型用法代码示例。如果您正苦于以下问题:C++ TriMesh::compute_areas方法的具体用法?C++ TriMesh::compute_areas怎么用?C++ TriMesh::compute_areas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriMesh
的用法示例。
在下文中一共展示了TriMesh::compute_areas方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_background_mesh
TriMesh* Scene::load_background_mesh(const string& filename, const Mat4x4f& transform)
{
TriMesh* mesh = new TriMesh;
obj_load(filename, *mesh);
if(!mesh->has_normals())
{
cout << "Computing normals" << endl;
mesh->compute_normals();
}
mesh->transform(transform);
mesh->compute_areas();
cout << "No. of triangles: " << mesh->geometry.no_faces() << endl;
meshes.push_back(mesh);
return mesh;
}
示例2: extract_area_lights
unsigned int Scene::extract_area_lights(RayTracer* tracer, unsigned int samples_per_light)
{
light_tracer = tracer;
for(unsigned int i = 0; i < meshes.size(); ++i)
{
TriMesh* mesh = new TriMesh;
const vector<int>& indices = meshes[i]->mat_idx;
for(unsigned int j = 0; j < indices.size(); ++j)
{
const ObjMaterial& mat = meshes[i]->materials[indices[j]];
if(mat.name == "default")
continue;
bool emissive = false;
for(unsigned int k = 0; k < 3; ++k)
emissive = emissive || (meshes[i]->materials[indices[j]].ambient[k] > 0.0f);
if(emissive)
{
Vec3i g_face = meshes[i]->geometry.face(j);
for(unsigned int k = 0; k < 3; ++k)
g_face[k] = mesh->geometry.add_vertex(meshes[i]->geometry.vertex(g_face[k]));
int idx = mesh->geometry.add_face(g_face);
if(meshes[i]->normals.no_faces() > j)
{
Vec3i n_face = meshes[i]->normals.face(j);
for(unsigned int k = 0; k < 3; ++k)
n_face[k] = mesh->normals.add_vertex(meshes[i]->normals.vertex(n_face[k]));
mesh->normals.add_face(n_face, idx);
}
if(meshes[i]->texcoords.no_faces() > j)
{
Vec3i t_face = meshes[i]->texcoords.face(j);
for(unsigned int k = 0; k < 3; ++k)
t_face[k] = mesh->texcoords.add_vertex(meshes[i]->texcoords.vertex(t_face[k]));
mesh->texcoords.add_face(t_face, idx);
}
bool material_exists = false;
for(unsigned int k = 0; k < mesh->materials.size(); ++k)
if(mesh->materials[k].name == meshes[i]->materials[indices[j]].name)
{
mesh->mat_idx.push_back(k);
material_exists = true;
break;
}
if(!material_exists)
{
mesh->mat_idx.push_back(mesh->materials.size());
mesh->materials.push_back(meshes[i]->materials[indices[j]]);
}
}
}
if(mesh->geometry.no_faces() == 0)
delete mesh;
else
{
mesh->compute_areas();
light_meshes.push_back(mesh);
extracted_lights.push_back(lights.size());
lights.push_back(new AreaLight(light_tracer, mesh, samples_per_light));
}
}
return lights.size();
}