예제 #1
0
 def test_disabled_textures(self):
     loader = colobot.loader.Loader(enable_textures=False)
     loader.add_directory('data/models')
     
     self.assertTrue(loader.get_model('keya.mod'))
     self.assertTrue(loader.get_model('keyb.mod'))
     self.assertTrue(loader.get_model('home1.mod'))
     self.assertRaises(KeyError, loader.get_model, 'blehblehbleh.mod')
     self.assertRaises(KeyError, loader.get_model, 'keya')
예제 #2
0
 def test_loading_success(self):
     loader = colobot.loader.Loader()
     loader.add_directory('data/models')
     loader.add_directory('data/diagram')
     loader.add_directory('data/textures')
     
     self.assertTrue(loader.get_model('keya.mod'))
     self.assertTrue(loader.get_model('keyb.mod'))
     self.assertTrue(loader.get_model('home1.mod'))
     self.assertRaises(KeyError, loader.get_model, 'blehblehbleh.mod')
     self.assertRaises(KeyError, loader.get_model, 'keya')
예제 #3
0
        return (self.items(), )

    @staticmethod
    def _unserialize(seq):
        return dict(seq)

if __name__ == '__main__':
    import g3d
    import g3d.gl
    import g3d.camera_drivers
    import g3d.model
    import g3d.serialize
    import colobot.loader

    loader = colobot.loader.Loader(enable_textures=True)
    loader.add_directory('data/models')
    loader.add_directory('data/anim')
    loader.add_directory('data/diagram')
    loader.add_directory('data/textures')

    #g3d.model.read(loader=loader, name='wheeled-transporter.model')
    model = loader.get_model('keya.mod')

    s = g3d.serialize.Serializer()
    sha1hash = s.add(model)
    print sha1hash.encode('hex')
    data = s.get_by_sha1(sha1hash)
    import zlib
    print len(data), len(zlib.compress(data))
    print [ i.encode('hex') for i in s.deps[model] ]
    print [ i.encode('hex') for i in s.get_dependencies(model) ]
예제 #4
0
#!/usr/bin/python
import sys, os

sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))

import g3d
import g3d.gl
import g3d.camera_drivers
import g3d.model
import colobot.loader

loader = colobot.loader.Loader()
loader.add_directory("data/models")
loader.add_directory("data/anim")
loader.add_directory("data/diagram")
loader.add_directory("data/textures")

name = sys.argv[1]
if name.endswith(".mod"):
    obj = loader.get_model(name)
else:
    model = g3d.model.read(loader=loader, name=name)
    obj = model.root

g3d.options.enable_textures = True

win = g3d.gl.Window()
win.root.add(obj)


def rotate():
예제 #5
0
import logging
import glob

DEFAULT_PATH = '~/.colobot'
DEFAULT_ADDRESS = 'tcp:localhost:2718'

parser = argparse.ArgumentParser(description='Start Colobot-py server.')
parser.add_argument('--profile', metavar='PROFILE', dest='profile',
                    default=DEFAULT_PATH,
                   help='where to store server data (default: %(default)s)')
parser.add_argument('--address', metavar='ADDRESS', dest='address',
                   default=DEFAULT_ADDRESS, # notice that default port == int(e*1000)
                   help='address to bind (in form tcp:host:port or anything multisock accepts)'
                    ' (default: %(default)s)')
parser.add_argument('--log', metavar='LEVEL', dest='logging',
                    default='INFO', choices=['INFO', 'DEBUG', 'ERROR'],
                    help='logging level, one of: DEBUG, INFO, ERROR')

args = parser.parse_args()

logging.basicConfig(level=getattr(logging, args.logging.upper()))

profile = colobot.server.models.Profile(os.path.expanduser(args.profile))
loader = colobot.loader.Loader()

for path in glob.glob('data/*'):
    if os.path.isdir(path):
        loader.add_directory(path)

colobot.server.server.Server(profile=profile, loader=loader).run(args.address)