Sign in to follow this  
EvilProject

Mesh rendering problem

Recommended Posts

hi, im trying to render a skinned mesh and for some reson it doenst show up. this is the Render function of the mesh , thanks for all helpers :P
void CAnimatedMesh::Render()
{
	if(!m_bLoaded)
		return;
	void *pSource,*pDest;
	if(m_bUpdated)
	{
		m_pRootFrame->UpdateHierarchy();
		for(DWORD i=0; i<m_pContainer->pSkinInfo->GetNumBones(); i++)
		{
			m_pContainer->pBoneMatrices[i] = (*m_pContainer->pSkinInfo->GetBoneOffsetMatrix(i));
			if(m_pContainer->ppFrameMatrices[i])
				m_pContainer->pBoneMatrices[i] *= (*m_pContainer->ppFrameMatrices[i]);
		}
		m_pContainer->pMesh->LockVertexBuffer(D3DLOCK_READONLY,(void**)&pSource);
		m_pContainer->pSecondaryMesh->LockVertexBuffer(0,(void**)&pDest);
		m_pContainer->pSkinInfo->UpdateSkinnedMesh(m_pContainer->pBoneMatrices,NULL,pSource,pDest);
		m_pContainer->pMesh->UnlockVertexBuffer();
		m_pContainer->pSecondaryMesh->UnlockVertexBuffer();
		m_bUpdated = false;
	}
	m_pD3DDevice->SetVertexShader(NULL);
	m_pD3DDevice->SetVertexDeclaration(NULL);
	for(DWORD i=0; i<m_pContainer->dwNumMaterials; i++)
	{
		if(m_pContainer->pMaterials[i].MatD3D.Diffuse.a !=1.0f)
		{
			m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
			m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
			m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_DESTCOLOR);
		}
		else
			m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);

		m_pD3DDevice->SetMaterial(&m_pContainer->pMaterials[i].MatD3D);
		m_pD3DDevice->SetTexture(0,m_pContainer->ppTextures[i]);
		m_pContainer->pSecondaryMesh->DrawSubset(i);
	}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this