Example #1
0
        /// <summary>
        /// Caches the textures used in a display info record for use.
        /// </summary>
        /// <param name="displayInfoRecord">The display info record to cache.</param>
        private void CacheDisplayInfo(CreatureDisplayInfoRecord displayInfoRecord)
        {
            if (displayInfoRecord == null)
            {
                throw new ArgumentNullException(nameof(displayInfoRecord));
            }

            if (_modelPath is null)
            {
                throw new InvalidOperationException();
            }

            foreach (var texture in _model.Textures)
            {
                int textureIndex;
                switch (texture.TextureType)
                {
                case MDXTextureType.MonsterSkin1:
                {
                    textureIndex = 0;
                    break;
                }

                case MDXTextureType.MonsterSkin2:
                {
                    textureIndex = 1;
                    break;
                }

                case MDXTextureType.MonsterSkin3:
                {
                    textureIndex = 2;
                    break;
                }

                default:
                {
                    continue;
                }
                }

                var textureName    = displayInfoRecord.TextureVariations[textureIndex].Value;
                var modelDirectory = _modelPath.Remove(_modelPath.LastIndexOf('\\'));
                var texturePath    = $"{modelDirectory}\\{textureName}.blp";

                if (_textureLookup.ContainsKey(texturePath))
                {
                    continue;
                }

                _textureLookup.Add
                (
                    texturePath,
                    _cache.GetTexture(texture, _gameContext, texturePath)
                );
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderableGameModel"/> class.
        /// </summary>
        /// <param name="inModel">The model to render.</param>
        /// <param name="gameContext">The game context.</param>
        public RenderableGameModel(MDX inModel, WarcraftGameContext gameContext)
        {
            this.Model       = inModel;
            this.GameContext = gameContext;

            this.ActorTransform = new Transform();

            // Set a default display info for this model
            var displayInfo = GetSkinVariations().FirstOrDefault();

            if (displayInfo != null)
            {
                this.CurrentDisplayInfo = displayInfo;
            }

            this.IsInitialized = false;
        }
Example #3
0
 /// <summary>
 /// Sets the current display info to the record pointed to by the given ID.
 /// </summary>
 /// <param name="variationID">The ID of the record.</param>
 public void SetDisplayInfoByID(int variationID)
 {
     this.CurrentDisplayInfo = this.GameContext.Database.GetDatabase <CreatureDisplayInfoRecord>().GetRecordByID(variationID);
     CacheDisplayInfo(this.CurrentDisplayInfo);
 }