// -------------------------------------------------------------------------- // ========================================================================== // File: TDx9_3DXPMesh.CPP // Authors: BCB_Code_Generator v2.00, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons) // Description: This file contains the code for the TDx9_3DXPMesh Component // // "TDx9_3DX_Library v1.00" // (c) 2005 BCB-Tools.com Pty. Ltd., Sydney, Australia. // All Rights Reserved. // // Refer to the 'Licence.Txt' file for licencing & copyright information. // ========================================================================== // -------------------------------------------------------------------------- // #includes ... // -------------------------------------------------------------------------- #include #pragma hdrstop // -------------------------------------------------------------------------- #include "TDx9_3DXPMesh.H" // -------------------------------------------------------------------------- // external classes used by TDx9_3DXPMesh methods. #include "TDx9_3DDevice.H" #include "TDx9_3DXPMesh.H" #include "TDx9_3DIndexBuffer.H" #include "TDx9_3DVertexBuffer.H" // -------------------------------------------------------------------------- #pragma link "TDx_Library_Defns" #pragma link "TDx_Library_Functions" #pragma link "TDx9_3DX_Library_Defns" #pragma link "TDx9_3DX_Library_Functions" // -------------------------------------------------------------------------- // Object Registration... // -------------------------------------------------------------------------- #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ #pragma package(smart_init) #endif // -------------------------------------------------------------------------- static inline void ValidCtrCheck(TDx9_3DXPMesh*) { new TDx9_3DXPMesh(NULL); } // -------------------------------------------------------------------------- namespace Tdx9_3dxpmesh { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDx9_3DXPMesh)}; RegisterComponents("", classes, 0); } } // -------------------------------------------------------------------------- // Constructor: TDx9_3DXPMesh::TDx9_3DXPMesh() // Description: The default constructor for the TDx9_3DXPMesh object. // -------------------------------------------------------------------------- __fastcall TDx9_3DXPMesh::TDx9_3DXPMesh(TComponent* Owner) : TDx9_3DXBaseMesh(Owner) { fErrorValue = D3D_OK ; fCreated = false; } // -------------------------------------------------------------------------- // Destructor: TDx9_3DXPMesh::~TDx9_3DXPMesh() // Description: The destructor for the TDx9_3DXPMesh object. // -------------------------------------------------------------------------- __fastcall TDx9_3DXPMesh::~TDx9_3DXPMesh() { // destroy internals if (Created) Destroy(); } // -------------------------------------------------------------------------- // Property: Created // Description: The Created property is true if the internal LPD3DXPMESH used // in this component has been successfully created, otherwise // Created is false. // // To create the internal LPD3DXPMESH, call the // TDx9_3DXPMesh::Create() method. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::FGetCreated() { return fCreated; } // -------------------------------------------------------------------------- void __fastcall TDx9_3DXPMesh::FSetCreated( bool pCreated ) { fCreated = (pCreated && (fLPD3DXPMESH==NULL)); } // -------------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDx9_3DXPMesh method or fget/fset. // eg. D3D_OK // or DDERR_SURFACELOST or TDX_ERROR // -------------------------------------------------------------------------- HRESULT __fastcall TDx9_3DXPMesh::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDx9_3DXPMesh::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // Method: CloneMesh() // Description: The CloneMesh method is used to ... // Params: pOptions - // The Options parameter ... // pLPD3DVERTEXELEMENT9 - // The LPD3DVERTEXELEMENT9 parameter ... // pDeclaration - // The Declaration parameter ... // pDevice - // The Device parameter ... // pCloneMesh - // The CloneMesh parameter ... // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Method: CloneMeshFVF() // Description: The CloneMeshFVF method is used to ... // Params: pOptions - // The Options parameter ... // pFVF - // The FVF parameter ... // pDevice - // The Device parameter ... // pCloneMesh - // The CloneMesh parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::CloneMeshFVF( dword pOptions, dword pFVF, TDx9_3DDevice* pDevice, LPD3DXMESH* pCloneMesh ) { // Original Function Definition // HRESULT CloneMeshFVF( // DWORD Options, // DWORD FVF, // LPDIRECT3DDEVICE9 pDevice, // LPD3DXMESH *ppCloneMesh // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CloneMeshFVF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->CloneMeshFVF( (DWORD) pOptions, (DWORD) pFVF, (pDevice==NULL) ? NULL : pDevice->Internal_LPDIRECT3DDEVICE9, pCloneMesh ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CloneMeshFVF()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: ClonePMesh() // Description: The ClonePMesh method is used to ... // Params: pOptions - // The Options parameter ... // pLPD3DVERTEXELEMENT9 - // The LPD3DVERTEXELEMENT9 parameter ... // pDeclaration - // The Declaration parameter ... // pDevice - // The Device parameter ... // pCloneMesh - // The CloneMesh parameter ... // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Method: ClonePMeshFVF() // Description: The ClonePMeshFVF method is used to ... // Params: pOptions - // The Options parameter ... // pFVF - // The FVF parameter ... // pDevice - // The Device parameter ... // pCloneMesh - // The CloneMesh parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::ClonePMeshFVF( dword pOptions, dword pFVF, TDx9_3DDevice* pDevice, TDx9_3DXPMesh* pCloneMesh ) { // Original Function Definition // HRESULT ClonePMeshFVF( // DWORD Options, // DWORD FVF, // LPDIRECT3DDEVICE9 pDevice, // LPD3DXPMESH *ppCloneMesh // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ClonePMeshFVF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->ClonePMeshFVF( (DWORD) pOptions, (DWORD) pFVF, (pDevice==NULL) ? NULL : pDevice->Internal_LPDIRECT3DDEVICE9, (pCloneMesh==NULL) ? NULL : pCloneMesh->Internal_LPD3DXPMESH_Ptr ); // Translate Data returned from Function if (pCloneMesh!=NULL) pCloneMesh->Internal_LPD3DXPMESH_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ClonePMeshFVF()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: ConvertAdjacencyToPointReps() // Description: The ConvertAdjacencyToPointReps method is used to ... // Params: pDWORD* - // The DWORD* parameter ... // pAdjacency - // The Adjacency parameter ... // pPRep - // The PRep parameter ... // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Method: ConvertPointRepsToAdjacency() // Description: The ConvertPointRepsToAdjacency method is used to ... // Params: pDWORD* - // The DWORD* parameter ... // pPRep - // The PRep parameter ... // pAdjacency - // The Adjacency parameter ... // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Method: Create() // Description: The Create() method is used to automatically create the // internal LPD3DXPMESH interface used in the TDx9_3DXPMesh // component and must be called before any methods of the // TDx9_3DXPMesh component will function. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::Create() { fCreated = true; if (fCreated && FOnCreate) FOnCreate(this); return fCreated; } // -------------------------------------------------------------------------- // Method: Destroy() // Description: The Destroy() method is used to automatically destroy the // internal LPD3DXPMESH interface used in the TDx9_3DXPMesh // component and should be called when the internal interface is // no longer required. // // Note: This method is called by the component's destructor. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::Destroy() { fCreated = false; if (FOnDestroy) FOnDestroy(this); return !fCreated; } // -------------------------------------------------------------------------- // Method: DrawSubset() // Description: The DrawSubset method is used to ... // Params: pAttribId - // The AttribId parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::DrawSubset( dword pAttribId ) { // Original Function Definition // HRESULT DrawSubset( // DWORD AttribId // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawSubset()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->DrawSubset( (DWORD) pAttribId ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawSubset()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GenerateAdjacency() // Description: The GenerateAdjacency method is used to ... // Params: pEpsilon - // The Epsilon parameter ... // pAdjacency - // The Adjacency parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GenerateAdjacency( float pEpsilon, dword* pAdjacency ) { // Original Function Definition // HRESULT GenerateAdjacency( // FLOAT fEpsilon, // DWORD* pAdjacency // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GenerateAdjacency()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GenerateAdjacency( (FLOAT) pEpsilon, (DWORD*) pAdjacency ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GenerateAdjacency()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GenerateVertexHistory() // Description: The GenerateVertexHistory method is used to ... // Params: pVertexHistory - // The VertexHistory parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GenerateVertexHistory( dword* pVertexHistory ) { // Original Function Definition // HRESULT GenerateVertexHistory( // DWORD* pVertexHistory // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GenerateVertexHistory()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GenerateVertexHistory( (DWORD*) pVertexHistory ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GenerateVertexHistory()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetAdjacency() // Description: The GetAdjacency method is used to ... // Params: pAdjacency - // The Adjacency parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GetAdjacency( dword* pAdjacency ) { // Original Function Definition // HRESULT GetAdjacency( // DWORD *pAdjacency // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetAdjacency()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetAdjacency( (DWORD*) pAdjacency ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetAdjacency()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetAttributeTable() // Description: The GetAttributeTable method is used to ... // Params: pAttribTable - // The AttribTable parameter ... // pAttribTableSize - // The AttribTableSize parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GetAttributeTable( D3DXATTRIBUTERANGE* pAttribTable, dword* pAttribTableSize ) { // Original Function Definition // HRESULT GetAttributeTable( // D3DXATTRIBUTERANGE *pAttribTable, // DWORD *pAttribTableSize // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetAttributeTable()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetAttributeTable( pAttribTable, (DWORD*) pAttribTableSize ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetAttributeTable()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDeclaration() // Description: The GetDeclaration method is used to ... // Params: pDeclaration[MAX_FVF_DECL_SIZE] - // The Declaration[MAX_FVF_DECL_SIZE] parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GetDeclaration( D3DVERTEXELEMENT9 pDeclaration[MAX_FVF_DECL_SIZE] ) { // Original Function Definition // HRESULT GetDeclaration( // D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE] // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDeclaration()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetDeclaration( pDeclaration[MAX_FVF_DECL_SIZE] ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDeclaration()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDevice() // Description: The GetDevice method is used to ... // Params: pDevice - // The Device parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GetDevice( TDx9_3DDevice* pDevice ) { // Original Function Definition // HRESULT GetDevice( // LPDIRECT3DDEVICE9 *ppDevice // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDevice()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetDevice( (pDevice==NULL) ? NULL : pDevice->Internal_LPDIRECT3DDEVICE9_Ptr ); // Translate Data returned from Function if (pDevice!=NULL) pDevice->Internal_LPDIRECT3DDEVICE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDevice()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetFVF() // Description: The GetFVF method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetFVF() { // Original Function Definition // DWORD GetFVF(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetFVF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetFVF( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetFVF()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetIndexBuffer() // Description: The GetIndexBuffer method is used to ... // Params: pIB - // The IB parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GetIndexBuffer( TDx9_3DIndexBuffer* pIB ) { // Original Function Definition // HRESULT GetIndexBuffer( // LPDIRECT3DINDEXBUFFER9 *ppIB // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetIndexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetIndexBuffer( (pIB==NULL) ? NULL : pIB->Internal_LPDIRECT3DINDEXBUFFER9_Ptr ); // Translate Data returned from Function if (pIB!=NULL) pIB->Internal_LPDIRECT3DINDEXBUFFER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetIndexBuffer()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetMaxFaces() // Description: The GetMaxFaces method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetMaxFaces() { // Original Function Definition // DWORD GetMaxFaces(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetMaxFaces()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetMaxFaces( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetMaxFaces()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetMaxVertices() // Description: The GetMaxVertices method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetMaxVertices() { // Original Function Definition // DWORD GetMaxVertices(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetMaxVertices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetMaxVertices( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetMaxVertices()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetMinFaces() // Description: The GetMinFaces method is used to ... // -------------------------------------------------------------------------- DWORD __fastcall TDx9_3DXPMesh::GetMinFaces() { return (DWORD) NULL; } // -------------------------------------------------------------------------- // Method: GetMinVertices() // Description: The GetMinVertices method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetMinVertices() { // Original Function Definition // DWORD GetMinVertices(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetMinVertices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetMinVertices( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetMinVertices()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetNumBytesPerVertex() // Description: The GetNumBytesPerVertex method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetNumBytesPerVertex() { // Original Function Definition // DWORD GetNumBytesPerVertex(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetNumBytesPerVertex()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetNumBytesPerVertex( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetNumBytesPerVertex()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetNumFaces() // Description: The GetNumFaces method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetNumFaces() { // Original Function Definition // DWORD GetNumFaces(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetNumFaces()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetNumFaces( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetNumFaces()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetNumVertices() // Description: The GetNumVertices method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetNumVertices() { // Original Function Definition // DWORD GetNumVertices(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetNumVertices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetNumVertices( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetNumVertices()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetOptions() // Description: The GetOptions method is used to ... // -------------------------------------------------------------------------- dword __fastcall TDx9_3DXPMesh::GetOptions() { // Original Function Definition // DWORD GetOptions(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetOptions()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetOptions( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetOptions()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return <>; } // Success! return <>; } // -------------------------------------------------------------------------- // Method: GetVertexBuffer() // Description: The GetVertexBuffer method is used to ... // Params: pVB - // The VB parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::GetVertexBuffer( TDx9_3DVertexBuffer* pVB ) { // Original Function Definition // HRESULT GetVertexBuffer( // LPDIRECT3DVERTEXBUFFER9 *ppVB // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetVertexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->GetVertexBuffer( (pVB==NULL) ? NULL : pVB->Internal_LPDIRECT3DVERTEXBUFFER9_Ptr ); // Translate Data returned from Function if (pVB!=NULL) pVB->Internal_LPDIRECT3DVERTEXBUFFER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetVertexBuffer()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: LockIndexBuffer() // Description: The LockIndexBuffer method is used to ... // Params: pFlags - // The Flags parameter ... // pData - // The Data parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::LockIndexBuffer( dword pFlags, void** pData ) { // Original Function Definition // HRESULT LockIndexBuffer( // DWORD Flags, // VOID **ppData // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::LockIndexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->LockIndexBuffer( (DWORD) pFlags, (VOID**) pData ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::LockIndexBuffer()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: LockVertexBuffer() // Description: The LockVertexBuffer method is used to ... // Params: pFlags - // The Flags parameter ... // pData - // The Data parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::LockVertexBuffer( dword pFlags, void** pData ) { // Original Function Definition // HRESULT LockVertexBuffer( // DWORD Flags, // VOID **ppData // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::LockVertexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->LockVertexBuffer( (DWORD) pFlags, (VOID**) pData ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::LockVertexBuffer()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Optimize() // Description: The Optimize method is used to ... // Params: pFlags - // The Flags parameter ... // pAdjacencyOut - // The AdjacencyOut parameter ... // pFaceRemap - // The FaceRemap parameter ... // pVertexRemap - // The VertexRemap parameter ... // pOptMesh - // The OptMesh parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::Optimize( dword pFlags, dword* pAdjacencyOut, dword* pFaceRemap, LPD3DXBUFFER* pVertexRemap, LPD3DXMESH* pOptMesh ) { // Original Function Definition // HRESULT Optimize( // DWORD Flags, // DWORD *pAdjacencyOut, // DWORD *pFaceRemap, // LPD3DXBUFFER *ppVertexRemap, // LPD3DXMESH *ppOptMesh // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Optimize()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->Optimize( (DWORD) pFlags, (DWORD*) pAdjacencyOut, (DWORD*) pFaceRemap, pVertexRemap, pOptMesh ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Optimize()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: OptimizeBaseLOD() // Description: The OptimizeBaseLOD method is used to ... // Params: pFlags - // The Flags parameter ... // pFaceMap - // The FaceMap parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::OptimizeBaseLOD( dword pFlags, dword* pFaceMap ) { // Original Function Definition // HRESULT OptimizeBaseLOD( // DWORD Flags, // DWORD *pFaceMap // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::OptimizeBaseLOD()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->OptimizeBaseLOD( (DWORD) pFlags, (DWORD*) pFaceMap ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::OptimizeBaseLOD()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Save() // Description: The Save method is used to ... // Params: pStream - // The Stream parameter ... // pD3DXMATERIAL - // The D3DXMATERIAL parameter ... // pD3DXEFFECTINSTANCE* - // The D3DXEFFECTINSTANCE* parameter ... // pEffectInstances - // The EffectInstances parameter ... // pNumMaterials - // The NumMaterials parameter ... // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Method: SetNumFaces() // Description: The SetNumFaces method is used to ... // Params: pFaces - // The Faces parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::SetNumFaces( dword pFaces ) { // Original Function Definition // HRESULT SetNumFaces( // DWORD Faces // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetNumFaces()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->SetNumFaces( (DWORD) pFaces ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetNumFaces()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetNumVertices() // Description: The SetNumVertices method is used to ... // Params: pVertices - // The Vertices parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::SetNumVertices( dword pVertices ) { // Original Function Definition // HRESULT SetNumVertices( // DWORD Vertices // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetNumVertices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->SetNumVertices( (DWORD) pVertices ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetNumVertices()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: TrimByFaces() // Description: The TrimByFaces method is used to ... // Params: pNewFacesMin - // The NewFacesMin parameter ... // pNewFacesMax - // The NewFacesMax parameter ... // pFaceRemap - // The FaceRemap parameter ... // pVertRemap - // The VertRemap parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::TrimByFaces( dword pNewFacesMin, dword pNewFacesMax, dword* pFaceRemap, dword* pVertRemap ) { // Original Function Definition // HRESULT TrimByFaces( // DWORD NewFacesMin, // DWORD NewFacesMax, // DWORD *rgiFaceRemap, // DWORD *rgiVertRemap // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::TrimByFaces()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->TrimByFaces( (DWORD) pNewFacesMin, (DWORD) pNewFacesMax, (DWORD*) pFaceRemap, (DWORD*) pVertRemap ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::TrimByFaces()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: TrimByVertices() // Description: The TrimByVertices method is used to ... // Params: pNewVerticesMin - // The NewVerticesMin parameter ... // pNewVerticessMax - // The NewVerticessMax parameter ... // pFaceRemap - // The FaceRemap parameter ... // pVertRemap - // The VertRemap parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::TrimByVertices( dword pNewVerticesMin, dword pNewVerticessMax, dword* pFaceRemap, dword* pVertRemap ) { // Original Function Definition // HRESULT TrimByVertices( // DWORD NewVerticesMin, // DWORD NewVerticessMax, // DWORD *rgiFaceRemap, // DWORD *rgiVertRemap // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::TrimByVertices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->TrimByVertices( (DWORD) pNewVerticesMin, (DWORD) pNewVerticessMax, (DWORD*) pFaceRemap, (DWORD*) pVertRemap ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::TrimByVertices()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: UnlockIndexBuffer() // Description: The UnlockIndexBuffer method is used to ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::UnlockIndexBuffer() { // Original Function Definition // HRESULT UnlockIndexBuffer(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::UnlockIndexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->UnlockIndexBuffer( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::UnlockIndexBuffer()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: UnlockVertexBuffer() // Description: The UnlockVertexBuffer method is used to ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::UnlockVertexBuffer() { // Original Function Definition // HRESULT UnlockVertexBuffer(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::UnlockVertexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->UnlockVertexBuffer( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::UnlockVertexBuffer()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: UpdateSemantics() // Description: The UpdateSemantics method is used to ... // Params: pDeclaration[MAX_FVF_DECL_SIZE] - // The Declaration[MAX_FVF_DECL_SIZE] parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DXPMesh::UpdateSemantics( D3DVERTEXELEMENT9 pDeclaration[MAX_FVF_DECL_SIZE] ) { // Original Function Definition // HRESULT UpdateSemantics( // D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE] // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::UpdateSemantics()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPD3DXPMESH->UpdateSemantics( pDeclaration[MAX_FVF_DECL_SIZE] ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::UpdateSemantics()", TDx9_3DX_Library_ErrorString(fErrorValue), TDx9_3DX_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Internal Interface Access // -------------------------------------------------------------------------- LPD3DXPMESH __fastcall TDx9_3DXPMesh::FGetInternal_LPD3DXPMESH() { return fLPD3DXPMESH; } // -------------------------------------------------------------------------- LPD3DXPMESH* __fastcall TDx9_3DXPMesh::FGetInternal_LPD3DXPMESH_Ptr() { return &fLPD3DXPMESH; } // -------------------------------------------------------------------------- void __fastcall TDx9_3DXPMesh::FSetInternal_LPD3DXPMESH( LPD3DXPMESH pLPD3DXPMESH ) { if (!fCreated) { fLPD3DXPMESH = pLPD3DXPMESH; fCreated = (fLPD3DXPMESH!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx9_3DXPMesh::Internal_LPD3DXPMESH_Update() { fCreated = (fLPD3DXPMESH!=NULL); } // --------------------------------------------------------------------------