+++ /dev/null
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-#include <d3d9.h>\r
-#include <d3dx9.h>\r
-#include <vcclr.h>\r
-\r
-#include "../ComObject.h"\r
-#include "../DataStream.h"\r
-#include "../Utilities.h"\r
-#include "../SlimDXException.h"\r
-\r
-#include "Device.h"\r
-#include "Mesh.h"\r
-#include "MeshData.h"\r
-#include "ProgressiveMesh.h"\r
-#include "PatchMesh.h"\r
-#include "MeshContainer.h"\r
-#include "SkinInfo.h"\r
-#include "IAllocateHierarchy.h"\r
-#include "AnimationFrame.h"\r
-\r
-using namespace System;\r
-\r
-namespace SlimDX\r
-{\r
-namespace Direct3D9\r
-{\r
- IAllocateHierarchyShim::IAllocateHierarchyShim( IAllocateHierarchy^ wrappedInterface )\r
- {\r
- m_WrappedInterface = wrappedInterface;\r
- }\r
-\r
- HRESULT IAllocateHierarchyShim::CreateFrame( LPCSTR Name, LPD3DXFRAME *ppNewFrame )\r
- {\r
- Frame^ frame;\r
- *ppNewFrame = NULL;\r
-\r
- try\r
- {\r
- frame = m_WrappedInterface->CreateFrame( gcnew String( Name ) );\r
- }\r
- catch( SlimDXException^ ex)\r
- {\r
- return ex->ResultCode.Code;\r
- }\r
- catch( Exception^ )\r
- {\r
- return E_FAIL;\r
- }\r
-\r
- *ppNewFrame = frame->Pointer;\r
-\r
- return D3D_OK;\r
- }\r
-\r
- HRESULT IAllocateHierarchyShim::CreateMeshContainer( LPCSTR Name, const D3DXMESHDATA *pMeshData,\r
- const D3DXMATERIAL *pMaterials, const D3DXEFFECTINSTANCE *pEffectInstances,\r
- DWORD NumMaterials, const DWORD *pAdjacency, LPD3DXSKININFO pSkinInfo,\r
- LPD3DXMESHCONTAINER *ppNewMeshContainer )\r
- {\r
- MeshContainer^ meshContainer;\r
- *ppNewMeshContainer = NULL;\r
-\r
- MeshData^ meshData;\r
- int count = 0;\r
-\r
- if( pMeshData->Type == D3DXMESHTYPE_MESH )\r
- {\r
- pMeshData->pMesh->AddRef();\r
- meshData = gcnew MeshData( Mesh::FromPointer( pMeshData->pMesh ) );\r
- count = meshData->Mesh->FaceCount;\r
- }\r
- else if( pMeshData->Type == D3DXMESHTYPE_PMESH )\r
- {\r
- pMeshData->pPMesh->AddRef();\r
- meshData = gcnew MeshData( ProgressiveMesh::FromPointer( pMeshData->pPMesh ) );\r
- count = meshData->ProgressiveMesh->FaceCount;\r
- }\r
- else if( pMeshData->Type == D3DXMESHTYPE_PATCHMESH )\r
- {\r
- pMeshData->pPatchMesh->AddRef();\r
- meshData = gcnew MeshData( PatchMesh::FromPointer( pMeshData->pPatchMesh ) );\r
- count = meshData->PatchMesh->PatchCount;\r
- }\r
-\r
- count *= 3;\r
-\r
- array<ExtendedMaterial>^ materials = gcnew array<ExtendedMaterial>( NumMaterials );\r
- array<EffectInstance>^ effects = gcnew array<EffectInstance>( NumMaterials );\r
- array<int>^ adjacency = gcnew array<int>( count );\r
-\r
- for( unsigned int i = 0; i < NumMaterials; i++ )\r
- {\r
- materials[i] = ExtendedMaterial::FromUnmanaged( pMaterials[i] );\r
- effects[i] = EffectInstance::FromUnmanaged( pEffectInstances[i] );\r
- }\r
-\r
- for( int i = 0; i < count; i++ )\r
- adjacency[i] = pAdjacency[i];\r
-\r
- SkinInfo^ skinInfo = nullptr;\r
- if( pSkinInfo != NULL )\r
- {\r
- pSkinInfo->AddRef();\r
- skinInfo = SkinInfo::FromPointer( pSkinInfo );\r
- }\r
-\r
- try\r
- {\r
- meshContainer = m_WrappedInterface->CreateMeshContainer( gcnew String( Name ), meshData, materials, \r
- effects, adjacency, skinInfo );\r
- }\r
- catch( SlimDXException^ ex)\r
- {\r
- return ex->ResultCode.Code;\r
- }\r
- catch( Exception^ )\r
- {\r
- return E_FAIL;\r
- }\r
-\r
- *ppNewMeshContainer = meshContainer->Pointer; \r
-\r
- return D3D_OK;\r
- }\r
-\r
- HRESULT IAllocateHierarchyShim::DestroyFrame( LPD3DXFRAME pFrameToFree )\r
- {\r
- try\r
- {\r
- m_WrappedInterface->DestroyFrame( static_cast<FrameShim*>( pFrameToFree )->GetFrame() );\r
- }\r
- catch( SlimDXException^ ex)\r
- {\r
- return ex->ResultCode.Code;\r
- }\r
- catch( Exception^ )\r
- {\r
- return E_FAIL;\r
- }\r
-\r
- return D3D_OK;\r
- }\r
-\r
- HRESULT IAllocateHierarchyShim::DestroyMeshContainer( LPD3DXMESHCONTAINER pMeshContainerToFree )\r
- {\r
- try\r
- { \r
- m_WrappedInterface->DestroyMeshContainer( static_cast<MeshContainerShim*>( pMeshContainerToFree )->GetMeshContainer() );\r
- }\r
- catch( SlimDXException^ ex)\r
- {\r
- return ex->ResultCode.Code;\r
- }\r
- catch( Exception^ )\r
- {\r
- return E_FAIL;\r
- }\r
-\r
- return D3D_OK;\r
- }\r
-}\r
-}\r