Beispiel #1
0
//-----------------------------------------------------------------------------
void mglGraph::Cloud(const mglData &a, const char *sch, mreal alpha)
{
	if(a.nx<2 || a.ny<2 || a.nz<2)
	{	SetWarn(mglWarnLow,"CloudQ");	return;	}
	mglData x(a.nx), y(a.ny),z(a.nz);
	x.Fill(Min.x,Max.x);
	y.Fill(Min.y,Max.y);
	z.Fill(Min.z,Max.z);
	Cloud(x,y,z,a,sch,alpha);
}
Beispiel #2
0
Model::Model() {
    this->screenWidth  = 0.7 * glutGet(GLUT_SCREEN_WIDTH);
    this->screenHeight = 0.7 * glutGet(GLUT_SCREEN_HEIGHT);

    // Crea il sole
    this->sun = new Sun();
    this->sun->circles.push_back(Sun::Circle(
                                     Vertex2d(this->screenWidth * 0.15f, this->screenHeight * 0.8f),
                                     55, 2, 1, RGBColor(1.0, 0.9, 0.0, 0.3)
                                 ));
    this->sun->circles.push_back(Sun::Circle(
                                     Vertex2d(this->screenWidth * 0.15f, this->screenHeight * 0.8f),
                                     45, 2, 0, RGBColor(1.0, 0.95, 0.0, 0.9)
                                 ));
    this->sun->circles.push_back(Sun::Circle(
                                     Vertex2d(this->screenWidth * 0.15f, this->screenHeight * 0.8f),
                                     40, 0, 0, RGBColor(1.0, 1.0, 0.0, 1.0)
                                 ));

    // Crea le nuvole
    for (int i=0; i<8; i++) {
        int circles = rand() % 3 + 3;
        this->clouds.push_back(Cloud(
                                   Vertex2d(0, this->screenHeight * (rand() % 30 + 60) / 100.0f),
                                   RGBColor(0.9, 0.9, 0.9, 1.0),
                                   1.0f * circles, 0.5f * circles * circles * circles, 0,
                                   (rand() % 10) * 3 / 10.0f + 3
                               ));
    }

    // Crea il pavimento
    this->floor = new Floor(this->screenWidth, 2 * this->screenHeight / 5);

    this->tree = new Tree(
        Vertex2d(this->screenWidth / 2.0f, this->screenHeight / 15.0f),
        0,
        this->screenHeight * 3 / 10.0, this->screenWidth / 80.0,
        5, this->floor, false
    );
    this->shrub1 = new Tree(
        Vertex2d(this->screenWidth / 2.0f, this->tree->position.y + this->tree->logHeight),
        M_PI / 8,
        this->tree->logHeight / 2.0, this->tree->logWidth / 2,
        3, this->floor, true
    );
    this->shrub2 = new Tree(
        Vertex2d(this->screenWidth / 2.0f, this->tree->position.y + this->tree->logHeight),
        -M_PI / 8,
        this->tree->logHeight / 2.0f, this->tree->logWidth / 2.0,
        3, this->floor, true
    );

    // Aggiunge la neve
    for (int i=0; i<this->snow.SNOW_FLAKES; i++) {
        this->snow.flakes.push_back(Snowflake());
        this->snow.flakes.back().position.y = rand() % screenHeight + screenHeight + 2;
        this->snow.flakes.back().weight = (rand() % 100) / 100.0f + 2.0f;
        this->snow.flakes.back().startX = rand() % screenWidth;
        this->snow.flakes.back().lastZ = rand() % (int)(this->floor->height / 2 - this->snow.flakes.back().weight) / 1.0f + this->snow.flakes.back().weight;
    }
}