Original Post
Ok Im trying to make all the tiles in my game that have a moving water texture on them animate by adjusting the texture coords accordingly. I basically just have been guessing and playing around with the numbers, and I just can''t seem to get it to look right (its gets distorted as the coords are moved.
Here is the code as it currently stands:
Is this right( not the other stuff, just the panning part, I know I should optimize the tile drawing as well, but thats beside the point).
-Etnu.
void CMap::Draw(LPDIRECT3DDEVICE7 pD3DDevice,float fTimeKey)
{
for(int i3 = 0; i3 < TEXTURES; i3++)
{
pD3DDevice->SetTexture(0,m_ppTex[i3]);
for(int i = 0; i < m_XCount; i++)
{
for(int i2 = 0; i2 < m_ZCount; i2++)
{
int t = m_MapTiles<i>[i2]->Tex;
if( t == i3)
{
D3DXMATRIX mat = m_MapTiles[i][i2]->matPos;
pD3DDevice->SetTransform( D3DTRANSFORMSTATE_WORLD,(D3DMATRIX *)mat);
if(i3 == WATER)
{
for(int v = 0; v < 4; v++)
{
m_MapTiles[i][i2]->Verts[v].tv += fTimeKey;
if(m_MapTiles[i][i2]->Verts[v].tv > 1.0f)
m_MapTiles[i][i2]->Verts[v].tv = 0.0;
}
}
pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,m_MapTiles[i][i2]->Verts,4,0);
}
}
}
}
}
|