void SrTerrain::calHeight(float* height)
{
	memset(height, 0, sizeof(float) * mParam.mNumCols * mParam.mNumRows);

	addPerlinNoise(height, mParam.mYSize);
	perturb(height, mParam.mF, mParam.mD);
	for (int i = 0; i < 10; i++ )
		erode(height, mParam.mErode);
	smoothen(height);
}
Exemplo n.º 2
0
static void
smoothen(struct state *st, int x, int lastx, int y, int lasty, int size, int last_color, XColor *colors, Display *dpy, Window window, GC bgc, int screen, struct info *info)
{
    double xdistance = abs((double)x-(double)lastx);
    double ydistance = abs((double)y-(double)lasty);
    double distance = sqrt(((xdistance * xdistance) + (ydistance * ydistance)) );
    double slope = (((double)y-(double)lasty) / ((double)x-(double)lastx));
    printf("Starting smoothen with values: %f, %f, %f, %f\n", xdistance, ydistance, distance, slope);
    if (distance > 2.0) {
        int newx = (int)((xdistance / distance) * slope);
        int newy = (int)((ydistance / distance) * slope);
        if (! st->info->trail) {
            XSetForeground(st->dpy, st->bgc, BlackPixel(st->dpy, st->screen));
            XFillArc(st->dpy, st->window, st->bgc, lastx, lasty, size, size, START_ARC, END_ARC);
        }
        XSetForeground(st->dpy, st->bgc, st->colors[last_color].pixel);
        XFillArc(st->dpy, st->window, st->bgc, newx, newy, size, size, START_ARC, END_ARC);
        smoothen(st, newx, x, newy, y, size, last_color, st->colors, st->dpy, st->window, st->bgc, st->screen, st->info);
    }
}
Exemplo n.º 3
0
    void render() {
        log("Begin rendering");
        printf("%d %d\n", width, height);
        if (width == 0 || rendered) {
            return;
        }
        buffer = std::vector<std::vector<Color> >(width, std::vector<Color>(height));
        int x, y;
#pragma omp parallel for default(shared) private(x, y) schedule(dynamic) collapse(2) num_threads(4)
        for (x = 0; x < width; ++x) {
            for (y = 0; y < height; ++y) {
                buffer[x][y] = scene.trace_ray(get_ray(x, y));
            }
        }
        enchance_balance();
        exit(0);
        smoothen();
        rendered = true;
        log("End rendering");
    }