当前位置: 首页>>代码示例>>C++>>正文


C++ DataChunk::save方法代码示例

本文整理汇总了C++中DataChunk::save方法的典型用法代码示例。如果您正苦于以下问题:C++ DataChunk::save方法的具体用法?C++ DataChunk::save怎么用?C++ DataChunk::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataChunk的用法示例。


在下文中一共展示了DataChunk::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write


//.........这里部分代码省略.........
				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];
					mkft.v[1] = translation.getKeyFrame(ii)->v[1];
					mkft.v[2] = translation.getKeyFrame(ii)->v[2];
					pDataStream->write( &mkft, sizeof(mkft) );
				} 
				
				CompressQua(m_vBones[i]->rotation,rotation,fCopress);
				nKeyFrames = rotation.numKeyFrames();
				//修正时间
				if(bFixWrongTime)
				{
					int nCurAniIndex=0;
					for( uint ii = 0; ii < nKeyFrames; ii++)
					{
						KeyFrame<Quaternion> * kf =  rotation.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++)
				{
					ModelKeyframeRotation mkfr;
					mkfr.time = rotation.getKeyFrame(ii)->time;
					mkfr.q[0] = rotation.getKeyFrame(ii)->v.x;
					mkfr.q[1] = rotation.getKeyFrame(ii)->v.y;
					mkfr.q[2] = rotation.getKeyFrame(ii)->v.z;
					mkfr.q[3] = rotation.getKeyFrame(ii)->v.w;
					pDataStream->write( &mkfr, sizeof(mkfr) );
				} 
				
				CompressPos(m_vBones[i]->scale,scale,fCopress);
				nKeyFrames = scale.numKeyFrames();
				//修正时间
				if(bFixWrongTime)
				{
					int nCurAniIndex=0;
					for( uint ii = 0; ii < nKeyFrames; ii++)
					{
						KeyFrame<Vector3> * kf =  scale.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 ++)
				{
					ModelKeyframeScale mkfs;
					mkfs.time = scale.getKeyFrame(ii)->time;
					mkfs.v[0] = scale.getKeyFrame(ii)->v[0];
					mkfs.v[1] = scale.getKeyFrame(ii)->v[1];
					mkfs.v[2] = scale.getKeyFrame(ii)->v[2];
					pDataStream->write( &mkfs, sizeof(mkfs) );
				}
			
			}
			writeChunk.endChunk();		
		}

		writeChunk.save(filename.c_str());
		return true;
	}
开发者ID:lorichen,项目名称:xgame,代码行数:101,代码来源:BoneAnimationSet.cpp


注:本文中的DataChunk::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。