rendered paste bodyDrawer::Drawer(float fScreenMaxX,float fScreenMaxY,float fScreenMinX,float fScreenMinY,int iScreenX,
int iScreenY,int iCenterX,int iCenterY)
{
fMinX = fScreenMinX;
fMinY = fScreenMinY;
fHeight = fScreenMaxY - fScreenMinY;
fWidth = fScreenMaxX - fScreenMinX;
fDistX = fWidth/iScreenX;
fDistY = fHeight/iScreenY;
iScreenHeight = iScreenX;
iScreenWidth = iScreenY;
iOriginX = iCenterX;
iOriginY = iCenterX;
fRadian = 3.14159265f / 180.0f;
}
float Drawer::Wrangle(float fX, float fY,float fT)
{
fX *= 100*fRadian;
fY *= 100*fRadian;
fT *= 5*fRadian;
float fDistance = sqrt(fX*fX + fY*fY);
float fCircular = cos( fDistance-fT)*0.025;
float fDamp = fDistance*0.025;
if(fDamp < 0.5f)
fDamp = 0.5f;
//float fWave = cos(fX+fT)/40.0f;
return fCircular/(fDamp);
}
void Drawer::Draw(float iT)
{
int i = 0;
glColor3f(0.0f,0.0f,1.0f);
float iScale = 64./iScreenWidth;
float jScale = 64./iScreenHeight;
static std::vector<float> grid;
grid.resize(iScreenHeight * iScreenWidth);
for (int i = 0; i < iScreenHeight; ++i)
for (int j = 0; j < iScreenWidth; ++j)
grid[i * iScreenWidth + j] = Wrangle(i*iScale - iOriginX, j*jScale - iOriginY, iT);
static std::vector<float> vertices((iScreenHeight - 1) * iScreenWidth * 6);
static std::vector<float> colors((iScreenHeight - 1) * iScreenWidth * 6);
while(i < iScreenHeight - 1)
{
float fResult[2];
int j = 0;
while(j < iScreenWidth) {
fResult[0] = grid[(i + 1) * iScreenWidth + j];
fResult[1] = grid[i * iScreenWidth + j];
int index = (i*iScreenWidth+j)*6;
colors[index + 2] = 0.75 - fResult[0]*10;
colors[index + 5] = 0.75 - fResult[1]*10;
float fX = fMinX + i*fDistX;
float fY = fMinY + j*fDistY;
vertices[index] = fX + fDistX;
vertices[index+1] = fY;
vertices[index+2] = fResult[0];
vertices[index+3] = fX;
vertices[index+4] = fY;
vertices[index+5] = fResult[1];
j++;
}
i++;
}
glVertexPointer(3, GL_FLOAT, 0, &vertices[0]);
glColorPointer(3, GL_FLOAT, 0, &colors[0]);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
for (int i = 0; i < iScreenHeight-1; ++i)
glDrawArrays(GL_TRIANGLE_STRIP, iScreenWidth*i*2, iScreenWidth*2);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}