Exemple #1
0
    def test_mountains(self):
        mount = ImageFeature("tests/img/mount_200.png")
        
        gen_model = AbstractModel(os.path.abspath(os.path.dirname(sys.argv[0])) + "/tests/models/pine_tree/Pine_4m.obj", 0.01, (0, 0))
        v1 = Vegetation(geom.box(20, 20, 180, 180), gen_model, 10)
        v1.models.append(Model((5, 5), gen_model))
        v1.models.append(Model((195, 195), gen_model))

        env = Environment([mount, v1])
        env.init_heightmap(200, 200)
        
        f = open('mountains.pickle', 'wb')
        pickle.dump(env, f)
        f.close()

        env.export_heightmap("bla.png", 200, 200)
Exemple #2
0
class TestClassEnvironment(unittest.TestCase):
    def setUp(self):
        self.background = FeatureTest(100, influence="notall", val_influence=1)
        self.background.shape = geom.box(5, 5, 45, 45)
        
        self.up = FeatureTest(150, influence="notall", val_influence=1)
        self.up.shape = geom.box(10, 10, 30, 30)
        
        self.rep = FeatureTestReplace(0, influence="notall", val_influence=1)
        self.rep.shape = geom.box(10, 10, 30, 30)
        
        self.forest = Vegetation(geom.box(5, 5, 45, 45), model=AbstractModel(), tree_number=50)

        self.env = Environment([self.rep, self.up, self.background, self.forest])
        
    def test_models(self):
        self.assertLess(len(self.env.models), 50)
        self.assertGreater(len(self.env.models), 25)

        self.env.export_heightmap("temp_env.png", 50, 50)
Exemple #3
0
 def test_mountain(self):
     m2 = Mountain(10**3, 0, (50, 50))
     t = Environment([m2])
     t.export_heightmap("mountain_as_env.png", res_x=100, res_y=100)