Exemplo n.º 1
0
FSkyVertexBuffer::FSkyVertexBuffer()
{
	CreateDome();
	mVertexBuffer = screen->CreateVertexBuffer();

	static const FVertexBufferAttribute format[] = {
		{ 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FSkyVertex, x) },
		{ 0, VATTR_TEXCOORD, VFmt_Float2, (int)myoffsetof(FSkyVertex, u) },
		{ 0, VATTR_COLOR, VFmt_Byte4, (int)myoffsetof(FSkyVertex, color) }
	};
	mVertexBuffer->SetFormat(1, 3, sizeof(FSkyVertex), format);
	mVertexBuffer->SetData(mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], true);
}
Exemplo n.º 2
0
void Building::CreateTower() {
    x_dim = 10;
    z_dim = 8;
    top_height = 0;

    transform_group tower = share<Transform>();
    transform_group a = CreatePyramid(10, randomMaterial(), CUBE);
    tower->addChild(a);

    transform_group b = CreatePillarsVertical(5, randomMaterial(), CUBE);
    tower->addChild(b);

    transform_group c = CreatePyramid(8, randomMaterial(), CYLINDER);
    tower->addChild(c);

    transform_group d = CreateBlock(7, randomMaterial(), CYLINDER);
    tower->addChild(d);
    
    transform_group d1 = CreatePillarsHorizontal(randomMaterial(), CUBE);
    tower->addChild(d1);
    transform_group d2 = CreatePillarsHorizontal(randomMaterial(), CYLINDER);
    tower->addChild(d2);
    transform_group d3 = CreateBlock(2, randomMaterial(), CYLINDER);
    tower->addChild(d3);

    transform_group e = CreatePillarsVertical(3, randomMaterial(), CYLINDER);
    tower->addChild(e);

    transform_group f = CreatePyramid(4, randomMaterial(), CUBE);
    tower->addChild(f);

    transform_group g = CreateBlock(3, randomMaterial(), CUBE);
    tower->addChild(g);
    transform_group g1 = CreatePillarsHorizontal(randomMaterial(), CYLINDER);
    tower->addChild(g1);
    transform_group g2 = CreatePillarsHorizontal(randomMaterial(), CYLINDER);
    tower->addChild(g2);

    transform_group h = CreatePyramid(15, randomMaterial(), CYLINDER);
    tower->addChild(h);

    transform_group i = CreateBlock(2, randomMaterial(), CYLINDER);
    tower->addChild(i);

    transform_group j = CreateDome(randomMaterial());
    tower->addChild(j);
//    tower->translateLocal(0, 0, -50);
    world->addChild(tower);
}
Exemplo n.º 3
0
FSkyVertexBuffer::FSkyVertexBuffer()
{
	CreateDome();

	glBindVertexArray(vao_id);
	glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
	glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x);
	glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u);
	glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color);
	glEnableVertexAttribArray(VATTR_VERTEX);
	glEnableVertexAttribArray(VATTR_TEXCOORD);
	glEnableVertexAttribArray(VATTR_COLOR);
	glBindVertexArray(0);

}
Exemplo n.º 4
0
  SkyDome::SkyDome(PropertyList* plist) {
  
	int horiRes                 = plist->GetInt("resolution.horizontal");
	int vertRes                 = plist->GetInt("resolution.vertical");
	float texturePercentage     = plist->GetFloat("texture.percentage");
	float domePercentage        = plist->GetFloat("dome.percentage");
	float radius                = plist->GetFloat("dome.radius");
    Vector<3,float> center      = plist->GetVector<3,float>("dome.center");
    ITextureResourcePtr texture = ResourceManager<ITextureResource>::Create(plist->GetString("texture"));
    
    FaceSet* faces = CreateDome(horiRes, vertRes, texturePercentage, domePercentage, radius, center, texture);
    
    sceneNode = new DisableLightingNode();
    sceneNode->AddNode(new GeometryNode(faces));
    
  }
Exemplo n.º 5
0
/* creates a building with a base, center and a top 
 * the rules:
 * Bot can be type of {BLOCK, PILLARS_V PYRAMID} 1/10 of y_dim
 * Mid can be type of {BLOCK, PILLAR_V, PYRAMID, PILLAR_H} up to 4 middle piece spanning 7/10 of y_dim,
 *  (mid can have multiple mid pieces)
 * Top can be type of {BLOCK, ELLIPSE, PYRAMID} 2/10 of y_dim 
 *  (top may inrease the current x_dim and z_dim to create a lip of a roof)
 *
 * no PILLARS_V can immediately succede PILLARS_V
 * no PILLARS_V can immediately succede PILLARS_H
 * no BLOCK of shape CUBE can immediately succede PYRAMID of shape CYLINDER
 * no BLOCK of shape CUBE can immediately succede BLOCK of shape CYLINDER
 * no PILLAR_H can immediately succede PYRAMID
 * no PILLAR_H can immediately succede PILLAR_V
 * no PYRAMID of shape CUBE can immediately succede PYRAMID of shape CYLINDER
 * no PYRAMID of shape CUBE can immediately succede BLOCK of shape CYLINDER
 * no ELLIPSE can immediately succede PILLARS_H
 *
 * pieces of type of {BLOCK, PILLARS_V, PILLARS_H, PYRAMID} can be shape {CYLINDER, CUBE}
 * 
 *
 *
 * notes:
 * buildings are always built from the bottom up.
 * each Create call builds on top of the next pieces (or on the sides of with PILLARS_H)
 *  and modifies the dimensions of the building
 */
transform_group Building::CreateRandomBuilding() {
    transform_group building = share<Transform>();

    int bot_type = rand()%3;
    int bot_shape = rand()%2;
    float bot_height = y_dim/10;
    
    transform_group bot;
    if (bot_type == 0){ //BLOCK
        bot = CreateBlock(bot_height, randomMaterial(), bot_shape);
    }
    else if (bot_type == 1){ //PILLARS_V
        bot = CreatePillarsVertical(bot_height, randomMaterial(), bot_shape);

    }
    else if (bot_type == 2){ //PYRAMID
        int steps = (int)(bot_height/pyramid_step_height); //height to steps conversion, # of steps rounded down
        bot = CreatePyramid(steps, randomMaterial(), bot_shape);
    }
    building->addChild(bot);

    
    int mid_types[] = {BLOCK, PILLARS_V, PYRAMID, PILLARS_H,PILLARS_H,PILLARS_H,PILLARS_H};
    for (int i = 0, loop = rand()%6+4, remaining_mid_space = 7;
         i<loop && remaining_mid_space > 0;
         i++) {
        int mid_type = rand()%7;
        int mid_shape = rand()%2;
        if (!isValidPlacement(mid_types[mid_type], mid_types[mid_shape])) {
            --i; //repeat the iteration
            continue;
        }
        int how_many_tenths = rand() % remaining_mid_space + 1;;
        int mid_height = y_dim/10*how_many_tenths;
        if (i == loop-1)
            mid_height = y_dim/10*remaining_mid_space;
        
        transform_group mid;
        if (mid_type == 0){ //BLOCK
            mid = CreateBlock(mid_height, randomMaterial(), mid_shape);
        }
        else if (mid_type == 1){ //PILLARS_V
            mid = CreatePillarsVertical(mid_height, randomMaterial(), mid_shape);
            
        }
        else if (mid_type == 2){ //PYRAMID
            int steps = (int)(mid_height/pyramid_step_height); //height to steps conversion, # of steps rounded down
            if (mid_height-steps*pyramid_step_height < 1) {
                --i; //repeat the iteration
                continue;
            }
            mid = CreatePyramid(steps, randomMaterial(), mid_shape);
        }
        else if (mid_type >= 3){ //PILLARS_H
            if (i == loop-1) {
                --i; //repeat the iteration
                continue;
            }
            remaining_mid_space += how_many_tenths; // add the height chang b/c no height change
            mid = CreatePillarsHorizontal(randomMaterial(), mid_shape);
        }
        
        remaining_mid_space -= how_many_tenths;
        building->addChild(mid);
    }
    
    
    int top_type, top_shape;
    int top_types[4] = {BLOCK, ELLIPSE, PYRAMID};

    float top_height = 2*y_dim/10;
    do {
        top_type = rand()%3;
        top_shape = rand()%2;
        if (top_types[top_type] == ELLIPSE && prev_block_height < y_dim/20) // prevents thin domes
            continue;
    } while (!(isValidPlacement(top_types[top_type], top_shape) && top_types[top_type] != ELLIPSE) && // if valid non elipse
             !(isValidPlacement(top_types[top_type], top_shape) && top_types[top_type] == ELLIPSE && prev_block_height > y_dim/20)); // if valid elipse with heigh >= 1/20th
    
    int lip = rand()%2;
    if (lip && top_type != 1){
        current_x_dim += pyramid_step_height;
        current_z_dim += pyramid_step_height;
    }
    
    transform_group top;
    if (top_type == 0){ //BLOCK
        top = CreateBlock(top_height, randomMaterial(), top_type);
    }
    else if (top_type == 1){ //ELLIPSE
        top = CreateDome(randomMaterial());
        
    }
    else if (top_type == 2){ //PYRAMID
        int steps = (int)(top_height/pyramid_step_height); //height to steps conversion, # of steps rounded down
        top = CreatePyramid(steps, randomMaterial(), top_type);
    }
    building->addChild(top);
    
    return building;
}
Exemplo n.º 6
0
FSkyVertexBuffer::FSkyVertexBuffer()
{
	CreateDome();
}