public MainSceneEditor()
        {
            var texturePool           = new TexturePool();
            var meshpartPool          = new MeshPartPool();
            var vertexDeclarationPool = new VertexDeclarationPool();

            vertexDeclarationPool.SetVertexElements <TangentVertex>(TangentVertex.VertexElements);
            renderer = new SimpleMeshRenderer(texturePool, meshpartPool, vertexDeclarationPool);

            game.IsFixedTimeStep = false;
            game.DrawFps         = true;
            game.AddXNAObject(texturePool);
            game.AddXNAObject(meshpartPool);
            game.AddXNAObject(vertexDeclarationPool);
            game.AddXNAObject(renderer);

            renderingFactory = new DiskRenderingAssetFactory();


            placeTool     = new WorldObjectPlaceTool(game, world, renderer, builder, renderingFactory, tileFaceFactory);
            moveTool      = new WorldObjectMoveTool(game, world, builder, renderer);
            snapLearnTool = new SnapLearnTool(world, renderer, builder);

            game.AddXNAObject(placeTool);
            game.AddXNAObject(moveTool);
            game.AddXNAObject(snapLearnTool);

            diskTileDataFactory = new DiskTileDataFactory(renderingFactory, tileFaceTypeFactory);
            worldSerializer     = new WorldSerializer(renderingFactory, diskTileDataFactory, game, renderer, worldObjectTypeFactory,
                                                      builder);
        }
Beispiel #2
0
        public void TestLoadWorldInScene()
        {
            var game            = new TestTWGame();
            var factory         = new DiskRenderingAssetFactory();
            var tileDataFactory = new DiskTileDataFactory(factory, new SimpleTileFaceTypeFactory());
            var serializer      = new WorldSerializer(factory, tileDataFactory,
                                                      game.Game, game.Renderer, new SimpleWorldObjectTypeFactory(),
                                                      new TileSnapInformationBuilder());



            var world          = new World();
            var worldXmlFile   = TWDir.Test.CreateSubdirectory("TileEngine").FullName + "\\WorldBig001Up.xml";
            var worldDirectory = TWDir.Test.CreateSubdirectory("TileEngine\\WorldBig001Up");

            factory.SaveDir         = worldDirectory;
            tileDataFactory.SaveDir = worldDirectory;
            using (var fs = File.Open(worldXmlFile, FileMode.Open))
                serializer.DeserializeWorld(world, fs);


            var scene = new Scene.Scene(game.Renderer, game.PhysicsFactory);

            game.Game.AddXNAObject(scene);

            var loader = new WorldSceneLoader(world, scene);

            loader.LoadIntoScene();

            var shooter = new TestSphereShooter(game.Game, game.PhysicsEngine, game.PhysicsTreeRoot,
                                                game.Game.SpectaterCamera);

            game.Game.AddXNAObject(shooter);

            game.Game.Run();
        }