void HlModel::SetTextures( SgNode *pNode, BtU32 index, RsTexture *pTexture )
{
	// Cache the materials
	SgMaterial* pMaterials = pNode->pMaterial();

	// Cache the number of materials
	BtU32 numMaterials = pMaterials->NumMaterials();

	for( BtU32 i=0; i<numMaterials; i++)
	{
		// Cache the material
		RsMaterial* pMaterial = pMaterials->GetMaterial( i );

		// Set the texture
		pMaterial->SetTexture( index, pTexture );
	}
	
	// Cache the first child
	SgNode* pChild = pNode->pFirstChild();

	// Loop through the children
	while( pChild != BtNull )
	{
		// Set the materials
		SetTextures( pChild, index, pTexture );

		// Move to the next child
		pChild = pChild->pNextSibling();
	}
}
void HlModel::SetSortOrders( SgNode *pNode, BtU32 sortOrder )
{
	if( pNode->HasMaterials() )
	{
		SgMaterial* pMaterials = pNode->pMaterial();

		// Cache the number of materials
		BtU32 numMaterials = pMaterials->NumMaterials();

		for( BtU32 i=0; i<numMaterials; i++)
		{
			// Cache the material
			RsMaterial* pMaterial = pMaterials->GetMaterial( i );

			// Set the sort order
			pMaterial->SetSortOrder( sortOrder );

			// Set the material
			pMaterials->SetMaterial( i, pMaterial );
		}
	}

	// Cache the first child
	SgNode* pChild = pNode->pFirstChild();

	// Loop through the children
	while( pChild != BtNull )
	{
		// Set the materials
		SetSortOrders( pChild, sortOrder );

		// Move to the next child
		pChild = pChild->pNextSibling();
	}
}
void HlModel::SetMaterialTechnique( SgNode *pNode, const BtChar *technique )
{
	if( pNode->GetMesh() )
	{
		// Cache the materials
		SgMaterial* pMaterials = pNode->pMaterial();

		// Cache the number of materials
		BtU32 numMaterials = pMaterials->NumMaterials();

		for( BtU32 i=0; i<numMaterials; i++)
		{
			// Cache the material
			RsMaterial* pMaterial = pMaterials->GetMaterial( i )->GetDuplicate();

			// Cache the current technique name
			BtChar *currentTechniqueName = pMaterial->GetTechniqueName();
			(void)currentTechniqueName;

			// Set the technique name
			pMaterial->SetTechniqueName( technique );

			// Set the material
			pMaterials->SetMaterial( i, pMaterial );
		}
	}

	// Cache the first child
	SgNode* pChild = pNode->pFirstChild();

	// Loop through the children
	while( pChild != BtNull )
	{
		// Set the materials
		SetMaterialTechnique( pChild, technique );

		// Move to the next child
		pChild = pChild->pNextSibling();
	}
}