void DrawTorus(float r, float R, int nsides, int rings) { int i, j; float theta, phi, theta1, phi1; Indices.clear(); Vertices.clear(); for (i = 0; i < rings; i++) { theta = (float) i * 2.0f * M_PI / rings; theta1 = (float) (i + 1) * 2.0f * M_PI / rings; for (j = 0; j < nsides; j++) { phi = (float) j * 2.0f * M_PI / nsides; phi1 = (float) (j + 1) * 2.0f * M_PI / nsides; XMFLOAT3 p0 = XMFLOAT3(cos(theta) * (R + r * cos(phi)), // x -sin(theta) * (R + r * cos(phi)), // y r * sin(phi)); // z XMFLOAT3 p1 = XMFLOAT3(cos(theta1) * (R + r * cos(phi)), // x -sin(theta1) * (R + r * cos(phi)), // y r * sin(phi)); // z XMFLOAT3 p2 = XMFLOAT3(cos(theta1) * (R + r * cos(phi1)), // x -sin(theta1) * (R + r * cos(phi1)),// y r * sin(phi1)); // z XMFLOAT3 p3 = XMFLOAT3(cos(theta) * (R + r * cos(phi1)), // x -sin(theta) * (R + r * cos(phi1)), // y r * sin(phi1)); // z // Add XMFLOAT4 color = (ConwayGame.GetCellState(i, j)) ? XMFLOAT4(CELL_ALIVE_COLOR) : ((j + i)&1) ? XMFLOAT4(CELL_DEATH_COLOR) : XMFLOAT4(CELL_DEATH_COLOR2); AddQuad(p0, p1, p2, p3, color); } } }