Exemple #1
0
        public void TestGenerateBridge()
        {
            #region init

            initializeTW();
            throw new NotImplementedException();
            TWRenderWrapper renderer = null;//= new TWRenderWrapper(deferredRenderer, game);

            const string startSemId = "Start";
            const bool   hideMeshes = false;

            int width  = 4;
            int height = 2;
            int length = 20;

            var startShapes = new List <IBuildingElement>();
            rnd.Reset();
            var face = new Face(startSemId, Matrix.RotationX(-(float)Math.PI * 0.5f) * Matrix.RotationY((float)Math.PI), new Vector2(width, length));
            startShapes.Add(face);

            #endregion init

            var builder = new Builder(renderer);
            builder.Build(startShapes, BridgeRuleBase(startSemId, hideMeshes, height), rnd.GetCurrentSeed());

            var exporter = new EasyExporter();

            game.GameLoopEvent += delegate
            {
                if (game.Keyboard.IsKeyPressed(Key.F))
                {
                    exporter.ExportScene(renderer.GetCurrentMeshes(), "bridge");
                }

                if (game.Keyboard.IsKeyPressed(Key.R))
                {
                    startShapes = new List <IBuildingElement>();

                    rnd.Reset();

                    width  = rnd.GetRandInt(2, 6);
                    height = rnd.GetRandInt(2, 4);
                    length = rnd.GetRandInt(15, 35);

                    face = new Face(startSemId, Matrix.RotationX(-(float)Math.PI * 0.5f) * Matrix.RotationY((float)Math.PI), new Vector2(width, length));
                    startShapes.Add(face);

                    builder.Purge();
                    builder.Build(startShapes, BridgeRuleBase(startSemId, hideMeshes, height), rnd.GetCurrentSeed());
                }

                renderer.Update();
                update();
            };

            game.Run();
        }
Exemple #2
0
        public void TestIslandParts()
        {
            var seed = 1;

            #region init
            hideAxes = true;
            initializeTW();
            throw new NotImplementedException();
            TWRenderWrapper renderer = null;// = new TWRenderWrapper(deferredRenderer, game);
            renderer.DrawFaceUnitAxes = false;
            rnd.Reset(seed);
            #endregion init

            var   generator   = new IslandGenerator();
            var   startShapes = generator.GetIslandBase(seed);
            IMesh islandMesh;
            List <IBuildingElement> navMesh;
            List <IBuildingElement> buildMesh;
            List <IBuildingElement> borderMesh;
            generator.GetIslandParts(startShapes, seed, true, out islandMesh, out navMesh, out buildMesh, out borderMesh);

            var allFaces = navMesh.Select(element => ((Face)element).ExtraTransform(Matrix.Translation(0, 0, 0.25f), "nav")).ToList();
            allFaces.AddRange(buildMesh.Select(element => ((Face)element).ExtraTransform(Matrix.Translation(0, 0, 4), "build")));
            allFaces.AddRange(borderMesh.Select(element => ((Face)element).ExtraTransform(Matrix.Translation(0, 0, 8), "border")));

            var builder = new Builder(renderer);
            builder.Build(allFaces, new RuleBase(), seed);
            deferredRenderer.CreateMeshElement(islandMesh);

            game.GameLoopEvent += delegate
            {
                if (game.Keyboard.IsKeyPressed(Key.L))
                {
                    extraLight.LightPosition = camera.GetCameraPosition();
                }
                renderer.Update();
                update();
                cameraLight.LightPosition = new Vector3(10, 15, 5);
            };

            game.Run();
        }