Example #1
0
        /// <summary>
        ///     Get the model for a specific QWord, character type, and the current <see cref="EquipSlot" />.
        /// </summary>
        /// <param name="key">The identifier of the model.</param>
        /// <param name="characterType">Character type to get the model for.</param>
        /// <param name="materialVersion">When this method returns, contains the variant contained within <c>key</c>.</param>
        /// <returns>Returns the <see cref="Model" /> for the specified <c>key</c> and <c>characterType</c>.</returns>
        public ModelDefinition GetModel(Quad key, int characterType, out Graphics.ImcVariant variant)
        {
            variant = Graphics.ImcVariant.Default;

            ModelHelper helper;

            if (!ModelHelpers.TryGetValue(Key, out helper))
            {
                return(null);
            }
            if (helper == null)
            {
                return(null);
            }

            var packs = Collection.Collection.PackCollection;

            var variantIndex = (int)((key.ToInt64() >> (helper.VariantIndexWord * 16)) & 0xFFFF);

            var imcPath = string.Format(helper.ImcFileFormat, key.Value1, key.Value2, key.Value3, key.Value4, characterType);

            IO.File imcBase;
            if (!packs.TryGetFile(imcPath, out imcBase))
            {
                return(null);
            }

            var imc = new Graphics.ImcFile(imcBase);

            variant = imc.GetVariant(helper.ImcPartKey, variantIndex);

            IO.File modelBase = null;
            while (!packs.TryGetFile(string.Format(helper.ModelFileFormat, key.Value1, key.Value2, key.Value3, key.Value4, characterType), out modelBase) && CharacterTypeFallback.TryGetValue(characterType, out characterType))
            {
            }

            var asModel = modelBase as Graphics.ModelFile;

            if (asModel == null)
            {
                return(null);
            }
            return(asModel.GetModelDefinition());
        }
Example #2
0
        /// <summary>
        ///     Get the model for a specific QWord, character type, and the current <see cref="EquipSlot" />.
        /// </summary>
        /// <param name="key">The identifier of the model.</param>
        /// <param name="characterType">Character type to get the model for.</param>
        /// <param name="materialVersion">When this method returns, contains the variant contained within <c>key</c>.</param>
        /// <returns>Returns the <see cref="Model" /> for the specified <c>key</c> and <c>characterType</c>.</returns>
        public ModelDefinition GetModel(long key, int characterType, out Graphics.ImcVariant variant)
        {
            variant = Graphics.ImcVariant.Default;

            ModelHelper helper;
            if (!ModelHelpers.TryGetValue(Key, out helper))
                return null;
            if (helper == null)
                return null;

            var packs = Collection.Collection.PackCollection;

            var a = key & 0xFFFF;
            var b = (key >> 16) & 0xFFFF;
            var c = (key >> 32) & 0xFFFF;
            var d = (key >> 48) & 0xFFFF;
            var variantIndex = (int)((key >> (helper.VariantIndexWord * 16)) & 0xFFFF);

            var imcPath = string.Format(helper.ImcFileFormat, a, b, c, d, characterType);
            IO.File imcBase;
            if (!packs.TryGetFile(imcPath, out imcBase))
                return null;

            var imc = new Graphics.ImcFile(imcBase);
            variant = imc.GetVariant(helper.ImcPartKey, variantIndex);

            IO.File modelBase = null;
            while (!packs.TryGetFile(string.Format(helper.ModelFileFormat, a, b, c, d, characterType), out modelBase) && CharacterTypeFallback.TryGetValue(characterType, out characterType)) { }

            var asModel = modelBase as Graphics.ModelFile;
            if (asModel == null)
                return null;
            return asModel.GetModelDefinition();
        }