当前位置: 首页>>代码示例>>C++>>正文


C++ LPD3DXMESH::GetNumFaces方法代码示例

本文整理汇总了C++中LPD3DXMESH::GetNumFaces方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXMESH::GetNumFaces方法的具体用法?C++ LPD3DXMESH::GetNumFaces怎么用?C++ LPD3DXMESH::GetNumFaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPD3DXMESH的用法示例。


在下文中一共展示了LPD3DXMESH::GetNumFaces方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawMeshContainer

/**
 * \brief Called to render a mesh
 * \param device - the Direct3D device object
 * \param meshContainerBase - the mesh container
 * \param frameBase - frame containing the mesh
 * \author Keith Ditchburn \date 18 July 2005
*/
void CXFileEntity::DrawMeshContainer(LPD3DXMESHCONTAINER meshContainerBase, LPD3DXFRAME frameBase)
{
	DWORD attrSize = 0;
	// Cast to our extended frame type
	D3DXFRAME_EXTENDED *frame = (D3DXFRAME_EXTENDED*)frameBase;		

	// Cast to our extended mesh container
	D3DXMESHCONTAINER_EXTENDED *meshContainer = (D3DXMESHCONTAINER_EXTENDED*)meshContainerBase;
	
	// Set the world transform
    m_d3dDevice->SetTransform(D3DTS_WORLD, &frame->exCombinedTransformationMatrix);

	unsigned int pass;
	if (effect) {
		effect->SetMatrix("worldmat",&frame->exCombinedTransformationMatrix);

		effect->Begin(&pass,0);
		effect->BeginPass(0);
	}

	// Loop through all the materials in the mesh rendering each subset
    for (unsigned int iMaterial = 0; iMaterial < meshContainer->NumMaterials; iMaterial++)
    {
		// use the material in our extended data rather than the one in meshContainer->pMaterials[iMaterial].MatD3D
		//m_d3dDevice->SetMaterial( &meshContainer->exMaterials[iMaterial] );
		//m_d3dDevice->SetTexture( 0, meshContainer->exTextures[iMaterial] );

		// Select the mesh to draw, if there is skin then use the skinned mesh else the normal one
		LPD3DXMESH pDrawMesh = (meshContainer->pSkinInfo) ? meshContainer->exSkinMesh: meshContainer->MeshData.pMesh;

		// Finally Call the mesh draw function
        //pDrawMesh->DrawSubset(iMaterial);

		pDrawMesh->GetVertexBuffer(&vb.vb);
		pDrawMesh->GetIndexBuffer(&ib.ib);

		//D3DVERTEXELEMENT9 pDecl[MAX_FVF_DECL_SIZE];
		//pDrawMesh->GetDeclaration(pDecl);
		//renderSystem->CreateVertexDeclaration(&pDecl[0],&vb.declaration);
		// Получение данных о количестве вершин, индексов и полигонов
		dwNumVerticies	= pDrawMesh->GetNumVertices();
		dwNumIndecies	= pDrawMesh->GetNumFaces()*3;
		dwNumFaces		= pDrawMesh->GetNumFaces();
		vb.vertexSize = (short)pDrawMesh->GetNumBytesPerVertex();

		renderSystem->DrawIndexedPrimitive(vb,0,dwNumVerticies,ib,0,dwNumFaces);
    }

	if (effect) {
		effect->EndPass();
		effect->End();
	}
}
开发者ID:corpsofengineers,项目名称:ffed3d,代码行数:60,代码来源:XfileEntity.cpp

示例2: LoadMesh

void cMyASELoader::LoadMesh(){
#ifdef _DEBUG
	_ASSERT(m_bLoaded && "Data Not Loaded");
#endif
	int check = 0;
	for (size_t i = 0; i < m_vecASENode.size(); i++){
		if (m_vecASENode[i].nRef != INT_MAX){
			m_vecsubSet.push_back(m_vecASENode[i].nRef);
			LPD3DXMESH pMesh = NULL;
			HRESULT hr = D3DXCreateMeshFVF(m_vecASENode[i].vecVertex.size() / 3,
				m_vecASENode[i].vecVertex.size(),
				D3DXMESH_MANAGED,
				ST_PNT_VERTEX::FVF,
				g_pD3DDevice,
				&pMesh);

			ST_PNT_VERTEX* pV = NULL;
			pMesh->LockVertexBuffer(0, (LPVOID*)&pV);
			memcpy(pV, &m_vecASENode[i].vecVertex[0], m_vecASENode[i].vecVertex.size() * sizeof(ST_PNT_VERTEX));
			pMesh->UnlockVertexBuffer();

			WORD* pI = NULL;
			pMesh->LockIndexBuffer(0, (LPVOID*)&pI);
			for (size_t j = 0; j < pMesh->GetNumVertices(); ++j)
			{
				pI[j] = j;
			}
			pMesh->UnlockIndexBuffer();

			DWORD* pA = NULL;
			pMesh->LockAttributeBuffer(0, &pA);
			for (size_t j = 0; j < pMesh->GetNumFaces(); j++){
				pA[j] = m_vecASENode[i].nRef;
			}
			pMesh->UnlockAttributeBuffer();

			std::vector<DWORD> vecAdjBuffer(m_vecASENode[i].vecVertex.size());
			pMesh->GenerateAdjacency(0.0f, &vecAdjBuffer[0]);

			pMesh->OptimizeInplace(
				D3DXMESHOPT_ATTRSORT |
				D3DXMESHOPT_COMPACT |
				D3DXMESHOPT_VERTEXCACHE,
				&vecAdjBuffer[0], 0, 0, 0);

			m_vecMeshs.push_back(pMesh);
		}
	}
	m_bMeshed = true;
}
开发者ID:arkiny,项目名称:Direct3D,代码行数:50,代码来源:cMyASELoader.cpp

示例3: ASSERT

HRESULT KG3DMesh::_LoadBSPFileFromMemory(IKG_Buffer *piBSPFile)
{
	HRESULT hrResult  = E_FAIL;
    HRESULT hrRetCode = E_FAIL;
    DWORD dwBSPVertexCount = 0;
    DWORD dwBSPFaceCount = 0;
    DWORD dwMeshVerticesCount = 0;
    DWORD dwMeshFacesCount = 0;
    LPD3DXMESH piMesh = m_ppMeshes[SMBT_NORMAL];
    KG3DBsp *pBSP = NULL;
   
    ASSERT(piBSPFile);

    KGLOG_PROCESS_ERROR(piMesh);
    dwMeshFacesCount    = piMesh->GetNumFaces();
    dwMeshVerticesCount = piMesh->GetNumVertices();

    pBSP = new KG3DBsp;
    KGLOG_PROCESS_ERROR(pBSP);

	hrRetCode = pBSP->LoadFromMemory(piBSPFile);
	KGLOG_COM_PROCESS_ERROR(hrRetCode);

    hrRetCode = pBSP->GetMeshInfo(&dwBSPVertexCount, &dwBSPFaceCount);
    KGLOG_COM_PROCESS_ERROR(hrRetCode);

    if ((dwBSPVertexCount != dwMeshVerticesCount) || (dwBSPFaceCount != dwMeshFacesCount))
    {
        KGLogPrintf(KGLOG_ERR, "%s, BSP unmatch Mesh :(", m_scName.c_str());
        KG_PROCESS_ERROR(FALSE);
    }

    ASSERT(!m_lpBsp);
    m_lpBsp = pBSP;
    pBSP = NULL;
	hrResult = S_OK;
Exit0:
    KG_DELETE(pBSP);
	if(FAILED(hrResult))
	{
		KGLogPrintf(KGLOG_ERR, "%s BSP加载失败", m_scName.c_str());
	}
	return hrResult;
}
开发者ID:1suming,项目名称:pap2,代码行数:44,代码来源:KG3DMeshLoader.cpp

示例4: D3DXMeshCreateAttributeEnumer

HRESULT D3DXMeshCreateAttributeEnumer(LPD3DXMESH pMesh, D3DXMeshAttributeEnumer& enumer )
{
	_ASSERTE(! enumer.IsValid());
	ZeroMemory(&enumer, sizeof(D3DXMeshAttributeEnumer)); //因为外部传入的enumer是可能重用的,这里绝对要重新清空一次

	_ASSERTE(NULL != pMesh);
	KG_PROCESS_ERROR(NULL != pMesh);
	{
		HRESULT hr = pMesh->LockAttributeBuffer(0, reinterpret_cast<DWORD**>(&enumer.m_pBuffer));
		KG_COM_PROCESS_ERROR(hr);
		_ASSERTE(1 == sizeof(BYTE) && 2 == sizeof(WORD) && 4 == sizeof(DWORD));

		enumer.m_pMesh = pMesh;
		enumer.m_pMesh->AddRef();
		enumer.m_dwNumFaceCount = pMesh->GetNumFaces();

		return S_OK;
	}
Exit0:
	return E_FAIL;
}
开发者ID:1suming,项目名称:pap2,代码行数:21,代码来源:KG3DMeshHelpers.cpp

示例5: D3DXMeshCreateIndexEnumer

HRESULT D3DXMeshCreateIndexEnumer( LPD3DXMESH pMesh, D3DXMeshIndexEnumer& enumer )
{
	_ASSERTE(! enumer.IsValid());
	ZeroMemory(&enumer, sizeof(D3DXMeshIndexEnumer)); //因为外部传入的enumer是可能重用的,这里绝对要重新清空一次

	_ASSERTE(NULL != pMesh);
	KG_PROCESS_ERROR(NULL != pMesh);
	{
		HRESULT hr = pMesh->LockIndexBuffer(0, reinterpret_cast<LPVOID*>(&enumer.m_pBuffer));
		KG_COM_PROCESS_ERROR(hr);
		_ASSERTE(1 == sizeof(BYTE) && 2 == sizeof(WORD) && 4 == sizeof(DWORD));

		enumer.m_pMesh = pMesh;
		enumer.m_pMesh->AddRef();
		enumer.m_dwNumBytePerIndex = (pMesh->GetOptions() & D3DXMESH_32BIT) ? 4 : 2;
		enumer.m_dwNumIndexCount = pMesh->GetNumFaces() * 3;
	
		return S_OK;
	}
Exit0:
	return E_FAIL;
}
开发者ID:1suming,项目名称:pap2,代码行数:22,代码来源:KG3DMeshHelpers.cpp

示例6: D3DXMeshCreateByVerticesPos

HRESULT D3DXMeshCreateByVerticesPos( DWORD dwFVF, D3DVECTOR* pPosArray, DWORD dwVertexCount
									, DWORD* pIndexArray, DWORD dwNumIndexCount
									, LPDIRECT3DDEVICE9 pDevice, DWORD dwOption, LPD3DXMESH* pRet )
{
	HRESULT hr = E_FAIL;
	LPD3DXMESH pMesh = NULL;
	KG_PROCESS_ERROR((dwFVF & D3DFVF_XYZ));
	KG_PROCESS_ERROR(NULL != pPosArray && NULL != pIndexArray && NULL != pDevice && NULL != pRet);

	_ASSERTE(IsMeshValidToBeCreated(dwOption, dwVertexCount, dwNumIndexCount));

	{
		DWORD dwNumFaces = dwNumIndexCount / 3;
		
		hr = D3DXCreateMeshFVF(dwNumFaces, dwVertexCount, dwOption, dwFVF, pDevice, &pMesh);
		KG_COM_PROCESS_ERROR(hr);
		
#if defined(DEBUG) | defined(_DEBUG)
		ULONG uRefSave = KGGetRef(pMesh);
#endif

		{
			BOOL bValidity = pMesh->GetNumVertices() == dwVertexCount && pMesh->GetNumFaces() == dwNumFaces;
			KG_PROCESS_ERROR(bValidity);
		}
		
		_ASSERTE(sizeof(BYTE) == 1);
		{
			D3DXMeshVertexEnumer vertexEnumer;
			hr = D3DXMeshCreateVertexEnumer(pMesh, vertexEnumer);
			KG_COM_PROCESS_ERROR(hr);
			_ASSERTE(vertexEnumer.IsValid() && vertexEnumer.GetVertexCount() == dwVertexCount);
			for (UINT i = 0; i < vertexEnumer.GetVertexCount(); ++i)
			{
				vertexEnumer.SetPos(i, pPosArray[i]);
			}
		}

		{
			D3DXMeshIndexEnumer indexEnumer;
			hr = D3DXMeshCreateIndexEnumer(pMesh, indexEnumer);
			KG_COM_PROCESS_ERROR(hr);
			_ASSERTE(indexEnumer.IsValid() && indexEnumer.GetIndexCount() <= dwNumIndexCount);
			
			for (UINT i = 0; i < indexEnumer.GetIndexCount(); ++i)
			{
				indexEnumer.SetIndex(i, pIndexArray[i]);
			}
		}

		D3DXMeshZeroMeshAttributes(pMesh);

		_ASSERTE(uRefSave == KGGetRef(pMesh));
	}
	
	*pRet = pMesh;
	return S_OK;
Exit0:
	SAFE_RELEASE(pMesh);
	return E_FAIL;
}
开发者ID:1suming,项目名称:pap2,代码行数:61,代码来源:KG3DMeshHelpers.cpp

示例7: CreateGeometry

void CreateGeometry(const char* sourceFile)
{
    cout << endl << "Reading " << sourceFile << endl;
    wstring wideSourceFile(sourceFile, sourceFile + strlen(sourceFile));

    // Load the mesh from the specified file
    LPD3DXBUFFER pD3DXMtrlBuffer;
    LPD3DXBUFFER pD3DXEffectInstances;
    HRESULT hr = D3DXLoadMeshFromX(
        wideSourceFile.c_str(),
        D3DXMESH_SYSTEMMEM,
        g_pd3dDevice, 0,
        &pD3DXMtrlBuffer, &pD3DXEffectInstances, &g_dwNumMaterials,
        &g_pMesh);

    if (FAILED(hr))
    {
        MessageBox(0, (L"Could not find " + wideSourceFile).c_str(), L"X2CTM", MB_OK);
        exit(1);
    }

    DWORD* adjacencyIn = new DWORD[3 * g_pMesh->GetNumFaces()];
    g_pMesh->GenerateAdjacency(0.0001f, adjacencyIn);

    DWORD* adjacencyOut = new DWORD[3 * g_pMesh->GetNumFaces()];

    LPD3DXMESH newMesh = 0;
    //hr = g_pMesh->Optimize(D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT, adjacencyIn, adjacencyOut, 0, 0, &newMesh);
    //hr = g_pMesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT, adjacencyIn, adjacencyOut, 0, 0);
    if (FAILED(hr))
    {
        MessageBox(0, L"Unable to build attribute table", L"Whatever", MB_OK);
        exit(1);
    }
    //g_pMesh = newMesh;

    if (WeldVertices)
    {
        DWORD beforeVertCount = g_pMesh->GetNumVertices();
        DWORD beforeFaceCount = g_pMesh->GetNumFaces();
        hr = D3DXWeldVertices(g_pMesh, D3DXWELDEPSILONS_WELDALL, 0, 0, 0, 0, 0);
        DWORD afterVertCount = g_pMesh->GetNumVertices();
        DWORD afterFaceCount = g_pMesh->GetNumFaces();
    }

    D3DXATTRIBUTERANGE table[256];
    DWORD tableSize = sizeof(table) / sizeof(table[0]);
    g_pMesh->GetAttributeTable(&table[0], &tableSize);

    D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*) pD3DXMtrlBuffer->GetBufferPointer();
    D3DXEFFECTINSTANCE* d3dxEffects = (D3DXEFFECTINSTANCE*) pD3DXEffectInstances->GetBufferPointer();

    g_pMeshMaterials = new D3DMATERIAL9[g_dwNumMaterials];
    g_pMeshTextures = new LPDIRECT3DTEXTURE9[g_dwNumMaterials];

    for (DWORD i = 0; i < g_dwNumMaterials; i++)
    {
        g_pMeshMaterials[i] = d3dxMaterials[i].MatD3D;
        g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse;
        g_pMeshTextures[i] = 0;
        if (d3dxMaterials[i].pTextureFilename && lstrlenA(d3dxMaterials[i].pTextureFilename) > 0)
        {
            D3DXCreateTextureFromFileA(g_pd3dDevice, d3dxMaterials[i].pTextureFilename, &g_pMeshTextures[i]);
        }
    }
/*
    for (DWORD attrib = 0;  attrib < tableSize; ++attrib)
    {

        // I'm not so sure about material-to-attribute correlation
//        if (attrib < g_dwNumMaterials)
//        {
            LPSTR pTexture = d3dxMaterials[attrib].pTextureFilename;
            LPSTR pSlash = strchr(pTexture, '\\');
            if (pSlash)
            {
                pTexture = ++pSlash;
            }
            cout << "{Texture='" << pTexture << "',";
//        }

        string subMeshFilename = string("X_") + string("Armature.ctm"); // string(pTexture).substr(0, strlen(pTexture) - 4) + ".ctm";
        subMeshFilename[0] = attrib + 'A';

        ExportRangeCTM(table[attrib], g_pMesh, subMeshFilename.c_str());

        cout
            //<< table[attrib].AttribId << ' '
            << "FaceStart=" << table[attrib].FaceStart << ','
            << "FaceCount=" << table[attrib].FaceCount << ','
            << "VertexStart=" << table[attrib].VertexStart << ','
            << "VertexCount=" << table[attrib].VertexCount << '}' << endl;
    }
*/
    pD3DXMtrlBuffer->Release();


    // Convert the filename from .X to .CTM while preserving the full path.

   char destFile[_MAX_PATH];
//.........这里部分代码省略.........
开发者ID:jsj2008,项目名称:blog-source,代码行数:101,代码来源:Converter.cpp

示例8: CreateMeshContainer

//====================================================================================
// メッシュコンテナの作成(XFileの各パーツの集合)ようはスキンメッシュモデルをここで作る
//====================================================================================
HRESULT CInheritanceHierarchy::CreateMeshContainer(LPCSTR Name, CONST D3DXMESHDATA* pMeshData,
													CONST D3DXMATERIAL* pMaterials, CONST D3DXEFFECTINSTANCE* pEffectInstances,
													DWORD NumMaterials, CONST DWORD *pAdjacency, LPD3DXSKININFO pSkinInfo, 
													LPD3DXMESHCONTAINER *ppMeshContainer )
{
	//========================================================================
	// コンテナ作成に当たって必要な変数を用意
	//========================================================================
	MYMESHCONTAINER *pMeshContainer = NULL;
	int iFacesAmount;
	DWORD iMaterial;
	LPDIRECT3DDEVICE9 pDevice = NULL;
	LPD3DXMESH pMesh = NULL;
	*ppMeshContainer = NULL;
	DWORD dwBoneNum=0;

	//========================================================================
	// コンテナを動的確保して値を入れていく作業へ
	//========================================================================
	pMesh = pMeshData->pMesh;
	pMeshContainer = new MYMESHCONTAINER;

	//メモリ不足のときは終了
	if (pMeshContainer == NULL)
	{
		return E_OUTOFMEMORY;
	}

	//作成に成功したら中身を0で初期化しておく
	ZeroMemory(pMeshContainer, sizeof(MYMESHCONTAINER));

	//メッシュコンテナとしてXFileでつけられてる名前を拾う
	pMeshContainer->Name=new TCHAR[lstrlen(Name) + 1];	// \0分の+1

	//名前がなかったらおかしいので終了
	if (!pMeshContainer->Name)
	{
		return E_FAIL;
	}

	//名前があるならそれにする
	strcpy(pMeshContainer->Name,Name);

	// デバイスゲット
	pMesh->GetDevice(&pDevice);

	// 面の数ゲット
	iFacesAmount = pMesh->GetNumFaces();

	pMeshContainer->MeshData.pMesh = pMesh;
	pMeshContainer->MeshData.Type = D3DXMESHTYPE_MESH;

	//通常メッシュの場合はこれが必要。スキンの場合、これをするとメモリリークになる。
	if (pSkinInfo == NULL)
	{
		pMesh->AddRef();
	}

	//メッシュのマテリアル設定
	pMeshContainer->NumMaterials = max(1, NumMaterials);
	pMeshContainer->pMaterials = new D3DXMATERIAL[pMeshContainer->NumMaterials];
	pMeshContainer->ppTextures = new LPDIRECT3DTEXTURE9[pMeshContainer->NumMaterials];
	pMeshContainer->pAdjacency = new DWORD[iFacesAmount * NUM_POLYGON_CREATE_TRIANGLE];

	//隣接性情報またはマテリアルがなければ終了
	if( pMeshContainer->pAdjacency == NULL
	||	pMeshContainer->pMaterials == NULL )
	{
		return E_FAIL;
	}

	//情報をメッシュコンテナに流し込む
	memcpy(pMeshContainer->pAdjacency, pAdjacency, sizeof(DWORD) * iFacesAmount * NUM_POLYGON_CREATE_TRIANGLE);
	memset(pMeshContainer->ppTextures, 0, sizeof(LPDIRECT3DTEXTURE9) * pMeshContainer->NumMaterials);

	//========================================================================
	//該当メッシュがスキン情報を持っている場合
	//========================================================================
	if (pSkinInfo != NULL)
	{
		pMeshContainer->pSkinInfo = pSkinInfo;
		pSkinInfo->AddRef();
		dwBoneNum = pSkinInfo->GetNumBones();
		pMeshContainer->pBoneOffsetMatrices = new D3DXMATRIX[dwBoneNum];
		for (DWORD i = 0; i < dwBoneNum; i++)
		{
			memcpy(&pMeshContainer->pBoneOffsetMatrices[i], pMeshContainer->pSkinInfo->GetBoneOffsetMatrix(i), sizeof(D3DMATRIX));
		}

		// インデックスつきのものに変換   シェーダー使わないやつとは別なので注意
		if (FAILED(pMeshContainer->pSkinInfo->ConvertToIndexedBlendedMesh(pMesh,
			NULL,
			dwBoneNum,
			pMeshContainer->pAdjacency,
			NULL,
			NULL,
			NULL,
//.........这里部分代码省略.........
开发者ID:NojiriMisoten,项目名称:OMTT,代码行数:101,代码来源:CInheritanceHierarchy.cpp

示例9: GenerateCache

void MeshParameterization::GenerateCache( LPD3DXMESH meshOut, LPD3DXBUFFER remapped )
{
	paramVertex * pNewVerts = NULL;
	IToolBox * tool = EngineGetToolBox();
			
	HRESULT hr;
	m_Cache.Clean();
	//have to now be able to map a face to a texture area, or, a face to a chart.
	int numVertices = m_CollapsedMesh->size();
	int numNewVertices = remapped->GetBufferSize() / sizeof( DWORD );

	if( numNewVertices != numVertices )
	{
		//Our cache is a remapping cache! New vertices were generated!!!!
		m_Cache.m_bRemapped = true;

		//First we remap our vertices
		int remapsize = remapped->GetBufferSize() / sizeof( DWORD );
		DWORD * remappedData = (DWORD*) remapped->GetBufferPointer();

		m_Cache.m_NumVertices = remapsize;
		m_Cache.ResizeRemappedData( remapsize );
		m_Cache.ResizeUVData(  remapsize*2 );
		memcpy( m_Cache.m_RemappedData, remappedData, sizeof( DWORD )*remapsize );

		vector< ParameterizationVertex > newVertBuffer;
		newVertBuffer.resize( remapsize );

		//loop through and assign new vertices
		hr = meshOut->LockVertexBuffer( 0, (LPVOID*)&pNewVerts );
		if( hr == D3D_OK &&
			pNewVerts)
		{
			for( int i = 0; i < remapsize; i++ )
			{
				int oldIndex = remappedData[ i ];
				newVertBuffer[ i ] = (*m_CollapsedMesh)[ oldIndex ];
				//UV for internal lightmap calcs
				NormalizeUV( pNewVerts[ i ].u );
				NormalizeUV( pNewVerts[ i ].v );
				newVertBuffer[ i ].generatedU = pNewVerts[ i ].u;
				newVertBuffer[ i ].generatedV = pNewVerts[ i ].v;
				//Duplicate uv to pass to render object as a stream
				m_Cache.m_UVData[ i*2 ]		= pNewVerts[ i ].u;
				m_Cache.m_UVData[ i*2 + 1 ] = pNewVerts[ i ].v;
			}
			meshOut->UnlockVertexBuffer();
			//assign new mesh
			m_CollapsedMesh->clear();
			(*m_CollapsedMesh) = newVertBuffer;
			newVertBuffer.clear();
		}else
		{
			tool->Log( LOGERROR, _T("Could not lock mesh param vertex buffer to remap vertices\n"));

		}
		//now do indices
		int numIndices = 3*meshOut->GetNumFaces();
		m_Cache.m_NumIndices = numIndices;
		m_Cache.ResizeRemappedIndices( numIndices );
		WORD * pIndices = NULL;
		hr = meshOut->LockIndexBuffer( 0, (LPVOID*)&pIndices );
		if( hr == D3D_OK &&
			pIndices)
		{
			for( int i = 0; i < numIndices; i++ )
			{
				m_Cache.m_RemappedIndices[ i ] = (DWORD)pIndices[ i ];
				//faces
				int faceIndex = i/3;
				int triIndex = i%3;
				(*m_Faces)[ faceIndex ].index[ triIndex ] = pIndices[ i ];
			}
		}else if( tool )
		{
			tool->Log( LOGERROR, _T("Could not lock mesh param index buffer to remap indices\n"));
		}
	}
	else //no remapping, just uvs needed
	{
		BYTE * pNewVerts = NULL;
		hr = meshOut->LockVertexBuffer( 0, (LPVOID*)&pNewVerts );
		
		m_Cache.m_NumVertices = m_CollapsedMesh->size();
		m_Cache.ResizeUVData( m_Cache.m_NumVertices*2 );
		if( hr == D3D_OK )
		{
			//copy new uvs
			paramVertex * pv = (paramVertex*)pNewVerts;
			for( int i = 0; i < (int)m_CollapsedMesh->size(); i++ )
			{
				NormalizeUV( pv[ i ].u );
				NormalizeUV( pv[ i ].v );
				(*m_CollapsedMesh)[i].generatedU = pv[ i ].u;
				(*m_CollapsedMesh)[i].generatedV = pv[ i ].v;
				//copy uvs for passing to render object as a stream
				m_Cache.m_UVData[ i*2 ] = pv[ i ].u;
				m_Cache.m_UVData[ i*2 + 1 ] = pv[ i ].v;
			}
			meshOut->UnlockVertexBuffer();
//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:MeshParameterization.cpp

示例10: main

int main(int argc, char* argv[])
{
	if (argc < 3)
	{
		puts("Usage: MeshConv meshfile rdffile");
		return 1;
	}

	// Initialize DirectDraw
	pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	if (pD3D == NULL)
	{
		puts("Cannot init D3D");
		return 1;
	}

	MeshMender mender;
	std::vector<MeshMender::Vertex> MendVerts;
	std::vector<unsigned int> MendIndices;
	std::vector<unsigned int> mappingNewToOld;

	HRESULT hr;
	D3DDISPLAYMODE dispMode;
	D3DPRESENT_PARAMETERS presentParams;

	pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dispMode);

	ZeroMemory(&presentParams, sizeof(presentParams));
	presentParams.Windowed = TRUE;
	presentParams.hDeviceWindow = GetConsoleWindow();
	presentParams.SwapEffect = D3DSWAPEFFECT_COPY;
	presentParams.BackBufferWidth = 8;
	presentParams.BackBufferHeight = 8;
	presentParams.BackBufferFormat = dispMode.Format;

	hr = pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParams, &pD3DDevice);
	if (FAILED(hr))
	{
		printf("Cannot init D3D device: %08x\n", hr);
		pD3D->Release();
		return 1;
	}

	printf("Loading mesh %s: ", argv[1]);

	LPD3DXBUFFER pAdjacency, pMaterials, pEffects;
	DWORD n;
	LPD3DXMESH pLoadMesh;
	hr = D3DXLoadMeshFromX(argv[1], D3DXMESH_SYSTEMMEM, pD3DDevice, &pAdjacency, &pMaterials, &pEffects, &n, &pLoadMesh);
	if (FAILED(hr))
	{
		printf("ERROR: %08x\n", hr);
		goto mesherror;
	}
	pEffects->Release();
	pMaterials->Release();
	printf("%d faces, %d verts\n", pLoadMesh->GetNumFaces(), pLoadMesh->GetNumVertices());

	LPD3DXMESH pMesh;
	if (pLoadMesh->GetFVF() != MESHFVF)
	{
		hr = pLoadMesh->CloneMeshFVF(D3DXMESH_SYSTEMMEM, MESHFVF, pD3DDevice, &pMesh);
		pLoadMesh->Release();
		if (FAILED(hr))
		{
			printf("CloneMesh error: %08x\n", hr);
			goto mesherror;
		}
	}
	else
		pMesh = pLoadMesh;

	printf("Welding verts: ");

	DWORD* pAdj = new DWORD[pAdjacency->GetBufferSize() / 4];

	D3DXWELDEPSILONS Eps;
	memset(&Eps, 0, sizeof(Eps));
	hr = D3DXWeldVertices(pMesh, D3DXWELDEPSILONS_WELDPARTIALMATCHES, &Eps, (DWORD*)pAdjacency->GetBufferPointer(), pAdj, NULL, NULL);
	if (FAILED(hr))
	{
		printf("ERROR: %08x\n", hr);
		goto mesherror;
	}
	
	hr = pMesh->OptimizeInplace(D3DXMESHOPT_VERTEXCACHE, pAdj, (DWORD*)pAdjacency->GetBufferPointer(), NULL, NULL);
	if (FAILED(hr))
	{
		printf("ERROR: %08x\n", hr);
		goto mesherror;
	}
	
	pAdjacency->Release();
	delete [] pAdj;

	printf("%d faces, %d verts\n", pMesh->GetNumFaces(), pMesh->GetNumVertices());

	printf("Mending mesh: ");

	DWORD NumVerts = pMesh->GetNumVertices();
//.........这里部分代码省略.........
开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:101,代码来源:MeshConv.cpp

示例11: CreateMeshContainer

HRESULT AllocateHierarchy::CreateMeshContainer(
	LPCSTR Name,
	CONST D3DXMESHDATA *pMeshData,
	CONST D3DXMATERIAL *pMaterials,
	CONST D3DXEFFECTINSTANCE *pEffectInstances,
	DWORD NumMaterials,
	CONST DWORD *pAdjacency,
	LPD3DXSKININFO pSkinInfo,
	LPD3DXMESHCONTAINER *ppNewMeshContainer)
{
    HRESULT hr;
    D3DXMESHCONTAINER_DERIVED *pMeshContainer = NULL;
    UINT NumFaces;
    UINT iMaterial;
    UINT iBone, cBones;
    LPDIRECT3DDEVICE9 pd3dDevice = NULL;

    LPD3DXMESH pMesh = NULL;

    *ppNewMeshContainer = NULL;

    // this sample does not handle patch meshes, so fail when one is found
    if (pMeshData->Type != D3DXMESHTYPE_MESH)
    {
        hr = E_FAIL;
        goto e_Exit;
    }

    // get the pMesh interface pointer out of the mesh data structure
    pMesh = pMeshData->pMesh;

    // this sample does not FVF compatible meshes, so fail when one is found
    if (pMesh->GetFVF() == 0)
    {
        hr = E_FAIL;
        goto e_Exit;
    }

    // allocate the overloaded structure to return as a D3DXMESHCONTAINER
    pMeshContainer = new D3DXMESHCONTAINER_DERIVED;
    if (pMeshContainer == NULL)
    {
        hr = E_OUTOFMEMORY;
        goto e_Exit;
    }
    memset(pMeshContainer, 0, sizeof(D3DXMESHCONTAINER_DERIVED));

    // make sure and copy the name.  All memory as input belongs to caller, interfaces can be addref'd though
    hr = AllocateName(Name, &pMeshContainer->Name);
    if (FAILED(hr))
        goto e_Exit;        

    pMesh->GetDevice(&pd3dDevice);
    NumFaces = pMesh->GetNumFaces();

    // if no normals are in the mesh, add them
    if (!(pMesh->GetFVF() & D3DFVF_NORMAL))
    {
        pMeshContainer->MeshData.Type = D3DXMESHTYPE_MESH;

        // clone the mesh to make room for the normals
        hr = pMesh->CloneMeshFVF( pMesh->GetOptions(), 
                                    pMesh->GetFVF() | D3DFVF_NORMAL, 
                                    pd3dDevice, &pMeshContainer->MeshData.pMesh );
        if (FAILED(hr))
            goto e_Exit;

        // get the new pMesh pointer back out of the mesh container to use
        // NOTE: we do not release pMesh because we do not have a reference to it yet
        pMesh = pMeshContainer->MeshData.pMesh;

        // now generate the normals for the pmesh
        D3DXComputeNormals( pMesh, NULL );
    }
    else  // if no normals, just add a reference to the mesh for the mesh container
    {
        pMeshContainer->MeshData.pMesh = pMesh;
        pMeshContainer->MeshData.Type = D3DXMESHTYPE_MESH;

        pMesh->AddRef();
    }
        
    // allocate memory to contain the material information.  This sample uses
    //   the D3D9 materials and texture names instead of the EffectInstance style materials
    pMeshContainer->NumMaterials = max(1, NumMaterials);
    pMeshContainer->pMaterials = new D3DXMATERIAL[pMeshContainer->NumMaterials];
    pMeshContainer->ppTextures = new LPDIRECT3DTEXTURE9[pMeshContainer->NumMaterials];
    pMeshContainer->pAdjacency = new DWORD[NumFaces*3];
    if ((pMeshContainer->pAdjacency == NULL) || (pMeshContainer->pMaterials == NULL))
    {
        hr = E_OUTOFMEMORY;
        goto e_Exit;
    }

    memcpy(pMeshContainer->pAdjacency, pAdjacency, sizeof(DWORD) * NumFaces*3);
    memset(pMeshContainer->ppTextures, 0, sizeof(LPDIRECT3DTEXTURE9) * pMeshContainer->NumMaterials);

    // if materials provided, copy them
    if (NumMaterials > 0)            
    {
//.........这里部分代码省略.........
开发者ID:wenqvip,项目名称:MoonGame,代码行数:101,代码来源:MoonSkinmesh.cpp

示例12: CreateMeshContainer

//======================================================================
// <<<メッシュ コンテナ オブジェクトの割り当て要求の実装>>>
//	Name			 : [in] メッシュの名前
//	pMeshData		 : [in] メッシュデータ構造体へのポインタ
//	pMaterials		 : [in] メッシュに使うマテリアルの配列
//	pEffectInstances : [in] メッシュに使うエフェクトインスタンスの配列
//	NumMaterials	 : [in] マテリアル配列内のマテリアルの数
//	pAdjacency		 : [in] メッシュの隣接性配列
//	pSkinInfo		 : [in] スキンデータが見つかった場合のスキンメッシュオブジェクトへのポインタ
//	ppNewMeshContainer : [out, retval] 作成されたメッシュコンテナを返す
//======================================================================
HRESULT CAllocateHierarchy::CreateMeshContainer( LPCSTR Name, 
        CONST D3DXMESHDATA *pMeshData,
        CONST D3DXMATERIAL *pMaterials, 
        CONST D3DXEFFECTINSTANCE *pEffectInstances, 
        DWORD NumMaterials, 
        CONST DWORD *pAdjacency, 
        LPD3DXSKININFO pSkinInfo, 
        LPD3DXMESHCONTAINER *ppNewMeshContainer) 
{
	HRESULT hr = S_OK;

	*ppNewMeshContainer = NULL;

	// patch meshes を扱う事はできない
	if( pMeshData->Type != D3DXMESHTYPE_MESH )
	{
		return E_FAIL;
	}

	LPD3DXMESH pMesh = pMeshData->pMesh;

	// FVF で記述されたメッシュ以外は読めぬ
	if( pMesh->GetFVF() == 0 )
	{
		return E_FAIL;
	}

	UINT NumFaces = pMesh->GetNumFaces();

	// メッシュ作成
	CXMesh *pCXMesh	= NULL;
	
	try
	{
		pCXMesh = new CXMesh;
	}
	
	catch ( std::bad_alloc& )
	{
		// メモリが足りない
		return E_OUTOFMEMORY;
	}

	// 名前設定
	pCXMesh->SetName( Name );

	// メッシュタイプ設定
	pCXMesh->MeshData.Type = D3DXMESHTYPE_MESH;

	LPDIRECT3DDEVICE9 pD3DDevice = NULL;

	// デバイスを取得
	if( FAILED( pMesh->GetDevice( &pD3DDevice ) ) )
	{
		hr = E_FAIL;
		goto e_Exit;
	}

	// Xファイルに法線が無かったら計算で求める
	if( !( pMesh->GetFVF() & D3DFVF_NORMAL ) )
	{
		////FVFに法線を追加した新しいメッシュにする////
        hr = pMesh->CloneMeshFVF( pMesh->GetOptions(), 
                                  pMesh->GetFVF() | D3DFVF_NORMAL, 
                                  pD3DDevice, &pCXMesh->MeshData.pMesh );

        if( FAILED( hr ) )
		{
			goto e_Exit;
		}

		// 引数で渡されたメッシュへのポインタに新しいメッシュへのポインタをセット
		// pMeshへの参照はこの時点で存在しないので、ここではreleaseをかけない
		pMesh = pCXMesh->MeshData.pMesh;

		D3DXComputeNormals( pMesh, NULL );
	}
	
	// 法線があった
	else
	{
		// リファレンスを増やすだけ
		pCXMesh->MeshData.pMesh = pMesh;
		pMesh->AddRef();
	}

	// マテリアル用のメモリを確保
	pCXMesh->NumMaterials = max( 1, NumMaterials );

//.........这里部分代码省略.........
开发者ID:Taka03,项目名称:Procon2007,代码行数:101,代码来源:CAllocateHierarchy.cpp

示例13: ConstruirSombra

void Sombra::ConstruirSombra(LPD3DXMESH pMesh, D3DXVECTOR3 vLight)
{
    // Note: the MeshVertex format depends on the FVF of the mesh
	struct MeshVertex { D3DXVECTOR3 p, n;
                            DWORD diffuse;
                         float tu,tv;   };

    MeshVertex *pVertices;
    WORD       *pIndices;

    // Lock the geometry buffers
    pMesh->LockVertexBuffer( 0L, (LPVOID*)&pVertices );
    pMesh->LockIndexBuffer( 0L, (LPVOID*)&pIndices );
    DWORD dwNumFaces    = pMesh->GetNumFaces();

    // Allocate a temporary edge list
    WORD *pEdges = new WORD[dwNumFaces*6];

    if( pEdges == NULL )
    {
        pMesh->UnlockVertexBuffer();
        pMesh->UnlockIndexBuffer();
        return ;
    }
	
    DWORD dwNumEdges = 0;

    // For each face
    for( DWORD i = 0; i < dwNumFaces; ++i )
    {
        WORD wFace0 = pIndices[3*i+0];
        WORD wFace1 = pIndices[3*i+1];
        WORD wFace2 = pIndices[3*i+2];

        D3DXVECTOR3 v0 = pVertices[wFace0].p;
        D3DXVECTOR3 v1 = pVertices[wFace1].p;
        D3DXVECTOR3 v2 = pVertices[wFace2].p;

        // Transform vertices or transform light?
        D3DXVECTOR3 vCross1(v2-v1);
        D3DXVECTOR3 vCross2(v1-v0);
        D3DXVECTOR3 vNormal;
        D3DXVec3Cross( &vNormal, &vCross1, &vCross2 );

        if( D3DXVec3Dot( &vNormal, &vLight ) >= 0.0f )
        {
            InsertarSegmento( pEdges, dwNumEdges, wFace0, wFace1 );
            InsertarSegmento( pEdges, dwNumEdges, wFace1, wFace2 );
            InsertarSegmento( pEdges, dwNumEdges, wFace2, wFace0 );
        }
    }

    // Se construyen las caras de la sombra extrudando los segmentos en la dirección
    // de la luz y una longitud 10 veces la del vector luz.
    for( i = 0; i < dwNumEdges; ++i )
    {
        D3DXVECTOR3 v1 = pVertices[pEdges[2*i+0]].p;
        D3DXVECTOR3 v2 = pVertices[pEdges[2*i+1]].p;
        D3DXVECTOR3 v3 = v1 - vLight/10;
        D3DXVECTOR3 v4 = v2 - vLight/10;

        // Add a quad (two triangles) to the vertex list
        m_pVertices[m_dwNumVertices++] = v1;
        m_pVertices[m_dwNumVertices++] = v2;
        m_pVertices[m_dwNumVertices++] = v3;

        m_pVertices[m_dwNumVertices++] = v2;
        m_pVertices[m_dwNumVertices++] = v4;
        m_pVertices[m_dwNumVertices++] = v3;
    }

    // Delete the temporary edge list
    delete[] pEdges;

    // Unlock the geometry buffers
    pMesh->UnlockVertexBuffer();
    pMesh->UnlockIndexBuffer();

   
    
}
开发者ID:BackupTheBerlios,项目名称:visionrobot,代码行数:81,代码来源:Sombra.cpp

示例14: InitGeometry

//-----------------------------------------------------------------------------
// Name: InitGeometry()
// Desc: Load the mesh and build the material and texture arrays
//-----------------------------------------------------------------------------
HRESULT InitGeometry()
{
	LPD3DXBUFFER pD3DXMtrlBuffer;
	LPDIRECT3DVERTEXBUFFER9 pMeshSourceVB;
	LPDIRECT3DINDEXBUFFER9  pMeshSourceIB;
	D3DVERTEX*              pSrc;
	D3DVERTEX*              pDst;


	// load the textures we are going to be using
	if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, L"cartoonpallet-white-to-black.bmp", &g_pTexture ) ) )
		MessageBox(NULL, L"Texture Load Problem", NULL, NULL);

	if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, L"cartoonpallet-black-to-white.bmp", &g_pTexture2 ) ) )
		MessageBox(NULL, L"Texture Load Problem", NULL, NULL);

	if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, L"marble.bmp",	&marbleTexture ) ) )
		MessageBox(NULL, L"Texture Load Problem", NULL, NULL);

	if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, L"background.jpg",	&backgroundTexture ) ) )
		MessageBox(NULL, L"Texture Load Problem", NULL, NULL);



	// Load the mesh from the specified file
	if( FAILED( D3DXLoadMeshFromX( L"skull.x", D3DXMESH_SYSTEMMEM, 
		g_pd3dDevice, NULL, 
		&pD3DXMtrlBuffer, NULL, &g_dwNumMaterials, 
		&g_pMesh ) ) )

		g_pd3dDevice->SetFVF(D3DFVF_D3DVERTEX );
	g_dwNumVertices  = g_pMesh->GetNumVertices();
	g_dwNumFaces     = g_pMesh->GetNumFaces();

	//Clone the mesh to set the FVF
	LPD3DXMESH pTempSysMemMesh = NULL;

	if( FAILED( g_pMesh->CloneMeshFVF( D3DXMESH_SYSTEMMEM, D3DFVF_D3DVERTEX,
		g_pd3dDevice, &pTempSysMemMesh ) ) )
		MessageBox(NULL,L"Mesh clone problem",NULL,NULL);
	g_pMesh->Release();


	g_pMesh = pTempSysMemMesh;

	//Compute normals in case the meshes have them
	if( g_pMesh )
		D3DXComputeNormals( g_pMesh, NULL );


	//Meshes cloned 

	if( FAILED(g_pd3dDevice->CreateVertexBuffer( g_dwNumVertices * sizeof(D3DVERTEX),
		D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED,
		&g_pMeshVB, NULL )))
		MessageBox(NULL,L"Vertex buffer create problem",NULL,NULL);

	if( FAILED(g_pd3dDevice->CreateIndexBuffer( g_dwNumFaces * 3 * sizeof(WORD),
		D3DUSAGE_WRITEONLY,
		D3DFMT_INDEX16, D3DPOOL_MANAGED,
		&g_pMeshIB, NULL )))
		MessageBox(NULL,L"Index buffer create problem",NULL,NULL);
	g_pMesh->GetVertexBuffer(&pMeshSourceVB);
	g_pMeshVB->Lock( 0, 0, (void**)&pDst, 0 );
	pMeshSourceVB->Lock( 0, 0, (void**)&pSrc, 0 );
	memcpy( pDst, pSrc, g_dwNumVertices * sizeof(D3DVERTEX) );
	g_pMeshVB->Unlock();
	pMeshSourceVB->Unlock();
	pMeshSourceVB->Release();

	g_pMesh->GetIndexBuffer(&pMeshSourceIB);
	g_pMeshIB->Lock( 0, 0, (void**)&pDst, 0 );
	pMeshSourceIB->Lock( 0, 0, (void**)&pSrc, 0 );
	memcpy( pDst, pSrc, g_dwNumFaces * 3 * sizeof(WORD));
	g_pMeshIB->Unlock();
	pMeshSourceIB->Unlock();
	pMeshSourceIB->Release();



	//// Done with the material buffer
	pD3DXMtrlBuffer->Release();

	return S_OK;
}
开发者ID:dimivogi,项目名称:MSC.skullShaders,代码行数:89,代码来源:ACW1.cpp

示例15: DeallocateGeometry

//------------------------------------------------------------------------------------------------
// Name:  XMesh
// Desc:  Constructs the subset geometry for a D3DXMesh
//------------------------------------------------------------------------------------------------
bool XMesh::buildGeometryFromD3DXMesh(LPD3DXMESH d3dxMesh, SubsetGeometry* subsetGeometry, DWORD subsets)
{
    // Check parameters
    if (APP_ERROR(!d3dxMesh || !subsetGeometry)("Invalid parameter to XMesh::buildGeometryFromD3DXMesh"))
        return false;

    // Add a reference to the mesh to counteract freeing it at the end
    d3dxMesh->AddRef();

    // Get the device
    LPDIRECT3DDEVICE9 pd3dDevice = NULL;
    d3dxMesh->GetDevice(&pd3dDevice);

    // If this mesh isn't already in the correct format, have D3D do the grunt work of
    // converting it.
    bool generate_normals = false; // Whether or not normals need to be generated for this mesh
    if ((d3dxMesh->GetFVF() != D3DFVF_GEOMETRYVERTEX) ||
        (D3DFMT_GEOMETRYINDEX == D3DFMT_INDEX32) && ((d3dxMesh->GetOptions() & D3DXMESH_32BIT) == 0))
    {
        // Holds the mesh when its converted to the correct format
        LPD3DXMESH pTemd3dxMesh = NULL;

        // Duplicate the loaded mesh into the format
        if (APP_ERROR(d3dxMesh->CloneMeshFVF(
                            D3DXMESH_SYSTEMMEM | ((D3DFMT_GEOMETRYINDEX == D3DFMT_INDEX32) ? D3DXMESH_32BIT : 0),
                            D3DFVF_GEOMETRYVERTEX, pd3dDevice, &pTemd3dxMesh))
                     ("XMesh couldn't convert the source geometry format")) {
            d3dxMesh->Release();
            pd3dDevice->Release();
			      return false;
        }

        // Generate normals if they didn't exist
        generate_normals = ((d3dxMesh->GetFVF()&D3DFVF_NORMAL)!=D3DFVF_NORMAL &&
                            (D3DFMT_GEOMETRYINDEX&D3DFVF_NORMAL)!=D3DFVF_NORMAL);

        // Use this mesh instead
        d3dxMesh->Release();
        d3dxMesh = pTemd3dxMesh;
    }

    // The mesh must have its attributes sorted before it can be converted to single strips
    {
        // Allocate an adjacency buffer
        DWORD faces = d3dxMesh->GetNumFaces();
        DWORD* pAdjacency = new DWORD[faces * 3];
		    bool failed = false;

        if (APP_ERROR(FAILED(d3dxMesh->GenerateAdjacency(ADJACENCY_EPSILON, pAdjacency)))("Unable to generate the mesh adjacency"))
          failed = true;

        { // Clean up "bowties" in the mesh that prevent lighting from being calculated correctly
          LPD3DXMESH cleaned_mesh = NULL;
          DWORD* cleaned_adjacency = new DWORD[faces * 3];
          LPD3DXBUFFER errors_and_warnings = NULL;
          if (!failed && APP_ERROR(FAILED(D3DXCleanMesh(D3DXCLEAN_BOWTIES,
                                                        d3dxMesh,
                                                        pAdjacency,
                                                        &cleaned_mesh,
                                                        cleaned_adjacency,
                                                        &errors_and_warnings)))
                                  ("Failed to clean mesh")) {
            failed = true;
            if (errors_and_warnings) {
              DEBUG_ERROR("Mesh cleaning error:  %s", (const char*)errors_and_warnings->GetBufferPointer());
            }
          }

          SAFE_RELEASE(errors_and_warnings);

          // If we successfully cleaned the mesh, use the new mesh and new set of
          // adjacencies.  Otherwise, just delete anything that was allocated and
          // keep the original.
          if (failed) {
            SAFE_DELETE_ARRAY(cleaned_adjacency);
            SAFE_RELEASE(cleaned_mesh);
          } else {
            SAFE_DELETE_ARRAY(pAdjacency);
            SAFE_RELEASE(d3dxMesh)
            pAdjacency = cleaned_adjacency;
            d3dxMesh = cleaned_mesh;
          }
        }

        // Compute mesh normals, if necessary
        if (!failed && generate_normals && APP_ERROR(FAILED(D3DXComputeNormals(d3dxMesh, pAdjacency)))("Couldn't generate mesh normals")) {
          failed = true;
        }

        // Optimize the mesh
        if (!failed && APP_ERROR(FAILED(d3dxMesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT,
                                                                  pAdjacency,
                                                                  NULL,
                                                                  NULL,
                                                                  NULL)))
                                 ("Couldn't optimize mesh attributes")) {
//.........这里部分代码省略.........
开发者ID:karlgluck,项目名称:Evidyon,代码行数:101,代码来源:xmesh.cpp


注:本文中的LPD3DXMESH::GetNumFaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。