本文整理汇总了C++中CArray::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::Resize方法的具体用法?C++ CArray::Resize怎么用?C++ CArray::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::Resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: oFileEntry
CGMeshMD5::CModel * CGmResMan::NewModelMD5( const char *pcFileNameMesh, const CArray<CStr> &roArrFileNameAnim, bool bTexSmooth )
{
CGMeshMD5::CModel *poModel = 0;
CStr oFileEntry( pcFileNameMesh );
for( unsigned int i=0; i<roArrFileNameAnim.GetSize(); ++i )
{
oFileEntry += "&";
oFileEntry += roArrFileNameAnim[i];
}
poModel = (CGMeshMD5::CModel *)FindFileEntry( oFileEntry.GetData() );
if( !poModel )
{
poModel = new CGMeshMD5::CModel;
//if( !MakeModelMD5_( poModel, pcFileNameMesh, roArrFileNameAnim, bTexSmooth ) )
//{
// ERR( "ModelMD5 %s.\n", pcFileNameMesh );
// DELETE_INSTANCE( poModel );
// return 0;
//}
{
if( !poModel->InitModel( DATA_DIR + /*"model/" +*/ pcFileNameMesh ) )
{
ERR( "ModelMD5 %s.\n", pcFileNameMesh );
DELETE_INSTANCE( poModel );
return 0;
}
CArray<CGTex2 *> oArrTex;
const unsigned int uiMeshCount = poModel->GetMeshCount();
oArrTex.Resize( uiMeshCount );
oArrTex.Fill( 0 );
unsigned int i = uiMeshCount;
while( i )
{
--i;
const char *pcMaterialName = poModel->GetMaterialName( i );
if( pcMaterialName )
{
oArrTex[i] = NewTexture( pcMaterialName, bTexSmooth, false );
}
}
const unsigned int uiAnimCount = roArrFileNameAnim.GetSize();
for( unsigned int uiAnim=0; uiAnim<uiAnimCount; ++uiAnim )
{
LOG( "Loading %s.\n", roArrFileNameAnim[uiAnim].GetData() );
if( poModel->InsertNewAnim( DATA_DIR + /*"model/" +*/ roArrFileNameAnim[uiAnim] ) )
{
for( unsigned int i=0; i<uiMeshCount; ++i )
{
if( oArrTex.GetSize() >= i && oArrTex[i] )
{
poModel->SetTex( i, uiAnim, oArrTex[i] );
}
}
}
}
poModel->SetAnim( poModel->GetAnimCount() - 1 );
}
m_oArrModelMD5.Append( poModel );
NewFileEntry( oFileEntry.GetData(), poModel );
}
else
{
LOG( "ModelMD5 skipped: %s.\n", pcFileNameMesh );
}
//else
//{
// // copy with shared data
// poModel = new CGMeshMD5::CModel( *poModel );
//
// m_oArrModelMD5.Append( poModel );
// LOG( "ModelMD5 copied: %s.\n", pcFileNameMesh );
//}
return poModel;
}
示例2: if
bool CGmObjAnim3::ReadXML( TiXmlNode* poParent, unsigned int uiCounter )
{
if( !poParent )
return false;
static char acTxt_[256];
if( uiCounter == 0 )
{
}
switch ( poParent->Type() )
{
case TiXmlNode::DOCUMENT:
LOG( "XML: Document" );
break;
case TiXmlNode::ELEMENT:
{
const char *pcName = poParent->Value();
//LOG( "name: %s\n", pcName );
if( !strcmp( pcName, "animation" ) )
{
LOG( "animation:\n" );
TiXmlElement * poElement = poParent->ToElement();
if( poElement )
{
int iIdx;
CStr oMeshFileName;
CArray<CStr> oArrAnimFileName;
TiXmlAttribute* poAttrib = poElement->FirstAttribute();
while( poAttrib )
{
const char *pcName = poAttrib->Name();
if( !strcmp( pcName, "mesh" ) )
{
STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
oMeshFileName = acTxt_;
}
else if( SSCANF( pcName, "anim_%d", &iIdx ) == 1 )
{
LOG( "%s: %d\n", poAttrib->Name(), iIdx );
STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
if( iIdx >= int( oArrAnimFileName.GetSize() ) )
oArrAnimFileName.Resize( iIdx + 1 );
oArrAnimFileName[iIdx] = acTxt_;
}
poAttrib = poAttrib->Next();
}
if( oMeshFileName.GetSize() )
{
// Model.
m_poModel = m_poResMan_->NewModelMD5( oMeshFileName, oArrAnimFileName, false );
const unsigned int uiFrameCountTotal = m_poModel->GetFrameCountTotal();
const unsigned int uiMeshCount = m_poModel->GetMeshCount();
const unsigned int uiAnimCount = m_poModel->GetAnimCount();
m_oArrAnim.Resize( uiAnimCount );
m_oArrAnim.Fill( 0 );
m_poData->SetFrameCount( uiFrameCountTotal );
unsigned int uiFrameIdx = 0;
for( unsigned int uiAnim=0; uiAnim<uiAnimCount; ++uiAnim )
{
//m_poModel->SetAnim( uiAnim );
const unsigned int uiFrameCount = m_poModel->GetFrameCount( uiAnim );
CAnim * poAnim = new CAnim;
m_oArrAnim[uiAnim] = poAnim;
poAnim->SetFrameRate( m_poModel->GetFrameRate( uiAnim ) );
poAnim->SetFrameCount( uiFrameCount );
for( unsigned int uiFrame=0; uiFrame<uiFrameCount; ++uiFrame )
{
CFrame * poFrame = new CFrame;
m_poData->SetFrame( uiFrameIdx, poFrame );
poAnim->SetFrameIndex( uiFrame, uiFrameIdx );
++uiFrameIdx;
poFrame->SetMeshCount( uiMeshCount );
for( unsigned int uiMesh=0; uiMesh<uiMeshCount; ++uiMesh )
{
CGMeshMD5 * poMesh = m_poModel->GetPrecalcMesh( uiMesh, uiFrame, uiAnim );
ASSERT( poMesh );
poFrame->SetMesh( uiMesh, poMesh );
}
}
poAnim->Init();
}
ASSERT( uiFrameIdx == uiFrameCountTotal );
}
//.........这里部分代码省略.........