Ejemplo n.º 1
0
        public ChunkRenderer([NotNull] TextureFinder textureFinder, RenderSettings settings = null)
        {
            this.textureFinder  = textureFinder ?? throw new ArgumentNullException(nameof(textureFinder));
            this.renderSettings = settings ?? new RenderSettings();

            b = new Brillouin(renderSettings.BrillouinJ, renderSettings.BrillouinDivider);
        }
        /// <summary>
        /// Converts the object into .mtl file content.
        /// </summary>
        /// <param name="textureFinder">The texture finder.</param>
        /// <returns>The content for the .mtl file.</returns>
        public string ToMaterialCode(TextureFinder textureFinder)
        {
            if (textureFinder is null)
            {
                throw new ArgumentNullException(nameof(textureFinder));
            }

            StringBuilder    sb            = new StringBuilder();
            HashSet <string> savedTextures = new HashSet <string>();

            foreach (ObjObject obj in Objects)
            {
                foreach (string texture in obj.Faces.Select(x => x.Texture))
                {
                    if (!savedTextures.Contains(texture))
                    {
                        savedTextures.Add(texture);
                        sb.Append("newmtl ").AppendLine(texture);
                        sb.Append("map_Kd ").Append(texture).AppendLine(textureFinder.FindExtension(texture));
                    }
                }
            }

            return(sb.ToString());
        }
Ejemplo n.º 3
0
 private void Awake()
 {
     SetUpDirectories();
     TextureFinder.AssignAllTextureDetails();
     RegionCollection.regionCollectionPrefab = (GameObject)Resources.Load("Region Collection");
     RegionCollection.CreateRegionCollection(new Vector3(-20, 20, -20), Vector3.zero, new IntVec3(3, 3, 3), "Test Region 1");
 }
Ejemplo n.º 4
0
            private static void RenderMap(int chunkRadius, Maploader.World.World dut, int centerOffsetX,
                                          int centerOffsetZ, string filename)
            {
                var json = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"textures",
                                                         "terrain_texture.json"));
                var ts       = new TerrainTextureJsonParser(json, "");
                var textures = ts.Textures;
                var g        = new SystemDrawing();
                var finder   = new TextureFinder <Bitmap>(textures,
                                                          Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "textures"), g);

                finder.Debug = false;

                var b = g.CreateEmptyImage(16 * 16 * (2 * chunkRadius + 1), 16 * 16 * (2 * chunkRadius + 1));

                var render = new ChunkRenderer <Bitmap>(finder, g, new RenderSettings()
                {
                    YMax = 40
                });

                //Parallel.For(-chunkRadius, chunkRadius + 1,new ParallelOptions(){MaxDegreeOfParallelism = 8} , dx =>
                for (int dz = -chunkRadius; dz <= chunkRadius; dz++)
                {
                    for (int dx = -chunkRadius; dx <= chunkRadius; dx++)
                    {
                        var c = dut.GetChunk(dx + centerOffsetX, dz + centerOffsetZ);
                        if (c != null)
                        {
                            render.RenderChunk(b, c, (chunkRadius + dx) * 256, (chunkRadius + dz) * 256);
                        }
                    }
                }

                var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);

                b.Save(path);
                Console.WriteLine(path);
                dut.Close();
            }
 /// <summary>
 /// Saves the .mtl file.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="textureFinder">The texture finder.</param>
 public void SaveMaterialFile(string path, TextureFinder textureFinder)
 => File.WriteAllText(path, ToMaterialCode(textureFinder));
Ejemplo n.º 6
0
 public RendererCombi(Dictionary <string, Texture> textureDictionary, string texturePath, RenderSettings renderSettings, IGraphicsApi <TImage> graphics)
 {
     Finder        = new TextureFinder <TImage>(textureDictionary, texturePath, graphics);
     ChunkRenderer = new ChunkRenderer <TImage>(Finder, graphics, renderSettings);
 }