本文整理汇总了C++中bgfx::VertexDecl::getOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexDecl::getOffset方法的具体用法?C++ VertexDecl::getOffset怎么用?C++ VertexDecl::getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bgfx::VertexDecl
的用法示例。
在下文中一共展示了VertexDecl::getOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseMeshesOld
//.........这里部分代码省略.........
if (indices_count <= 0) return false;
u32 INDICES_16BIT_FLAG = 1;
int index_size = global_flags & INDICES_16BIT_FLAG ? 2 : 4;
Array<u8> indices(m_allocator);
indices.resize(indices_count * index_size);
file.read(&indices[0], indices.size());
i32 vertices_size = 0;
file.read(&vertices_size, sizeof(vertices_size));
if (vertices_size <= 0) return false;
Array<u8> vertices(m_allocator);
vertices.resize(vertices_size);
file.read(&vertices[0], vertices.size());
int vertex_count = 0;
for (const Offsets& offsets : mesh_offsets)
{
vertex_count += offsets.attribute_array_size / global_vertex_decl.getStride();
}
if (version > FileVersion::BOUNDING_SHAPES_PRECOMPUTED)
{
file.read(&m_bounding_radius, sizeof(m_bounding_radius));
file.read(&m_aabb, sizeof(m_aabb));
}
float bounding_radius_squared = 0;
Vec3 min_vertex(0, 0, 0);
Vec3 max_vertex(0, 0, 0);
int vertex_size = global_vertex_decl.getStride();
int position_attribute_offset = global_vertex_decl.getOffset(bgfx::Attrib::Position);
int uv_attribute_offset = global_vertex_decl.getOffset(bgfx::Attrib::TexCoord0);
int weights_attribute_offset = global_vertex_decl.getOffset(bgfx::Attrib::Weight);
int bone_indices_attribute_offset = global_vertex_decl.getOffset(bgfx::Attrib::Indices);
bool keep_skin = global_vertex_decl.has(bgfx::Attrib::Weight) && global_vertex_decl.has(bgfx::Attrib::Indices);
for (int i = 0; i < m_meshes.size(); ++i)
{
Offsets& offsets = mesh_offsets[i];
Mesh& mesh = m_meshes[i];
mesh.indices_count = offsets.mesh_tri_count * 3;
mesh.indices.resize(mesh.indices_count * index_size);
copyMemory(&mesh.indices[0], &indices[offsets.indices_offset * index_size], mesh.indices_count * index_size);
int mesh_vertex_count = offsets.attribute_array_size / global_vertex_decl.getStride();
int mesh_attributes_array_offset = offsets.attribute_array_offset;
mesh.vertices.resize(mesh_vertex_count);
mesh.uvs.resize(mesh_vertex_count);
if (keep_skin) mesh.skin.resize(mesh_vertex_count);
for (int j = 0; j < mesh_vertex_count; ++j)
{
int offset = mesh_attributes_array_offset + j * vertex_size;
if (keep_skin)
{
mesh.skin[j].weights = *(const Vec4*)&vertices[offset + weights_attribute_offset];
copyMemory(mesh.skin[j].indices,
&vertices[offset + bone_indices_attribute_offset],
sizeof(mesh.skin[j].indices));
}
mesh.vertices[j] = *(const Vec3*)&vertices[offset + position_attribute_offset];
mesh.uvs[j] = *(const Vec2*)&vertices[offset + uv_attribute_offset];
float sq_len = mesh.vertices[j].squaredLength();
bounding_radius_squared = Math::maximum(bounding_radius_squared, sq_len > 0 ? sq_len : 0);
min_vertex.x = Math::minimum(min_vertex.x, mesh.vertices[j].x);