- int m_nFrameWidth=64;
- int m_nFrameHeight=64;
- int m_nTextureWidth=1024;
- int m_nTextureHeight=1024;
- int m_nNumFrameColumns=5;
- int m_nNumFrameRows=10;
- int m_nCurrentColumn=RAND_RANGE(0,4); // -> x Zufallszahl zwischen 0 und 4
- int m_nCurrentRow=rownumber; // ->y
- int m_nOffsetX=0;
- int m_nOffsetY=0;
- // If the frames of animation don't fill up the whole texture, you'll need
- // to find the sub-range within the standard texture range (0.0 to 1.0)
- // that the frames do exist within.
- float fSubRange_s = (1.0f / m_nTextureWidth ) *(m_nFrameWidth * m_nNumFrameColumns);
- float fSubRange_t = (1.0f / m_nTextureHeight) *(m_nFrameHeight * m_nNumFrameRows);
- // No convert the Width and Height of a frame into texture values...
- float fFrame_s = fSubRange_s / m_nNumFrameColumns;
- float fFrame_t = fSubRange_t / m_nNumFrameRows;
- // Now, calculate the new s/t texture values for the four corners
- // of the quad based on the current column and row of the animation
- float fLowerLeft_s = m_nCurrentColumn * fFrame_s;
- float fLowerLeft_t = 1.0f - (m_nCurrentRow * fFrame_t) - fFrame_t;
- float fLowerRight_s = (m_nCurrentColumn * fFrame_s) + fFrame_s;
- float fLowerRight_t = 1.0f - (m_nCurrentRow * fFrame_t) - fFrame_t;
- float fUpperRight_s = (m_nCurrentColumn * fFrame_s) + fFrame_s;
- float fUpperRight_t = 1.0f - (m_nCurrentRow * fFrame_t);
- float fUpperLeft_s = m_nCurrentColumn * fFrame_s;
- float fUpperLeft_t = 1.0f - (m_nCurrentRow * fFrame_t);