Mon, 19 Feb 2007
Descending to the planet surface, where they will live.
« Planet Progress | Main | Onwards to Artificial Life » Posted by at 8:29 PM in Code
I've been very busy the last weeks with work and also coding up the new version of darwinathome. I've been busy figuring out how to work with triangle strips, and now that i've got that worked out, the performance of the planet view is nice. The number of OpenGL vertices drops to just over a third.
The program now starts with the globe, which is terraformed using the random number generator. That's funny enough in itself that it requires me to quote here the function that actually does the work. Enjoy..
public void terraform() {
admitVisitor(Patch.getPopulator());
admitVisitor(new Sphere.Visitor() {
public void visit(Vertex vertex) {
vertex.getOccupant().buildTriangles();
}
} );
admitVisitor(new Sphere.Visitor() {
public void visit(Vertex vertex) {
vertex.getOccupant().getAverage();
}
} );
admitVisitor(new Sphere.Visitor() {
public void visit(Vertex vertex) {
vertex.getOccupant().setToAverage();
}
} );
admitVisitor(new Sphere.Visitor() {
public void visit(Vertex vertex) {
vertex.getOccupant().sharpen();
}
} );
}
Then when i click on a spot, it automatically and very promptly zooms me in to the surface. For that i'm using a combination of two distances that get varied according to a sine wave: the distance to the planet center, and the distance to the thing you're looking at. Anyway, i end up on the surface, with a new seed structure created there. This is just a test version.
Then my son came in and i remembered how he would test the program so i started clicking madly and creating many hundreds of seed structures. To my surprise, it took quite a few before the performance noticeably degraded. This indicates to me that i'll be able to get quite a few critters in view when they finally interact. That's exactly what i'm working on now. Senses.
These creatures are actually denizens of a spherical universe where their feet hit the ground when x2 + y2 + z2 is equal to a number, and gravity pulls towards the middle of the sphere. I've always imagined building something like that but this is the first time i've actually done it.