/// <summary> /// Loads an animation based on the name of the texture previouly from a spritesheet. Texture should have been /// previously loaded in the resource manager. Set the number of rows and columns /// and choose the row that contains the animation /// Animation are loaded from a spritesheet from a row /// </summary> /// <param name="animationName">Name to be given to the state and the animation</param> /// <param name="textureName">Name of the texture file/ spritesheet</param> /// <param name="numRows">Number of rows that the spritesheet has</param> /// <param name="numCols">Number of cols that the spritesheet has</param> /// <param name="row">Row of the animation </param> /// <returns>Returns the state created that hold the animation</returns> public IAnimationState LoadAnimation(string animationName, string textureName, int numRows, int numCols, int row) { //Creates a new animation IAnimationState animation = ASMachine.LoadState <SpritsheetAnimation>(animationName); //Get the texture/ spritesheet fro mthe resources texture = resourceManager.GetTexture(textureName); //Calculates the width and height of each frame int width = texture.Width / numCols; int height = texture.Height / numRows; //Calculates the pixels of the specific row to get the various frames int y = (height) * (row - 1); List <Rectangle> drawAreas = new List <Rectangle>(); int x = 0; //Gets all the textures of a specific row while (true) { drawAreas.Add(new Rectangle(x, y, width, height)); x += width; if (x + width >= texture.Width) { break; } } //Loads all the animation frames found into the animation SpritesheetAnimationFrames animationFrames = new SpritesheetAnimationFrames(); animationFrames.drawAreas = drawAreas.ToArray(); animationFrames.spriteSheet = texture; animationFrames.origin = new Vector2(drawAreas[0].Width / 2, drawAreas[0].Height / 2); animation.LoadFrames(animationFrames); return(animation); }
public void LoadContent() { //Load models m_chessboardModel = m_resourceManager.GetModel(GameModelKey.Chessboard); m_lettersModel = m_resourceManager.GetModel(GameModelKey.Letters); m_whitePawnModel = m_resourceManager.GetModel(GameModelKey.WhitePawn); m_whiteRookModel = m_resourceManager.GetModel(GameModelKey.WhiteRook); m_whiteKnightModel = m_resourceManager.GetModel(GameModelKey.WhiteKnight); m_whiteBishopModel = m_resourceManager.GetModel(GameModelKey.WhiteBishop); m_whiteQueenModel = m_resourceManager.GetModel(GameModelKey.WhiteQueen); m_whiteKingModel = m_resourceManager.GetModel(GameModelKey.WhiteKing); m_blackPawnModel = m_resourceManager.GetModel(GameModelKey.BlackPawn); m_blackRookModel = m_resourceManager.GetModel(GameModelKey.BlackRook); m_blackKnightModel = m_resourceManager.GetModel(GameModelKey.BlackKnight); m_blackBishopModel = m_resourceManager.GetModel(GameModelKey.BlackBishop); m_blackQueenModel = m_resourceManager.GetModel(GameModelKey.BlackQueen); m_blackKingModel = m_resourceManager.GetModel(GameModelKey.BlackKing); //Load effects m_phongBumpReflect = m_resourceManager.GetEffect(this, GameEffectKey.PhongBumpReflect); m_chessboardPickingEffect = m_resourceManager.GetEffect(this, GameEffectKey.SimpleTexture); m_phong = m_resourceManager.GetEffect(this, GameEffectKey.Phong); //Load textures m_chessboardPickingTexture = m_resourceManager.GetTexture(this, GameTextureKey.ChessboardPicking); m_chessboardDiffuse = m_resourceManager.GetTexture(this, GameTextureKey.ChessboardDiffuse); m_chessboardBump = m_resourceManager.GetTexture(this, GameTextureKey.ChessboardBump); m_lettersTexture = m_resourceManager.GetTexture(this, GameTextureKey.LettersDiffuse); m_whitePiecesTexture = m_resourceManager.GetTexture(this, GameTextureKey.WhitePiecesDiffuse); m_blackPiecesTexture = m_resourceManager.GetTexture(this, GameTextureKey.BlackPiecesDiffuse); m_selectedPiecesTexture = m_resourceManager.GetTexture(this, GameTextureKey.SelectedPiecesDiffuse); m_piecesBumpMap = m_resourceManager.GetTexture(this, GameTextureKey.PiecesBumpMap); //Load fonts m_messageFont = m_resourceManager.GetFont(GameFontKey.VerdanaBig); //Setup m_chessboardPickingEffect.Parameters["Texture"].SetValue(m_chessboardPickingTexture); //Setup the match m_chessMatch.SetupGame(); m_matchState = WhitePiecePicking.GetMatchState(this); //Reset the camera m_graphicsManager.ResetCamera(); }
public virtual void Load(IDataNode dataNode, IResourceManager resourceManager) { var shaderName = dataNode.ReadParameter("shader"); _shader = resourceManager.GetShader(shaderName); _name = dataNode.ReadParameter("key"); var textureParameters = new Dictionary <string, string>(); dataNode.ReadAllParameters(_vectorParameters, _numericParameters, textureParameters); foreach (var textureParameter in textureParameters) { if (resourceManager.HasTexture(textureParameter.Value)) { _textureParameters.Add(textureParameter.Key, resourceManager.GetTexture(textureParameter.Value)); } } }
public virtual void Load(IDataNode dataNode, IResourceManager resourceManager) { var shaderName = dataNode.ReadParameter("shader"); _shader = resourceManager.GetShader(shaderName); _name = dataNode.ReadParameter("key"); var textureParameters = new Dictionary<string, string>(); dataNode.ReadAllParameters(_vectorParameters, _numericParameters, textureParameters); foreach (var textureParameter in textureParameters) { if(resourceManager.HasTexture(textureParameter.Value)) _textureParameters.Add(textureParameter.Key, resourceManager.GetTexture(textureParameter.Value)); } }
public SimpleTexturedMaterial(IResourceManager rm, string textureName) { this.texture = rm.GetTexture(textureName); }