Пример #1
0
 /// <summary>
 /// Adds an existing <see cref="Texture2D"/> object.
 /// </summary>
 /// <param name="id"><see cref="TextureIDs"/> id being associated with the <see cref="Texture2D"/> object.</param>
 /// <param name="texture">A <see cref="Texture2D"/> object.</param>
 public static void AddTexture(TextureIDs id, Texture2D texture)
 {
     if (textures.ContainsKey(id))
     {
         textures[id] = texture;
     }
     else
     {
         textures.Add(id, texture);
     }
 }
Пример #2
0
        public override void Read(EndianBinaryReader reader, ISection section = null)
        {
            uint signature = reader.ReadUInt32();

            if (signature != 0x5062500 && signature != 0x5062501)
            {
                throw new InvalidDataException("Invalid signature (expected 0x5062500 or 0x5062501)");
            }

            int  meshCount           = reader.ReadInt32();
            int  globalBoneCount     = reader.ReadInt32();
            long meshesOffset        = reader.ReadOffset();
            long meshSkinningsOffset = reader.ReadOffset();
            long meshNamesOffset     = reader.ReadOffset();
            long meshIDsOffset       = reader.ReadOffset();
            long textureIDsOffset    = reader.ReadOffset();
            int  textureIDCount      = reader.ReadInt32();

            // We are reading only if there's no section provided.
            // The MeshSection class already parses the meshes.
            // For classic formats, this won't be done, so we will be parsing them ourselves.

            reader.ReadAtOffsetIf(section == null, meshesOffset, () =>
            {
                Meshes.Capacity = meshCount;
                for (int i = 0; i < meshCount; i++)
                {
                    reader.ReadOffset(() =>
                    {
                        reader.PushBaseOffset();
                        {
                            var mesh = new Mesh();
                            mesh.Read(reader);
                            Meshes.Add(mesh);
                        }
                        reader.PopBaseOffset();
                    });
                }
            });

            reader.ReadAtOffsetIf(section == null, meshSkinningsOffset, () =>
            {
                foreach (var mesh in Meshes)
                {
                    reader.ReadOffset(() =>
                    {
                        mesh.Skin = new MeshSkin();
                        mesh.Skin.Read(reader);
                    });
                }
            });

            reader.ReadAtOffset(meshNamesOffset, () =>
            {
                foreach (var mesh in Meshes)
                {
                    mesh.Name = reader.ReadStringOffset(StringBinaryFormat.NullTerminated);
                }
            });

            reader.ReadAtOffset(meshIDsOffset, () =>
            {
                foreach (var mesh in Meshes)
                {
                    mesh.ID = reader.ReadInt32();
                }
            });

            reader.ReadAtOffset(textureIDsOffset, () =>
            {
                TextureIDs.Capacity = textureIDCount;
                for (int i = 0; i < textureIDCount; i++)
                {
                    TextureIDs.Add(reader.ReadInt32());
                }
            });
        }
Пример #3
0
 /// <summary>
 /// This will add a font path to the dictionary under the provided <see cref="TextureIDs"/> ID.
 /// </summary>
 /// <param name="id"><see cref="TextureIDs"/> to associate font with the <see cref="Texture2D"/>.</param>
 /// <param name="path">Path to the <see cref="Texture2D"/> object.</param>
 /// <param name="ids">List of <see cref="TextureIDs"/> that resources have been added for.</param>
 /// <param name="paths">List of <see cref="string"/> paths to <see cref="Texture2D"/> objects.</param>
 private void LoadTexture(TextureIDs id, string path, List <TextureIDs> ids, Dictionary <TextureIDs, string> paths)
 {
     ids.Add(id);
     paths.Add(id, path);
 }
Пример #4
0
        /// <summary>
        /// Adds a new <see cref="Texture2D"/> through the <see cref="ContentManager"/> pipeline.
        /// </summary>
        /// <param name="id"><see cref="TextureIDs"/> id being associated with the <see cref="Texture2D"/> object.</param>
        /// <param name="path">A <see cref="string"/> path to the <see cref="Texture2D"/> object.</param>
        public static void AddTexture(TextureIDs id, string path)
        {
            Texture2D texture = Content.Load <Texture2D>(path);

            AddTexture(id, texture);
        }