Ejemplo n.º 1
0
//Generate the rocks
void RockGenerator::generate(const GroundPlane& ground) {
    int size = GroundPlane::GROUND_SCALE / ROCK_SIZE;
    int groundSize = GroundPlane::GROUND_SCALE / 2;

    for (int row = 0; row < size; row++) {
        for (int col = 0; col < size; col++) {
            if (rand() % ROCK_INVERSE_DENSITY == 0) {
                float scale = (rand() % (int)(ROCK_SCALE_MAX - ROCK_SCALE_MIN) + ROCK_SCALE_MIN)  / 100.0f;
                float x = row * ROCK_SIZE - groundSize + rand() % ROCK_SIZE;
                float y = col * ROCK_SIZE - groundSize + rand() % ROCK_SIZE;
                float angle = rand() % 360;

                auto density = makeDensity();
                rocks.push_back(Rock(draw_template_.mesh, glm::vec3(x, 0.0f, y), angle, ground, scale, density));
                density_levels.push_back(density);
            }
        }
    }
}
Ejemplo n.º 2
0
void initialize()
{
	Shader makeDensity("defaultVS.vs", "densityField.fs");

	QuadVao = CreateQuad();
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	velocity = createPingPongTexture(WIDTH, HEIGHT, 2);
	density = createPingPongTexture(WIDTH, HEIGHT, 1); 
	pressure = createPingPongTexture(WIDTH, HEIGHT, 2);

	divergence = createSurface(WIDTH, HEIGHT, 3);
	obstacle = createSurface(WIDTH, HEIGHT, 3);
	gravity = createSurface(WIDTH, HEIGHT, 2);

	//createGravityField();
	initDensity(makeDensity);

	createObstacles(obstacle, WIDTH, HEIGHT);
	ResetState();
}