Exemplo n.º 1
0
        public static void GenerateImage()
        {
            var boxMaterial = Material.Default with
            {
                Pattern = new SolidPattern(new Color(1f, 0.9f, 0.9f)), SpecularReflection = 0f
            };

            var floor = new InfinitePlane {
                Material = boxMaterial, Normal = Vector.UnitY
            };

            var leftWall = new InfinitePlane
            {
                Material  = boxMaterial,
                Normal    = Vector.UnitX,
                Transform = Matrix4.Translation(3f, 0f, 0f)
            };

            var rightWall = new InfinitePlane
            {
                Material  = boxMaterial,
                Normal    = Vector.UnitZ,
                Transform = Matrix4.Translation(0f, 0f, 3f)
            };

            var middleSphere = new Sphere
            {
                Material = Material.Default with
                {
                    DiffuseReflection  = 0.7f,
                    Pattern            = new SolidPattern(new Color(0.15f, 0.15f, 1f)),
                    SpecularReflection = 0.5f
                },
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Enter Seed");
            var seed     = Console.ReadLine();
            var Map      = new SandboxMap(0, 0);
            var Engine   = new Engine("MyEngine");
            var Me       = new Player("Branimir");
            var InfPlain = new InfinitePlane(seed, "MyPlayn");

            Engine.Connect("localhost:52062");
            Engine.PushNewScreenOnTop(Map);
            Engine.PushNewComponentOnActiveScreen(Me);
            Engine.PushNewComponentOnActiveScreen(InfPlain);

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    var a = System.Console.ReadKey(true);
                    Engine.InputNextCommand(new MyConsoleKeyInfo(a.KeyChar), "Branimir");
                }
            });

            try
            {
                Console.CursorVisible = false;
            }
            catch { }
            Console.Clear();
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    Engine.SetActiveComponent(Me, Console.WindowWidth - 10, Console.WindowHeight - 10);

                    var threadSafely = Engine.RenderAroundComponent();
                    System.Console.Clear();
                    System.Console.Write(threadSafely);
                    Thread.Sleep(100);
                }
            });
            Thread.Sleep(int.MaxValue);
        }
Exemplo n.º 3
0
        public static void GenerateImage()
        {
            var boxMaterial = Material.Default with
            {
                Pattern = new SolidPattern(new Color(1f, 0.9f, 0.9f)), SpecularReflection = 0f
            };

            var floor = new InfinitePlane {
                Material = boxMaterial, Normal = Vector.UnitY
            };

            var leftWall = new InfinitePlane
            {
                Material  = boxMaterial,
                Normal    = Vector.UnitX,
                Transform = Matrix4.Translation(3f, 0f, 0f)
            };

            var rightWall = new InfinitePlane
            {
                Material  = boxMaterial,
                Normal    = Vector.UnitZ,
                Transform = Matrix4.Translation(0f, 0f, 3f)
            };

            var sphere = new Sphere
            {
                Material = Material.Default with
                {
                    DiffuseReflection = 0.7f,
                    Pattern           = new StripedPattern
                    {
                        Patterns = ImmutableArray.Create <Pattern>(
                            new StripedPattern
                        {
                            Patterns = ImmutableArray.Create <Pattern>(
                                new StripedPattern
                            {
                                Patterns = ImmutableArray.Create <Pattern>(
                                    new SolidPattern(Color.Red),
                                    new SolidPattern(Color.White)
                                    ),
                                Transform = Matrix4.Identity.RotateZ(MathF.PI / 4f)
                                            .Scale(0.25f, 0.25f, 0.25f)
                            },
                                new StripedPattern
                            {
                                Patterns = ImmutableArray.Create <Pattern>(
                                    new SolidPattern(Color.Green),
                                    new SolidPattern(Color.White)
                                    ),
                                Transform = Matrix4.Identity.RotateZ(-MathF.PI / 4f)
                                            .Scale(0.25f, 0.25f, 0.25f)
                            }
                                ),
                            Transform = Matrix4.Identity.RotateZ(MathF.PI / 4f)
                                        .Scale(0.25f, 0.25f, 0.25f)
                        },
                            new StripedPattern
                        {
                            Patterns = ImmutableArray.Create <Pattern>(
                                new StripedPattern
                            {
                                Patterns = ImmutableArray.Create <Pattern>(
                                    new SolidPattern(Color.Blue),
                                    new SolidPattern(Color.White)
                                    ),
                                Transform = Matrix4.Identity.RotateZ(MathF.PI / 4f)
                                            .Scale(0.25f, 0.25f, 0.25f)
                            },
                                new StripedPattern
                            {
                                Patterns = ImmutableArray.Create <Pattern>(
                                    new SolidPattern(new Color(1f, 0.99f, 0.23f)),
                                    new SolidPattern(Color.White)
                                    ),
                                Transform = Matrix4.Identity.RotateZ(-MathF.PI / 4f)
                                            .Scale(0.25f, 0.25f, 0.25f)
                            }
                                ),
                            Transform = Matrix4.Identity.RotateZ(-MathF.PI / 4f)
                                        .Scale(0.25f, 0.25f, 0.25f)
                        }
                            ),
                        Transform = Matrix4.Identity.RotateZ(MathF.PI / 2f)
                                    .Scale(0.25f, 0.25f, 0.25f)
                    },
                    SpecularReflection = 0.5f
                },