Esempio n. 1
0
        private static void AddBinGameScene()
        {
            GameObject camera = new GameObject("Camera");

            camera.Transform.Rotation = Quaternion.CreateFromYawPitchRoll(0.3f, 0.3f, 0f);
            camera.AddComponent(new Camera());

            GameObject character = new GameObject("Character");

            character.AddComponent(new CharacterController());
            character.Transform.Position = new Vector3(0, 0, -5f);

            camera.Transform.Parent        = character.Transform;
            camera.Transform.LocalPosition = new Vector3(0, 1.0f, 0);
            camera.AddComponent(new FpsLookController());
            camera.AddComponent(new CameraBob());

            GameObject light          = new GameObject("Light");
            var        lightComponent = new DirectionalLight(RgbaFloat.White, new Vector3(0.3f, -1f, -1f));

            light.AddComponent(lightComponent);

            var woodTexture = Path.Combine("Textures", "Wood.png");

            for (int x = 0; x < 7; x++)
            {
                for (int z = 0; z < 7; z++)
                {
                    GameObject plane = new GameObject($"Plane{x},{z}");
                    plane.Transform.Position = new Vector3(-18 + (6 * x), -3.5f, -18 + (6 * z));
                    plane.Transform.Scale    = new Vector3(6);
                    plane.AddComponent(new MeshRenderer(EngineEmbeddedAssets.PlaneModelID, woodTexture));
                    plane.AddComponent(new BoxCollider(1f, 0.1f / 30f, 1f, -1.0f));
                }
            }

            var bin = Prefabs.CreateBin();

            var scaleBox = new GameObject("ScaleBox");

            scaleBox.Transform.Position = new Vector3(5f, 0f, 0f);
            scaleBox.Transform.Scale    = new Vector3(3f);
            scaleBox.AddComponent(new MeshRenderer(new SimpleMeshDataProvider(CubeModel.Vertices, CubeModel.Indices), woodTexture));
            scaleBox.AddComponent(new BoxCollider(1.0f, 1.0f, 1.0f, 50.0f));

            camera.AddComponent(new BallLauncher());
            camera.AddComponent(new DebugConsole());
        }