本文整理汇总了C++中LPDIRECTXFILEDATA类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTXFILEDATA类的具体用法?C++ LPDIRECTXFILEDATA怎么用?C++ LPDIRECTXFILEDATA使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTXFILEDATA类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DFile::CreateFromResource( LPDIRECT3DDEVICE9 pd3dDevice, TCHAR* strResource, TCHAR* strType )
{
LPDIRECTXFILE pDXFile = NULL;
LPDIRECTXFILEENUMOBJECT pEnumObj = NULL;
LPDIRECTXFILEDATA pFileData = NULL;
HRESULT hr;
// Create a x file object
if( FAILED( hr = DirectXFileCreate( &pDXFile ) ) )
return E_FAIL;
// Register templates for d3drm and patch extensions.
if( FAILED( hr = pDXFile->RegisterTemplates( (void*)D3DRM_XTEMPLATES,
D3DRM_XTEMPLATE_BYTES ) ) )
{
pDXFile->Release();
return E_FAIL;
}
CHAR strTypeAnsi[MAX_PATH];
DXUtil_ConvertGenericStringToAnsiCb( strTypeAnsi, strType, sizeof(strTypeAnsi) );
DXFILELOADRESOURCE dxlr;
dxlr.hModule = NULL;
dxlr.lpName = strResource;
dxlr.lpType = (TCHAR*) strTypeAnsi;
// Create enum object
hr = pDXFile->CreateEnumObject( (void*)&dxlr, DXFILELOAD_FROMRESOURCE,
&pEnumObj );
if( FAILED(hr) )
{
pDXFile->Release();
return hr;
}
// Enumerate top level objects (which are always frames)
while( SUCCEEDED( pEnumObj->GetNextDataObject( &pFileData ) ) )
{
hr = LoadFrame( pd3dDevice, pFileData, this );
pFileData->Release();
if( FAILED(hr) )
{
pEnumObj->Release();
pDXFile->Release();
return E_FAIL;
}
}
SAFE_RELEASE( pFileData );
SAFE_RELEASE( pEnumObj );
SAFE_RELEASE( pDXFile );
return S_OK;
}
示例2: if
HRESULT CXFrameNode::MergeFromXData(char* Filename, CXModel* Model, LPDIRECTXFILEDATA XObj)
{
HRESULT res = S_OK;
// get the type of the object
const GUID* ObjectType;
res = XObj->GetType(&ObjectType);
if(FAILED(res))
{
Game->LOG(res, "Error getting object type");
return res;
}
// load animation set
else if(*ObjectType == TID_D3DRMAnimationSet )
{
return Model->LoadAnimationSet(Filename, XObj);
}
// load a single animation (shouldn't happen here)
else if(*ObjectType == TID_D3DRMAnimation)
{
return Model->LoadAnimation(Filename, XObj);
}
// scan child frames
else if(*ObjectType == TID_D3DRMFrame)
{
// Enumerate child objects.
// Child object can be data, data reference or binary.
// Use QueryInterface() to find what objecttype of object a child is.
LPDIRECTXFILEDATA XChildData;
LPDIRECTXFILEOBJECT XChildObj;
res = E_FAIL;
while(SUCCEEDED(XObj->GetNextObject(&XChildObj)))
{
// Query the child for it's FileData
res = XChildObj->QueryInterface(IID_IDirectXFileData, (void**)&XChildData);
if(SUCCEEDED(res))
{
// load the child's object
res = MergeFromXData(Filename, Model, XChildData);
RELEASE(XChildData);
}
RELEASE(XChildObj);
}
return res;
}
return S_OK; // unknown type, ignore
}
示例3:
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DFile::LoadMesh( LPDIRECT3DDEVICE8 pd3dDevice,
LPDIRECTXFILEDATA pFileData,
CD3DFrame* pParentFrame )
{
// Currently only allowing one mesh per frame
if( pParentFrame->m_pMesh )
return E_FAIL;
// Get the mesh name
CHAR strAnsiName[512] = {0};
TCHAR strName[MAX_PATH];
DWORD dwNameLength;
pFileData->GetName( NULL, &dwNameLength );
if( dwNameLength > 0 )
pFileData->GetName( strAnsiName, &dwNameLength );
DXUtil_ConvertAnsiStringToGeneric( strName, strAnsiName );
// Create the mesh
pParentFrame->m_pMesh = new CD3DMesh( strName );
pParentFrame->m_pMesh->Create( pd3dDevice, pFileData );
return S_OK;
}
示例4: LoadMesh
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DFile::LoadFrame( LPDIRECT3DDEVICE9 pd3dDevice,
LPDIRECTXFILEDATA pFileData,
CD3DFrame* pParentFrame )
{
LPDIRECTXFILEDATA pChildData = NULL;
LPDIRECTXFILEOBJECT pChildObj = NULL;
const GUID* pGUID;
DWORD cbSize;
CD3DFrame* pCurrentFrame;
HRESULT hr;
// Get the type of the object
if( FAILED( hr = pFileData->GetType( &pGUID ) ) )
return hr;
if( *pGUID == TID_D3DRMMesh )
{
hr = LoadMesh( pd3dDevice, pFileData, pParentFrame );
if( FAILED(hr) )
return hr;
}
if( *pGUID == TID_D3DRMFrameTransformMatrix )
{
D3DXMATRIX* pmatMatrix;
hr = pFileData->GetData( NULL, &cbSize, (void**)&pmatMatrix );
if( FAILED(hr) )
return hr;
// Update the parent's matrix with the new one
pParentFrame->SetMatrix( pmatMatrix );
}
if( *pGUID == TID_D3DRMFrame )
{
// Get the frame name
CHAR strAnsiName[512] = "";
TCHAR strName[512];
DWORD dwNameLength = 512;
if( FAILED( hr = pFileData->GetName( strAnsiName, &dwNameLength ) ) )
return hr;
DXUtil_ConvertAnsiStringToGenericCb( strName, strAnsiName, sizeof(strName) );
// Create the frame
pCurrentFrame = new CD3DFrame( strName );
if( pCurrentFrame == NULL )
return E_OUTOFMEMORY;
pCurrentFrame->m_pNext = pParentFrame->m_pChild;
pParentFrame->m_pChild = pCurrentFrame;
// Enumerate child objects
while( SUCCEEDED( pFileData->GetNextObject( &pChildObj ) ) )
{
// Query the child for its FileData
hr = pChildObj->QueryInterface( IID_IDirectXFileData,
(void**)&pChildData );
if( SUCCEEDED(hr) )
{
hr = LoadFrame( pd3dDevice, pChildData, pCurrentFrame );
pChildData->Release();
}
pChildObj->Release();
if( FAILED(hr) )
return hr;
}
}
return S_OK;
}
示例5: CXMesh
HRESULT CXFrameNode::LoadFromXData(char* Filename, CXModel* Model, LPDIRECTXFILEDATA XObj)
{
Game->MiniUpdate();
HRESULT res = S_OK;
// {9E415A43-7BA6-4a73-8743-B73D47E88476}
GUID DXFILEOBJ_AnimTicksPerSecond = { 0x9e415a43, 0x7ba6, 0x4a73, { 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76 } };
// get the type of the object
GUID ObjectType;
res = XObj->GetType(&ObjectType);
if(FAILED(res))
{
Game->LOG(res, "Error getting object type");
return res;
}
// load a child mesh
if(ObjectType == TID_D3DRMMesh)
{
CXMesh* Mesh = new CXMesh(Game);
res = Mesh->LoadFromXData(Filename, XObj);
if(SUCCEEDED(res))
{
m_Meshes.Add(Mesh);
return S_OK;
}
else
{
SAFE_DELETE(Mesh);
return res;
}
}
// load the transformation matrix
else if(ObjectType == TID_D3DRMFrameTransformMatrix)
{
D3DXMATRIX* mat;
SIZE_T Size;
res = XObj->Lock(&Size, (LPCVOID*)&mat);
if(FAILED(res))
{
Game->LOG(res, "Error loading transformation matrix");
return res;
}
else
{
m_TransformationMatrix = *mat;
m_OriginalMatrix = *mat;
XObj->Unlock();
return S_OK;
}
}
// load animation set
else if(ObjectType == TID_D3DRMAnimationSet )
{
return Model->LoadAnimationSet(Filename, XObj);
}
// load a single animation (shouldn't happen here)
else if(ObjectType == TID_D3DRMAnimation)
{
return Model->LoadAnimation(Filename, XObj);
}
// create a new child frame
else if(ObjectType == TID_D3DRMFrame)
{
CXFrameNode* ChildFrame = new CXFrameNode(Game);
// get the name of the child frame
res = CXModel::LoadName(ChildFrame, XObj);
if(FAILED(res))
{
Game->LOG(res, "Error loading frame name");
SAFE_DELETE(ChildFrame);
return res;
}
// Enumerate child objects.
// Child object can be data, data reference or binary.
// Use QueryInterface() to find what objecttype of object a child is.
res = E_FAIL;
SIZE_T NumChildren;
XObj->GetChildren(&NumChildren);
for(SIZE_T i=0; i<NumChildren; i++)
{
LPDIRECTXFILEDATA XChildData;
res = XObj->GetChild(i, &XChildData);
if(SUCCEEDED(res))
{
res = ChildFrame->LoadFromXData(Filename, Model, XChildData);
RELEASE(XChildData);
}
}
//.........这里部分代码省略.........