本文整理汇总了C++中MeshObject::get_vertex_count方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshObject::get_vertex_count方法的具体用法?C++ MeshObject::get_vertex_count怎么用?C++ MeshObject::get_vertex_count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshObject
的用法示例。
在下文中一共展示了MeshObject::get_vertex_count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]));
}
示例2: compute_smooth_vertex_tangents_base_pose
void compute_smooth_vertex_tangents_base_pose(MeshObject& object)
{
assert(object.get_vertex_tangent_count() == 0);
assert(object.get_tex_coords_count() > 0);
const size_t vertex_count = object.get_vertex_count();
const size_t triangle_count = object.get_triangle_count();
vector<GVector3> tangents(vertex_count, GVector3(0.0));
for (size_t i = 0; i < triangle_count; ++i)
{
const Triangle& triangle = object.get_triangle(i);
if (!triangle.has_vertex_attributes())
continue;
const GVector2 v0_uv = object.get_tex_coords(triangle.m_a0);
const GVector2 v1_uv = object.get_tex_coords(triangle.m_a1);
const GVector2 v2_uv = object.get_tex_coords(triangle.m_a2);
//
// Reference:
//
// Physically Based Rendering, first edition, pp. 128-129
//
const GScalar du0 = v0_uv[0] - v2_uv[0];
const GScalar dv0 = v0_uv[1] - v2_uv[1];
const GScalar du1 = v1_uv[0] - v2_uv[0];
const GScalar dv1 = v1_uv[1] - v2_uv[1];
const GScalar det = du0 * dv1 - dv0 * du1;
if (det == GScalar(0.0))
continue;
const GVector3& v2 = object.get_vertex(triangle.m_v2);
const GVector3 dp0 = object.get_vertex(triangle.m_v0) - v2;
const GVector3 dp1 = object.get_vertex(triangle.m_v1) - v2;
const GVector3 tangent = normalize(dv1 * dp0 - dv0 * dp1);
tangents[triangle.m_v0] += tangent;
tangents[triangle.m_v1] += tangent;
tangents[triangle.m_v2] += tangent;
}
object.reserve_vertex_tangents(vertex_count);
for (size_t i = 0; i < vertex_count; ++i)
object.push_vertex_tangent(safe_normalize(tangents[i]));
}
示例3: compute_smooth_vertex_normals_pose
void compute_smooth_vertex_normals_pose(MeshObject& object, const size_t motion_segment_index)
{
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)
{
const Triangle& triangle = object.get_triangle(i);
const GVector3& v0 = object.get_vertex_pose(triangle.m_v0, motion_segment_index);
const GVector3& v1 = object.get_vertex_pose(triangle.m_v1, motion_segment_index);
const GVector3& v2 = object.get_vertex_pose(triangle.m_v2, motion_segment_index);
const GVector3 normal = normalize(cross(v1 - v0, v2 - v0));
normals[triangle.m_v0] += normal;
normals[triangle.m_v1] += normal;
normals[triangle.m_v2] += normal;
}
for (size_t i = 0; i < vertex_count; ++i)
object.set_vertex_normal_pose(i, motion_segment_index, safe_normalize(normals[i]));
}