float ch = building.height;
// 0,0,0 is the bottom center of the front
- // face, e.g. where the front door would be
-
+ // face, e.g. where the front door would be
// BASEMENT
// This exteds 10m below the main section
int row = ((int) (mt_rand(&seed) * 1000)) % 5;
float base_y = (float) row * 16.0 * 3.0 / 1024.0;
float top_y = base_y + 16.0 * (float) building.floors / 1024.0;
- float left_x = 0.0f;
- float right_x = 32.0 / 1024.0 * round((float) building.width / 6.0f);
- float front_x = 384.0/1024.0;
- float back_x = 384.0/1024.0 + 32.0 / 1024.0 * round((float) building.depth/ 6.0f);
+ float left_x = 32.0 / 1024.0 * round((float) building.width / 6.0f);
+ float right_x = 0.0f;
+ float front_x = 384.0/1024.0 + 32.0 / 1024.0 * round((float) building.depth/ 6.0f);
+ float back_x = 384.0/1024.0;
// BASEMENT - uses the baseline texture
for (unsigned int i = 0; i < 16; i++) {
if (building.pitched) {
// Use the entire height of the roof texture
top_y = base_y + 16.0 * 3.0 / 1024.0;
- left_x = 512/1024.0;
- right_x = 512/1024.0 + 32.0 / 1024.0 * round(building.width / 6.0f);
- front_x = 480.0/1024.0;
- back_x = 512.0/1024.0;
+ left_x = 512/1024.0 + 32.0 / 1024.0 * round(building.width / 6.0f);
+ right_x = 512/1024.0;
+ front_x = 512.0/1024.0;
+ back_x = 480.0/1024.0;
// Front
t->push_back( osg::Vec2( right_x, base_y) ); // bottom right
t->push_back( osg::Vec2( front_x, top_y ) ); // top right
} else {
// Flat roof
- left_x = 512.0/1024.0;
- right_x = 640.0/1024.0;
+ left_x = 640.0/1024.0;
+ right_x = 512.0/1024.0;
// Use the entire height of the roof texture
top_y = base_y + 16.0 * 3.0 / 1024.0;
int column = ((int) (mt_rand(&seed) * 1000)) % 5;
float base_y = 288 / 1024.0;
float top_y = base_y + 16.0 * (float) building.floors / 1024.0;
- float left_x = column * 192.0 /1024.0;
- float right_x = left_x + 32.0 / 1024.0 * round((float) building.width / 10.0f);
+ float left_x = column * 192.0 /1024.0 + 32.0 / 1024.0 * round((float) building.width / 10.0f);
+ float right_x = column * 192.0 /1024.0;
// BASEMENT - uses the baseline texture
for (unsigned int i = 0; i < 16; i++) {
if (building.pitched) {
base_y = 288.0/1024.0;
top_y = 576.0/1024.0;
- left_x = 960.0/1024.0;
- right_x = 1.0;
+ left_x = 1.0;
+ right_x = 960.0/1024.0;
// Front
t->push_back( osg::Vec2( right_x, base_y) ); // bottom right
t->push_back( osg::Vec2( left_x, base_y) ); // bottom left
// Flat roof
base_y = 416/1024.0;
top_y = 576.0/1024.0;
- right_x = left_x + 32.0 / 1024.0 * 6.0;
+ left_x = (column + 1)* 192.0 /1024.0;
+ right_x = column * 192.0 /1024.0;
+ //right_x = left_x + 32.0 / 1024.0 * 6.0;
t->push_back( osg::Vec2( right_x, base_y) ); // bottom right
t->push_back( osg::Vec2( left_x, base_y) ); // bottom left
int column = ((int) (mt_rand(&seed) * 1000)) % 8;
float base_y = 576 / 1024.0;
float top_y = base_y + 16.0 * (float) building.floors / 1024.0;
- float left_x = column * 128.0 /1024.0;
- float right_x = left_x + 32.0 / 1024.0 * round((float) building.width / 20.0f);
+ float left_x = column * 128.0 /1024.0 + 32.0 / 1024.0 * round((float) building.width / 20.0f);
+ float right_x = column * 128.0 /1024.0;
// BASEMENT - uses the baseline texture
for (unsigned int i = 0; i < 16; i++) {
floors = SGMisc<double>::round(mat->get_building_small_min_floors() + mt_rand(&seed) * (mat->get_building_small_max_floors() - mat->get_building_small_min_floors()));
height = floors * (2.8 + mt_rand(&seed));
+ // Small buildings are never deeper than they are wide.
if (depth > width) { depth = width; }
pitched = (mt_rand(&seed) < mat->get_building_small_pitch());
depth = mat->get_building_medium_min_depth() + mt_rand(&seed) * mt_rand(&seed) * (mat->get_building_medium_max_depth() - mat->get_building_medium_min_depth());
floors = SGMisc<double>::round(mat->get_building_medium_min_floors() + mt_rand(&seed) * (mat->get_building_medium_max_floors() - mat->get_building_medium_min_floors()));
height = floors * (2.8 + mt_rand(&seed));
+
+ while ((height > width) && (floors > mat->get_building_medium_min_floors())) {
+ // Ensure that medium buildings aren't taller than they are wide
+ floors--;
+ height = floors * (2.8 + mt_rand(&seed));
+ }
+
pitched = (mt_rand(&seed) < mat->get_building_medium_pitch());
} else {
buildingtype = SGBuildingBin::LARGE;