本文整理汇总了C++中ExportContext::IsSkeletal方法的典型用法代码示例。如果您正苦于以下问题:C++ ExportContext::IsSkeletal方法的具体用法?C++ ExportContext::IsSkeletal怎么用?C++ ExportContext::IsSkeletal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportContext
的用法示例。
在下文中一共展示了ExportContext::IsSkeletal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExportMeshLod
static void ExportMeshLod(ExportContext& Context, const CBaseMeshLod& Lod, const CMeshVertex* Verts, FArchive& Ar, FArchive& Ar2)
{
guard(ExportMeshLod);
// Opening brace
Ar.Printf("{\n");
// Asset
Ar.Printf(
" \"asset\" : {\n"
" \"generator\" : \"UE Viewer (umodel) build %s\",\n"
" \"version\" : \"2.0\"\n"
" },\n",
STR(GIT_REVISION));
// Scene
Ar.Printf(
" \"scene\" : 0,\n"
" \"scenes\" : [\n"
" {\n"
" \"nodes\" : [ 0 ]\n"
" }\n"
" ],\n"
);
// Nodes
if (!Context.IsSkeletal())
{
Ar.Printf(
" \"nodes\" : [\n"
" {\n"
" \"name\" : \"%s\",\n"
" \"mesh\" : 0\n"
" }\n"
" ],\n",
Context.MeshName
);
}
else
{
ExportSkinData(Context, static_cast<const CSkelMeshLod&>(Lod), Ar);
}
// Materials
Ar.Printf(" \"materials\" : [\n");
for (int i = 0; i < Lod.Sections.Num(); i++)
{
ExportMaterial(Lod.Sections[i].Material, Ar, i, i == Lod.Sections.Num() - 1);
}
Ar.Printf(" ],\n");
// Meshes
Ar.Printf(
" \"meshes\" : [\n"
" {\n"
" \"primitives\" : [\n"
);
for (int i = 0; i < Lod.Sections.Num(); i++)
{
ExportSection(Context, Lod, Verts, i, Ar);
}
Ar.Printf(
" ],\n"
" \"name\" : \"%s\"\n"
" }\n"
" ],\n",
Context.MeshName
);
// Write animations
if (Context.IsSkeletal() && Context.SkelMesh->Anim)
{
ExportAnimations(Context, Ar);
}
// Write buffers
int bufferLength = 0;
for (int i = 0; i < Context.Data.Num(); i++)
{
bufferLength += Context.Data[i].DataSize;
}
Ar.Printf(
" \"buffers\" : [\n"
" {\n"
" \"uri\" : \"%s.bin\",\n"
" \"byteLength\" : %d\n"
" }\n"
" ],\n",
Context.MeshName, bufferLength
);
// Write bufferViews
Ar.Printf(
" \"bufferViews\" : [\n"
);
int bufferOffset = 0;
for (int i = 0; i < Context.Data.Num(); i++)
{
const BufferData& B = Context.Data[i];
//.........这里部分代码省略.........
示例2: ExportSection
static void ExportSection(ExportContext& Context, const CBaseMeshLod& Lod, const CMeshVertex* Verts, int SectonIndex, FArchive& Ar)
{
guard(ExportSection);
int VertexSize = Context.IsSkeletal() ? sizeof(CSkelMeshVertex) : sizeof(CStaticMeshVertex);
const CMeshSection& S = Lod.Sections[SectonIndex];
bool bLast = (SectonIndex == Lod.Sections.Num()-1);
// Remap section indices to local indices
CIndexBuffer::IndexAccessor_t GetIndex = Lod.Indices.GetAccessor();
TArray<int> indexRemap; // old vertex index -> new vertex index
indexRemap.Init(-1, Lod.NumVerts);
int numLocalVerts = 0;
int numLocalIndices = S.NumFaces * 3;
for (int idx = 0; idx < numLocalIndices; idx++)
{
int vertIndex = GetIndex(S.FirstIndex + idx);
if (indexRemap[vertIndex] == -1)
{
indexRemap[vertIndex] = numLocalVerts++;
}
}
// Prepare buffers
int IndexBufIndex = Context.Data.AddZeroed();
int PositionBufIndex = Context.Data.AddZeroed();
int NormalBufIndex = Context.Data.AddZeroed();
int TangentBufIndex = Context.Data.AddZeroed();
int BonesBufIndex = -1;
int WeightsBufIndex = -1;
if (Context.IsSkeletal())
{
BonesBufIndex = Context.Data.AddZeroed();
WeightsBufIndex = Context.Data.AddZeroed();
}
int UVBufIndex[MAX_MESH_UV_SETS];
for (int i = 0; i < Lod.NumTexCoords; i++)
{
UVBufIndex[i] = Context.Data.AddZeroed();
}
BufferData& IndexBuf = Context.Data[IndexBufIndex];
BufferData& PositionBuf = Context.Data[PositionBufIndex];
BufferData& NormalBuf = Context.Data[NormalBufIndex];
BufferData& TangentBuf = Context.Data[TangentBufIndex];
BufferData* UVBuf[MAX_MESH_UV_SETS];
BufferData* BonesBuf = NULL;
BufferData* WeightsBuf = NULL;
PositionBuf.Setup(numLocalVerts, "VEC3", BufferData::FLOAT, sizeof(CVec3));
NormalBuf.Setup(numLocalVerts, "VEC3", BufferData::FLOAT, sizeof(CVec3));
TangentBuf.Setup(numLocalVerts, "VEC4", BufferData::FLOAT, sizeof(CVec4));
for (int i = 0; i < Lod.NumTexCoords; i++)
{
UVBuf[i] = &Context.Data[UVBufIndex[i]];
UVBuf[i]->Setup(numLocalVerts, "VEC2", BufferData::FLOAT, sizeof(CMeshUVFloat));
}
if (Context.IsSkeletal())
{
BonesBuf = &Context.Data[BonesBufIndex];
WeightsBuf = &Context.Data[WeightsBufIndex];
BonesBuf->Setup(numLocalVerts, "VEC4", BufferData::UNSIGNED_SHORT, sizeof(uint16)*4);
WeightsBuf->Setup(numLocalVerts, "VEC4", BufferData::UNSIGNED_BYTE, sizeof(uint32), /*InNormalized=*/ true);
}
// Prepare and build indices
TArray<int> localIndices;
localIndices.AddUninitialized(numLocalIndices);
int* pIndex = localIndices.GetData();
for (int i = 0; i < numLocalIndices; i++)
{
*pIndex++ = GetIndex(S.FirstIndex + i);
}
if (numLocalVerts <= 65536)
{
IndexBuf.Setup(numLocalIndices, "SCALAR", BufferData::UNSIGNED_SHORT, sizeof(uint16));
for (int idx = 0; idx < numLocalIndices; idx++)
{
IndexBuf.Put<uint16>(indexRemap[localIndices[idx]]);
}
}
else
{
IndexBuf.Setup(numLocalIndices, "SCALAR", BufferData::UNSIGNED_INT, sizeof(uint32));
for (int idx = 0; idx < numLocalIndices; idx++)
{
IndexBuf.Put<uint32>(indexRemap[localIndices[idx]]);
}
}
// Build reverse index map for fast lookup of vertex by its new index.
// It maps new vertex index to old vertex index.
TArray<int> revIndexMap;
revIndexMap.AddUninitialized(numLocalVerts);
for (int i = 0; i < indexRemap.Num(); i++)
//.........这里部分代码省略.........