本文整理汇总了C++中CPUTAssetLibraryDX11::GetModelDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ CPUTAssetLibraryDX11::GetModelDirectory方法的具体用法?C++ CPUTAssetLibraryDX11::GetModelDirectory怎么用?C++ CPUTAssetLibraryDX11::GetModelDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPUTAssetLibraryDX11
的用法示例。
在下文中一共展示了CPUTAssetLibraryDX11::GetModelDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: center
//-----------------------------------------------------------------------------
CPUTResult CPUTModelDX11::LoadModel(CPUTConfigBlock *pBlock, int *pParentID, CPUTModel *pMasterModel)
{
CPUTResult result = CPUT_SUCCESS;
CPUTAssetLibraryDX11 *pAssetLibrary = (CPUTAssetLibraryDX11*)CPUTAssetLibrary::GetAssetLibrary();
cString modelSuffix = ptoc(this);
// set the model's name
mName = pBlock->GetValueByName(_L("name"))->ValueAsString();
mName = mName + _L(".mdl");
// resolve the full path name
cString modelLocation;
cString resolvedPathAndFile;
modelLocation = ((CPUTAssetLibraryDX11*)CPUTAssetLibrary::GetAssetLibrary())->GetModelDirectory();
modelLocation = modelLocation+mName;
CPUTOSServices::GetOSServices()->ResolveAbsolutePathAndFilename(modelLocation, &resolvedPathAndFile);
// Get the parent ID. Note: the caller will use this to set the parent.
*pParentID = pBlock->GetValueByName(_L("parent"))->ValueAsInt();
LoadParentMatrixFromParameterBlock( pBlock );
// Get the bounding box information
float3 center(0.0f), half(0.0f);
pBlock->GetValueByName(_L("BoundingBoxCenter"))->ValueAsFloatArray(center.f, 3);
pBlock->GetValueByName(_L("BoundingBoxHalf"))->ValueAsFloatArray(half.f, 3);
mBoundingBoxCenterObjectSpace = center;
mBoundingBoxHalfObjectSpace = half;
mMeshCount = pBlock->GetValueByName(_L("meshcount"))->ValueAsInt();
mpMesh = new CPUTMesh*[mMeshCount];
mpMaterial = new CPUTMaterial*[mMeshCount];
memset( mpMaterial, 0, mMeshCount * sizeof(CPUTMaterial*) );
cString materialName;
char pNumber[4];
cString materialValueName;
CPUTModelDX11 *pMasterModelDX = (CPUTModelDX11*)pMasterModel;
for(UINT ii=0; ii<mMeshCount; ii++)
{
if(pMasterModelDX)
{
// Reference the master model's mesh. Don't create a new one.
mpMesh[ii] = pMasterModelDX->mpMesh[ii];
mpMesh[ii]->AddRef();
}
else
{
mpMesh[ii] = new CPUTMeshDX11();
}
}
if( !pMasterModelDX )
{
// Not a clone/instance. So, load the model's binary payload (i.e., vertex and index buffers)
// TODO: Change to use GetModel()
result = LoadModelPayload(resolvedPathAndFile);
ASSERT( CPUTSUCCESS(result), _L("Failed loading model") );
}
#if 0
cString assetSetDirectoryName = pAssetLibrary->GetAssetSetDirectoryName();
cString modelDirectory = pAssetLibrary->GetModelDirectory();
cString materialDirectory = pAssetLibrary->GetMaterialDirectory();
cString textureDirectory = pAssetLibrary->GetTextureDirectory();
cString shaderDirectory = pAssetLibrary->GetShaderDirectory();
cString fontDirectory = pAssetLibrary->GetFontDirectory();
cString up2MediaDirName = assetSetDirectoryName + _L("..\\..\\");
pAssetLibrary->SetMediaDirectoryName( up2MediaDirName );
mpShadowCastMaterial = pAssetLibrary->GetMaterial( _L("shadowCast"), false, this, -2 ); // -2 signifies shadow material. TODO: find a clearer way (e.g., enum?)
pAssetLibrary->SetAssetSetDirectoryName( assetSetDirectoryName );
pAssetLibrary->SetModelDirectoryName( modelDirectory );
pAssetLibrary->SetMaterialDirectoryName( materialDirectory );
pAssetLibrary->SetTextureDirectoryName( textureDirectory );
pAssetLibrary->SetShaderDirectoryName( shaderDirectory );
pAssetLibrary->SetFontDirectoryName( fontDirectory );
#endif
for(UINT ii=0; ii<mMeshCount; ii++)
{
// get the right material number ('material0', 'material1', 'material2', etc)
materialValueName = _L("material");
_itoa_s(ii, pNumber, 4, 10);
materialValueName.append(s2ws(pNumber));
materialName = pBlock->GetValueByName(materialValueName)->ValueAsString();
// Get/load material for this mesh
CPUTMaterialDX11 *pMaterial = (CPUTMaterialDX11*)pAssetLibrary->GetMaterial(materialName, false, this, ii);
ASSERT( pMaterial, _L("Couldn't find material.") );
// set the material on this mesh
// TODO: Model owns the materials. That allows different models to share meshes (aka instancing) that have different materials
SetMaterial(ii, pMaterial);
// Release the extra refcount we're holding from the GetMaterial operation earlier
// now the asset library, and this model have the only refcounts on that material
pMaterial->Release();
//.........这里部分代码省略.........