/// <summary>
        /// Initializes a new instance of the ExtendedModel class.
        /// </summary>
        /// <param name="content">The ContentManager to use to load the asset.</param>
        /// <param name="assetName">The name of the asset to load.</param>
        /// <exception cref="InvalidOperationException">Vertex data missing or in invalid format.</exception>
        private ExtendedModel(PackFileContentManager content, string assetName)
        {
            this.model = content.Load<Model>(assetName);

            try
            {
                if (this.model.Tag != null && this.model.Tag is Vector3[])
                {
                    this.vertices = (Vector3[])this.model.Tag;
                }
                else
                {
                    throw new InvalidOperationException(Resources.VertexDataMissingInvalid);
                }

                this.BoundingSphere = BoundingSphere.CreateFromPoints(this.vertices);
                this.BoundingBox = BoundingBox.CreateFromPoints(this.vertices);
            }
            finally
            {
                this.model.Tag = null;
            }

            ExtendedModel.cache.Add(assetName, this);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the GameEngine class.
        /// </summary>
        /// <param name="deviceManager">The GraphicsDeviceManager to manage rendering.</param>
        /// <param name="contentManager">The ContentManager for the content pipeline to load content from.</param>
        /// <exception cref="System.ArgumentNullException">GraphicsDeviceManager is null -or- ContentManager is null.</exception>
        public GameEngine(GraphicsDeviceManager deviceManager, PackFileContentManager contentManager)
            : this(contentManager)
        {
            if (deviceManager == null)
            {
                throw new ArgumentNullException("deviceManager");
            }

            this.GraphicsDeviceManager = deviceManager;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the GameEngine class.
        /// </summary>
        /// <param name="content">The ContentManager for the content pipeline to load content from.</param>
        /// <exception cref="System.ArgumentNullException">ContentManager is null.</exception>
        private GameEngine(PackFileContentManager content)
            : this()
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }

            this.Content = content;
            this.FontCreator = new SpriteFontCreator(content.ServiceProvider);
        }
 /// <summary>
 /// Loads a model from an XNB asset.
 /// </summary>
 /// <param name="content">The ContentManager to use to load the asset.</param>
 /// <param name="assetName">The name of the asset to load.</param>
 /// <returns>See summary.</returns>
 public static ExtendedModel Load(PackFileContentManager content, string assetName)
 {
     if (ExtendedModel.cache.ContainsKey(assetName))
     {
         return ExtendedModel.cache[assetName];
     }
     else
     {
         return new ExtendedModel(content, assetName);
     }
 }