本文整理汇总了C++中DataChunk::endChunk方法的典型用法代码示例。如果您正苦于以下问题:C++ DataChunk::endChunk方法的具体用法?C++ DataChunk::endChunk怎么用?C++ DataChunk::endChunk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataChunk
的用法示例。
在下文中一共展示了DataChunk::endChunk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
bool BoneAnimationSet::write(string filename,float fCopress)
{
//filename = m_strName+"1";
Stream *pDataStream;
DataChunk writeChunk;
//最新版本是7,把所有旧的版本转换为版本4
//写 'MVER'
writeChunk.beginChunk('MVER', &pDataStream);
uint ver = 4 ;//在导出插件里面计算aabb
pDataStream->write(&ver,sizeof(ver));
writeChunk.endChunk();
//写 'MANM'
uint32 nAnims = m_vAnimations.size();
//add by yhc 2010.5.10
//修正前一个动作的结束时间和后一个动作的开始时间一样的饿问题
bool bFixWrongTime = false;
if( nAnims > 0)
{
if( nAnims>1 && m_vAnimations[0]->getTimeEnd()==m_vAnimations[1]->getTimeStart() )
bFixWrongTime = true;
writeChunk.beginChunk('MANM', &pDataStream);
pDataStream->write( &nAnims, sizeof(nAnims) );
for( uint i =0; i < nAnims; i++)
{
string animname = m_vAnimations[i]->getName();
uchar animnameLen = animname.size();
pDataStream->write(&animnameLen, sizeof( animnameLen) );
pDataStream->write(animname.c_str(), animnameLen);
uint startTime,endTime;
startTime = m_vAnimations[i]->getTimeStart();
if(bFixWrongTime)
startTime += i*33;
endTime = m_vAnimations[i]->getTimeEnd();
if(bFixWrongTime)
endTime += i*33;
pDataStream->write(&startTime, sizeof(startTime));
pDataStream->write(&endTime, sizeof(endTime));
}
writeChunk.endChunk();
}
//写 'MBON'
uint nBones = m_vBones.size();
if( nBones > 0)
{
writeChunk.beginChunk('MBON', &pDataStream);
pDataStream->write( &nBones, sizeof(nBones) );
for( uint i = 0; i < nBones; i++)
{
int id = m_vBones[i]->objectId;
pDataStream->write( &id, sizeof(id));
string Jointname = m_vBones[i]->name;
uchar JointnameLen = Jointname.size();
pDataStream->write( &JointnameLen, sizeof(JointnameLen) );
pDataStream->write( Jointname.c_str(), JointnameLen);
int parent = m_vBones[i]->parentId;
pDataStream->write( &parent, sizeof(parent) );
Vector3 pivot = m_vBones[i]->pivotPoint;
pDataStream->write( &pivot, sizeof(pivot) );
//写骨骼的初始变换矩阵
pDataStream->write(m_vBones[i]->initTrans.val,sizeof(float)*3);
float _r[4];
_r[0] = m_vBones[i]->initQuat.x;
_r[1] = m_vBones[i]->initQuat.y;
_r[2] = m_vBones[i]->initQuat.z;
_r[3] = m_vBones[i]->initQuat.w;
pDataStream->write(_r, sizeof(float)*4);
pDataStream->write(m_vBones[i]->initScale.val, sizeof(float)*3);
KeyFrames<Vector3> translation;
KeyFrames<Quaternion> rotation;
KeyFrames<Vector3> scale;
//去掉重复和多余的keyframe
CompressPos(m_vBones[i]->translation,translation,fCopress);
uint nKeyFrames = translation.numKeyFrames();
//修正时间
if(bFixWrongTime)
{
int nCurAniIndex=0;
for( uint ii = 0; ii < nKeyFrames; ii++)
{
KeyFrame<Vector3> * kf = translation.getKeyFrame(ii);
if( kf->time>m_vAnimations[nCurAniIndex]->getTimeEnd() )
nCurAniIndex++;
kf->time += nCurAniIndex*33;
}
}
pDataStream->write( &nKeyFrames, sizeof(nKeyFrames) );
for( uint ii = 0; ii < nKeyFrames; ii++)
{
ModelKeyframeTranslation mkft;
mkft.time = translation.getKeyFrame(ii)->time;
mkft.v[0] = translation.getKeyFrame(ii)->v[0];
//.........这里部分代码省略.........