I'm trying to replace the content of a texture (statically applied to the material using a 3d model tool) with the content of a bitmap, using the following code:
Code: Select all
IAnimatedMesh mesh = m_Device.SceneManager.GetMesh(@"Card.x");
m_FullCardMeshNode = m_Device.SceneManager.AddAnimatedMeshSceneNode(mesh, null, -1);
m_FullCardMeshNode.AnimationSpeed = 0;
m_FullCardTextureFront = m_FullCardMeshNode.GetMaterial(0).Texture1;
// Get card bitmap pixels
System.Drawing.Imaging.BitmapData bmpdata = m_FullCardBitmap.LockBits(
new Rectangle(0, 0, m_FullCardBitmap.Width, m_FullCardBitmap.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly, m_FullCardBitmap.PixelFormat);
uint* pNewData = (uint*)bmpdata.Scan0.ToPointer();
// Get card texture pixels
uint* pOldData = (uint*)m_FullCardTextureFront.Lock();
try
{
// Copy bitmap into texture
for(int i = 0; i < m_FullCardBitmap.Width * m_FullCardBitmap.Height; i++)
{
*pOldData = *pNewData;
pNewData++;
pOldData++;
}
}
finally
{
m_FullCardTextureFront.Unlock();
m_FullCardBitmap.UnlockBits(bmpdata);
}
The problem is that if I zoom away from my model, the new image disappear and the old image comes back on the texture. I think that my function replaces the largest bitmap of the texture, but the other smallest images (mipmaps) remains the same.
Do anyone know how I can replace all mipmaps or how I can tell to engine to do this for me?
Thanks!