本文整理汇总了C++中ExportContext::GetFinalIndexForLastBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ ExportContext::GetFinalIndexForLastBlock方法的具体用法?C++ ExportContext::GetFinalIndexForLastBlock怎么用?C++ ExportContext::GetFinalIndexForLastBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportContext
的用法示例。
在下文中一共展示了ExportContext::GetFinalIndexForLastBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExportAnimations
//.........这里部分代码省略.........
RotationSamplerIndex, MeshBoneIndex + FIRST_BONE_NODE, "rotation", BoneIndex == AnimBones.Num()-1 ? "" : ","
);
}
Ar.Printf(" ],\n");
// Prepare samplers
Ar.Printf(" \"samplers\" : [\n");
for (int SamplerIndex = 0; SamplerIndex < Samplers.Num(); SamplerIndex++)
{
const AnimSampler& Sampler = Samplers[SamplerIndex];
// Prepare time array
const TArray<float>* TimeArray = (Sampler.Type == AnimSampler::TRANSLATION) ? &Sampler.Track->KeyPosTime : &Sampler.Track->KeyQuatTime;
if (TimeArray->Num() == 0)
{
// For this situation, use track's time array
TimeArray = &Sampler.Track->KeyTime;
}
int NumKeys = Sampler.Type == (AnimSampler::TRANSLATION) ? Sampler.Track->KeyPos.Num() : Sampler.Track->KeyQuat.Num();
int TimeBufIndex = Context.Data.AddZeroed();
BufferData& TimeBuf = Context.Data[TimeBufIndex];
TimeBuf.Setup(NumKeys, "SCALAR", BufferData::FLOAT, sizeof(float));
float RateScale = 1.0f / Seq.Rate;
float LastFrameTime = 0;
if (TimeArray->Num() == 0 || NumKeys == 1)
{
// Fill with equally spaced values
for (int i = 0; i < NumKeys; i++)
{
TimeBuf.Put(i * RateScale);
}
LastFrameTime = NumKeys-1;
}
else
{
for (int i = 0; i < TimeArray->Num(); i++)
{
TimeBuf.Put((*TimeArray)[i] * RateScale);
}
LastFrameTime = (*TimeArray)[TimeArray->Num()-1];
}
// Prepare min/max values for time track, it's required by glTF standard
TimeBuf.BoundsMin = "[ 0 ]";
char buf[64];
appSprintf(ARRAY_ARG(buf), "[ %g ]", LastFrameTime * RateScale);
TimeBuf.BoundsMax = buf;
// Try to reuse TimeBuf from previous tracks
TimeBufIndex = Context.GetFinalIndexForLastBlock(FirstDataIndex);
// Prepare data
int DataBufIndex = Context.Data.AddZeroed();
BufferData& DataBuf = Context.Data[DataBufIndex];
if (Sampler.Type == AnimSampler::TRANSLATION)
{
// Translation track
DataBuf.Setup(NumKeys, "VEC3", BufferData::FLOAT, sizeof(CVec3));
for (int i = 0; i < NumKeys; i++)
{
CVec3 Pos = Sampler.Track->KeyPos[i];
TransformPosition(Pos);
DataBuf.Put(Pos);
}
}
else
{
// Rotation track
DataBuf.Setup(NumKeys, "VEC4", BufferData::FLOAT, sizeof(CQuat));
for (int i = 0; i < NumKeys; i++)
{
CQuat Rot = Sampler.Track->KeyQuat[i];
TransformRotation(Rot);
if (Sampler.BoneNodeIndex - FIRST_BONE_NODE == 0)
{
Rot.Conjugate();
}
DataBuf.Put(Rot);
}
}
// Try to reuse data block as well
DataBufIndex = Context.GetFinalIndexForLastBlock(FirstDataIndex);
// Write glTF info
Ar.Printf(
" { \"input\" : %d, \"output\" : %d }%s\n",
TimeBufIndex, DataBufIndex, SamplerIndex == Samplers.Num()-1 ? "" : ","
);
}
Ar.Printf(" ]\n");
Ar.Printf(" }%s\n", SeqIndex == Anim->Sequences.Num()-1 ? "" : ",");
}
Ar.Printf(" ],\n");
unguard;
}