## Animations generated in R version 2.15.0 (2012-03-30) using the package animation
library(animation)
par(mfrow = c(1, species.number))
for (i in 1:ani.options("nmax")) {
    for (orgs in 1:species.number) {
        z <- pop.grid[, , i, orgs]
        x <- 10 * (1:nrow(z))
        y <- 10 * (1:ncol(z))
        z0 <- min(z) - 20
        z <- rbind(z0, cbind(z0, z, z0), z0)
        x <- c(min(x) - 1e-10, x, max(x) + 1e-10)
        y <- c(min(y) - 1e-10, y, max(y) + 1e-10)
        fill <- matrix("green3", nr = nrow(z) - 1, nc = ncol(z) - 
            1)
        fill[, i2 <- c(1, ncol(fill))] <- "gray"
        fill[i1 <- c(1, nrow(fill)), ] <- "gray"
        fcol <- fill
        zi <- pop.grid[-1, -1, i, orgs] + pop.grid[-1, -grid.size, 
            i, orgs] + pop.grid[-grid.size, -1, i, orgs] + 
            pop.grid[-grid.size, -grid.size, i, orgs]
        fcol[-i1, -i2] <- terrain.colors(20)[cut(zi, c(0, 
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 
            35, 40, 50, 80, 150, 300), include.lowest = TRUE)]
        par(mar = rep(0.5, 4))
        persp(x, y, z, theta = 0, phi = 40, col = fcol, scale = FALSE, 
            ltheta = -120, shade = 0.4, border = NA, box = FALSE)
        title(main = c("\n\nOrganism Surface", paste("\n\n\n\n\nTrophic Level", 
            orgs)), sub = species.number, cex.main = 2, font.main = 4, 
            col.main = orgs)
    }
    ani.pause()
}
## R version 2.15.0 (2012-03-30)
## Platform: x86_64-pc-mingw32/x64 (64-bit)
## Other packages: animation 2.0-6