本文整理汇总了C++中MeshData::GetRawIndexData方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshData::GetRawIndexData方法的具体用法?C++ MeshData::GetRawIndexData怎么用?C++ MeshData::GetRawIndexData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshData
的用法示例。
在下文中一共展示了MeshData::GetRawIndexData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteOBJ
void WriteOBJ(MeshData const& meshData, std::ostream* stream, IImportExportCallbacks* callbacks)
{
auto posStream = meshData.GetVertexStream(ElementType::Position);
auto uvStream = meshData.GetVertexStream(ElementType::TextureUV);
auto normalStream = meshData.GetVertexStream(ElementType::Normal);
auto indexData = meshData.GetRawIndexData();
size_t indexCount = meshData.GetIndexCount();
// streams must all have same size
DebugAssert(posStream);
DebugAssert(uvStream==nullptr || uvStream->Count == posStream->Count);
DebugAssert(normalStream==nullptr || normalStream->Count == posStream->Count);
// index buffer assumed to be triangles
DebugAssert(indexCount % 3 == 0);
struct Vec3
{
float x,y,z;
};
struct Vec2
{
float x,y;
};
size_t totalLines =
posStream->Count +
(uvStream ? uvStream->Count : 0) +
(normalStream ? normalStream->Count : 0) +
indexCount / 3;
size_t numLines = 0;
for (size_t i = 0; i < posStream->Count; i++)
{
HANDLE_PROGRESS;
Vec3 v = posStream->GetElement<Vec3>(i);
(*stream) << "v " << v.x << " " << v.y << " " << v.z << std::endl;
}
if( uvStream )
{
for (size_t i = 0; i < uvStream->Count; i++)
{
HANDLE_PROGRESS;
Vec2 v = uvStream->GetElement<Vec2>(i);
(*stream) << "vt " << v.x << " " << v.y << std::endl;
}
}
if( normalStream )
{
for (size_t i = 0; i < normalStream->Count; i++)
{
HANDLE_PROGRESS;
Vec3 v = normalStream->GetElement<Vec3>(i);
(*stream) << "vn " << v.x << " " << v.y << " " << v.z << std::endl;
}
}
for (size_t i = 0; i < indexCount; i += 3)
{
HANDLE_PROGRESS;
(*stream) << "f ";
WriteSlashedIndex(stream, indexData[i], uvStream != nullptr, normalStream != nullptr, false );
WriteSlashedIndex(stream, indexData[i+1], uvStream != nullptr, normalStream != nullptr, false );
WriteSlashedIndex(stream, indexData[i+2], uvStream != nullptr, normalStream != nullptr, true );
}
}