Esempio n. 1
0
        public static void Load(ContentManager Content, AnimationConfig config, GraphicsDeviceManager graphics = null)
        {
            Config = config;

            dot   = Content.Load <Texture2D>("dot");
            ring  = Content.Load <Texture2D>("ring");
            cross = Content.Load <Texture2D>("cross");

            if (graphics != null)
            {
                dotTex   = new Dictionary <Color, Texture2D>();
                ringTex  = new Dictionary <Color, Texture2D>();
                crossTex = new Dictionary <Color, Texture2D>();

                var colorList = new List <Color>()
                {
                    Color.White, Color.Black, Color.Red, Color.DarkRed, Color.Pink, Color.Purple,
                    Color.Blue, Color.LightBlue, Color.DarkBlue, Color.Green, Color.LightGreen, Color.DarkGreen, Color.LightGray,
                    Color.Gray, Color.DarkGray, Color.Yellow, Color.Orange, Color.Brown
                };

                foreach (var c in colorList)
                {
                    dotTex.Add(c, SetTextureColorData(graphics, dot, c));
                    ringTex.Add(c, SetTextureColorData(graphics, ring, c));
                    crossTex.Add(c, SetTextureColorData(graphics, cross, c));
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string path       = "";
            string resultPath = "";

            if (args.Length > 0)
            {
                path = args[0];
            }
            if (args.Length > 1)
            {
                resultPath = args[1];
            }

            if (File.Exists(path) && path != "")
            {
                string          s      = File.ReadAllText(path);
                AnimationConfig Config = JsonConvert.DeserializeObject <AnimationConfig>(s);

                Console.WriteLine(Config.SimulationType);
                Console.WriteLine(Config.OutputPath);
                foreach (var v in Config.particleBlueprints)
                {
                    Console.WriteLine(v.Name);
                    foreach (var t in v.outputInformations)
                    {
                        Console.WriteLine("\t" + t.Key + " " + t.Value);
                    }
                }

                if (resultPath != "")
                {
                    Config.OutputPath = resultPath;
                }

                //Game game = null;

                if (Config.SimulationType == "3D")
                {
                    Visual3D v = new Visual3D(Config);
                    //v.LoadContent();
                    v.BakeAnimation();
                }
                else
                {
                    Visual2D v = new Visual2D(Config);
                    v.BakeAnimation();
                }

                //game.Run();
            }
            else
            {
                Console.WriteLine("File '.conig' can not be found in: " + path);
            }
        }
Esempio n. 3
0
        public Visual2D(AnimationConfig config)
        {
            Config = config;

            string path = Assembly.GetEntryAssembly().Location;

            path = Path.GetFullPath(Path.Combine(path, @"..\..\..\..\"));
            path = Path.Combine(path, @"Content");

            Content.RootDirectory = path;

            var graphics = new GraphicsDeviceManager(this)
            {
                IsFullScreen              = false,
                PreferredBackBufferWidth  = (int)MaximumWindowSize.X,
                PreferredBackBufferHeight = (int)MaximumWindowSize.Y,
            };

            graphics.ApplyChanges();


            OutputWindowSize = CalcWindowSize();
            GridSize         = OutputWindowSize - MarginOffsetSize - new Vector2(LegendSize, 0);


            renderTarget = new RenderTarget2D(GraphicsDevice, (int)OutputWindowSize.X + LegendSize, (int)OutputWindowSize.Y, false,
                                              GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);


            Files = Directory.GetFiles(Config.OutputPath + "\\Data")
                    .Where((val) => val.EndsWith(".txt"))
                    .Where((val) => val.Contains("T="));

            Files = Files.OrderBy(s => double.Parse(s.Substring(s.IndexOf("T=") + 2).Replace(".txt", "")));

            if (Files.Count() == 0)
            {
                Files = Directory.GetFiles(Config.OutputPath)
                        .Where((val) => val.EndsWith(".txt"))
                        .Where((val) => val.Contains("T="));

                Files = Files.OrderBy(s => double.Parse(s.Substring(s.IndexOf("T=") + 2).Replace(".txt", "")));

                Console.WriteLine("***Could not find simulation results in specific directory: " + Config.OutputPath);
            }
        }
Esempio n. 4
0
        public Visual3D(AnimationConfig config)
        {
            Config = config;

            string path = Assembly.GetEntryAssembly().Location;

            path = Path.GetFullPath(Path.Combine(path, @"..\..\..\..\"));
            path = Path.Combine(path, @"Content");

            Content.RootDirectory = path;

            graphics = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = 1920,
                PreferredBackBufferHeight = 1080,
            };
            graphics.ApplyChanges();

            renderTarget = new RenderTarget2D(GraphicsDevice, 1920, 1080, false,
                                              GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);


            Files = Directory.GetFiles(Config.OutputPath + "\\Data")
                    .Where((val) => val.EndsWith(".txt"))
                    .Where((val) => val.Contains("T="));

            Files = Files.OrderBy(s => double.Parse(s.Substring(s.IndexOf("T=") + 2).Replace(".txt", "")));

            if (Files.Count() == 0)
            {
                Files = Directory.GetFiles(Config.OutputPath)
                        .Where((val) => val.EndsWith(".txt"))
                        .Where((val) => val.Contains("T="));

                Files = Files.OrderBy(s => double.Parse(s.Substring(s.IndexOf("T=") + 2).Replace(".txt", "")));

                Console.WriteLine("***Could not find simulation results in specific directory: " + Config.OutputPath);
            }
        }