本文整理汇总了C++中MeshObject::push_vertex_normal方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshObject::push_vertex_normal方法的具体用法?C++ MeshObject::push_vertex_normal怎么用?C++ MeshObject::push_vertex_normal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshObject
的用法示例。
在下文中一共展示了MeshObject::push_vertex_normal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute_smooth_vertex_normals_base_pose
void compute_smooth_vertex_normals_base_pose(MeshObject& object)
{
assert(object.get_vertex_normal_count() == 0);
const size_t vertex_count = object.get_vertex_count();
const size_t triangle_count = object.get_triangle_count();
vector<GVector3> normals(vertex_count, GVector3(0.0));
for (size_t i = 0; i < triangle_count; ++i)
{
Triangle& triangle = object.get_triangle(i);
triangle.m_n0 = triangle.m_v0;
triangle.m_n1 = triangle.m_v1;
triangle.m_n2 = triangle.m_v2;
const GVector3& v0 = object.get_vertex(triangle.m_v0);
const GVector3& v1 = object.get_vertex(triangle.m_v1);
const GVector3& v2 = object.get_vertex(triangle.m_v2);
const GVector3 normal = normalize(cross(v1 - v0, v2 - v0));
normals[triangle.m_v0] += normal;
normals[triangle.m_v1] += normal;
normals[triangle.m_v2] += normal;
}
object.reserve_vertex_normals(vertex_count);
for (size_t i = 0; i < vertex_count; ++i)
object.push_vertex_normal(safe_normalize(normals[i]));
}