If I want to simulate fire flames rising should I animate the UV?
There is no one and only way to simulate something. It depends how YOU want to do it.
I tried to use the code provided by "belfegor" but can't get it to work.
What have you tried and failed? Show some code, don't just say "i can't get it to work". How do you expect someone to help you with no relative information?
Put this somewhere at "init time"
const int framesCnt = 16;
const float uvOffset = 1.0f / (float)framesCnt;
D3DXVECTOR2 billUV[4];
billUV[0].x = 0; // top left
billUV[1].x = 0; // bottom left
billUV[2].x = uvOffset; // top right
billUV[3].x = uvOffset; // bottom right
billUV[0].y = 0; // top left
billUV[1].y = 1; // bottom left
billUV[2].y = 1; // bottom right
billUV[3].y = 0; // top right
Do this every frame, might be where you update your vertices
static float time = 0.0f;
const float animSpeed = 1.0f / 30.0f; // 30 frames per second
time += deltaTime;
if( time > animSpeed)
{
time = 0.0f;
billUV[0].x += uvOffset;
billUV[1].x += uvOffset;
billUV[2].x += uvOffset;
billUV[3].x += uvOffset;
if( billUV[3].x > 1.0f ) // reset to beginning
{
billUV[0].x = 0; // top left
billUV[1].x = 0; // bottom left
billUV[2].x = uvOffset; // top right
billUV[3].x = uvOffset; // bottom right
}
}
Then set to your vertices
vertices[j*4+0] = CUSTOM_VERTEX(pos, color, billUV[0].x, billUV[0].y);
vertices[j*4+1] = CUSTOM_VERTEX(pos, color, billUV[1].x, billUV[1].y);
vertices[j*4+2] = CUSTOM_VERTEX(pos, color, billUV[2].x, billUV[2].y);
vertices[j*4+3] = CUSTOM_VERTEX(pos, color, billUV[3].x, billUV[3].y);
Look for example texture in attachment.