Beispiel #1
0
    def create_trees(self):
        for tree in self.trees:
            tree.removeNode()
        self.trees = []
        for i in xrange(self.config.tree_models):
            l = 1
            self.trees.append(
                LowTreeModel('tree_{0}'.format(i),
                             (l, l, random.randint(8, 32)),
                             self.params.tree_tex, self.params.leafTex))
            #self.trees.append(TreeModel(self, 'tree_{0}'.format(i),
            #Vec3(l,
            #l,
            #random.randint(2,4)),
            #self.params.tree_tex,
            #self.params.leafModel,
            #self.params.leafTex,
            #numIterations = 0,
            #numCopies = 0))

        #for i in xrange(self.config.tree_models):
        #self.trees.append(CubeModel(1, 1, random.randint(6,18)))
        #self.trees[i].setTexture(self.params.tree_tex)
        #self.trees[i].flattenStrong()
        self.forest = ForestNode(self.config, self)
        self.forest.reparentTo(self.root_node)
Beispiel #2
0
    def create_trees(self):
        for tree in self.trees:
            tree.removeNode()
        self.trees = []
        for i in xrange(self.config.tree_models):
            l = 1
            self.trees.append(LowTreeModel('tree_{0}'.format(i),
                                 (l, l, random.randint(8, 32)),
                                 self.params.tree_tex,
                                 self.params.leafTex
                                 ))
            #self.trees.append(TreeModel(self, 'tree_{0}'.format(i),
                                        #Vec3(l,
                                             #l,
                                             #random.randint(2,4)),
                                        #self.params.tree_tex,
                                        #self.params.leafModel,
                                        #self.params.leafTex,
                                        #numIterations = 0,
                                        #numCopies = 0))

        #for i in xrange(self.config.tree_models):
            #self.trees.append(CubeModel(1, 1, random.randint(6,18)))
            #self.trees[i].setTexture(self.params.tree_tex)
            #self.trees[i].flattenStrong()
        self.forest = ForestNode(self.config, self)
        self.forest.reparentTo(self.root_node)
Beispiel #3
0
class World():
    """World

    config - voxplanet.config.Config()
    params - voxplanet.params.Params()
    """
    def __init__(self, config, params):
        self.config = config
        self.params = params
        self.seed = random.randint(0, sys.maxint)
        self.root_node = NodePath('Root_World')
        self.change_params(params)

        self.mutex_repaint = Mutex('repaint')
        self.trees = []
        self.treeland = TreeLand(self.config, self)
        self.forest = None

    def change_params(self, params):
        self.params = params
        self.root_node.reparentTo(self.params.root_node)
        self.gui = self.params.gui
        self.avatar = self.params.avatar
        self.status = self.params.status

    def get_map3d_tex(self, size=512, filename=None):
        """Generate texture of map world
        """
        return self.map3d.get_map_3d_tex(
            size, filename, (self.chunks_map.charX, self.chunks_map.charY))

    def create_trees(self):
        for tree in self.trees:
            tree.removeNode()
        self.trees = []
        for i in xrange(self.config.tree_models):
            l = 1
            self.trees.append(
                LowTreeModel('tree_{0}'.format(i),
                             (l, l, random.randint(8, 32)),
                             self.params.tree_tex, self.params.leafTex))
            #self.trees.append(TreeModel(self, 'tree_{0}'.format(i),
            #Vec3(l,
            #l,
            #random.randint(2,4)),
            #self.params.tree_tex,
            #self.params.leafModel,
            #self.params.leafTex,
            #numIterations = 0,
            #numCopies = 0))

        #for i in xrange(self.config.tree_models):
        #self.trees.append(CubeModel(1, 1, random.randint(6,18)))
        #self.trees[i].setTexture(self.params.tree_tex)
        #self.trees[i].flattenStrong()
        self.forest = ForestNode(self.config, self)
        self.forest.reparentTo(self.root_node)

    def new(self):
        """New world
        """

        self.create_trees()

        def create_world():
            global_map_gen = Map_generator_2D(self.config, self.seed)
            complete_i = 0
            st = 'Start generate of world'
            print st
            self.status(st)
            for e, (i, desc) in enumerate(global_map_gen.start()):
                st = '{0} * step: {1} / {2}'.format(e, i, desc)
                print st
                self.status(st)
                complete_i = i
            print global_map_gen.maps.get_ascii(3)
            st = 'Start convertation 2d -> 3d'
            print st
            self.status(st)
            self.map2d = global_map_gen.end_map
            # TODO: calculate real size of world
            self.map3d = Map3d(self.config, self.map2d, self.seed)
            endstr = 'Map generation process has been completed. Seed: {0}'.format(\
                                                self.seed)
            print endstr
            self.status(endstr)

        create_world()

        self.voxels = Voxels(self.map3d, self.params.get_coord_block)

        self.chunks_map = ChunksMap(self, 0, 1)
Beispiel #4
0
class World():
    """World

    config - voxplanet.config.Config()
    params - voxplanet.params.Params()
    """
    def __init__(self, config, params):
        self.config = config
        self.params = params
        self.seed = random.randint(0, sys.maxint)
        self.root_node = NodePath('Root_World')
        self.change_params(params)

        self.mutex_repaint = Mutex('repaint')
        self.trees = []
        self.treeland = TreeLand(self.config, self)
        self.forest = None

    def change_params(self, params):
        self.params = params
        self.root_node.reparentTo(self.params.root_node)
        self.gui = self.params.gui
        self.avatar = self.params.avatar
        self.status = self.params.status

    def get_map3d_tex(self, size = 512, filename = None):
        """Generate texture of map world
        """
        return self.map3d.get_map_3d_tex(size, filename, (self.chunks_map.charX,
                                                          self.chunks_map.charY))

    def create_trees(self):
        for tree in self.trees:
            tree.removeNode()
        self.trees = []
        for i in xrange(self.config.tree_models):
            l = 1
            self.trees.append(LowTreeModel('tree_{0}'.format(i),
                                 (l, l, random.randint(8, 32)),
                                 self.params.tree_tex,
                                 self.params.leafTex
                                 ))
            #self.trees.append(TreeModel(self, 'tree_{0}'.format(i),
                                        #Vec3(l,
                                             #l,
                                             #random.randint(2,4)),
                                        #self.params.tree_tex,
                                        #self.params.leafModel,
                                        #self.params.leafTex,
                                        #numIterations = 0,
                                        #numCopies = 0))

        #for i in xrange(self.config.tree_models):
            #self.trees.append(CubeModel(1, 1, random.randint(6,18)))
            #self.trees[i].setTexture(self.params.tree_tex)
            #self.trees[i].flattenStrong()
        self.forest = ForestNode(self.config, self)
        self.forest.reparentTo(self.root_node)

    def new(self):
        """New world
        """

        self.create_trees()

        def create_world():
            global_map_gen = Map_generator_2D(self.config, self.seed)
            complete_i = 0
            st = 'Start generate of world'
            print st
            self.status(st)
            for e, (i, desc) in enumerate(global_map_gen.start()):
                st = '{0} * step: {1} / {2}'.format(e, i,desc)
                print st
                self.status(st)
                complete_i = i
            print global_map_gen.maps.get_ascii(3)
            st = 'Start convertation 2d -> 3d'
            print st
            self.status(st)
            self.map2d = global_map_gen.end_map
            # TODO: calculate real size of world
            self.map3d = Map3d(self.config, self.map2d, self.seed)
            endstr = 'Map generation process has been completed. Seed: {0}'.format(\
                                                self.seed)
            print endstr
            self.status(endstr)

        create_world()

        self.voxels = Voxels(self.map3d, self.params.get_coord_block)

        self.chunks_map = ChunksMap(self, 0, 1)