public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch) { // TODO: Rendering needs refactoring... a LOT. if (s_defaultTexture == null) s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white"); Texture2D myTexture = _spriteTextures[_spriteCurrentFrame]; if(myTexture == null) myTexture = s_defaultTexture; Vector2 screenPos = aCamera.WorldToScreen(Position); Vector2 screenSize = aCamera.WorldSizeToScreenSize(Size); Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y); aBatch.Begin(); aBatch.Draw(myTexture, destRect, null, Color, MathHelper.ToRadians(Rotation), new Vector2(myTexture.Width / 2, myTexture.Height / 2), SpriteEffects.None, 0.0f); aBatch.End(); }
public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch) { if (_particles == null) return; if (s_defaultTexture == null) s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white"); Texture2D myTexture = _spriteTextures[_spriteCurrentFrame]; if (myTexture == null) myTexture = s_defaultTexture; // Render all of our particles. aBatch.Begin(); for (int i = 0; i < _maxParticlesAlive; ++i) { if (_particles[i]._age < 0.0f) continue; Vector2 screenPos = aCamera.WorldToScreen(_particles[i]._pos); Vector2 currentSize = Size * _particles[i]._scale; Vector2 screenSize = aCamera.WorldSizeToScreenSize(currentSize); Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y); aBatch.Draw(myTexture, destRect, null, _particles[i]._color, _particles[i]._rotation, new Vector2(myTexture.Width / 2, myTexture.Height / 2), SpriteEffects.None, 0.0f); } aBatch.End(); }
public void Render(Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch) { if (HasChildren) { LHC.Render(aCamera, aDevice, aBatch); RHC.Render(aCamera, aDevice, aBatch); return; } if (SpatialGraphManager.Instance.DrawBlocked ) { if (Blocked) BBox.Render(new Color(1.0f, 0.0f, 0.0f, 0.25f), aCamera, aDevice, aBatch); } if (SpatialGraphManager.Instance.DrawBounds) { // TODO; Render Outline of a BBox } Vector2 centroid = BBox.Centroid(); if( SpatialGraphManager.Instance.DrawNodeIndex ) { Vector2 screenCenter = aCamera.WorldToScreen( centroid ); aBatch.Begin(); aBatch.DrawString(FontCache.Instance["ConsoleSmall"], Index.ToString(), screenCenter, new Color(0, 1, 1, 1)); aBatch.End(); } if( SpatialGraphManager.Instance.DrawGraph && !Blocked ) { if(s_Effect == null) { s_Effect = new BasicEffect(aDevice, null); s_Effect.VertexColorEnabled = true; s_Effect.World = Matrix.Identity; } List<VertexPositionColor> lineList = new List<VertexPositionColor>(); for( int i = 0; i < Neighbors.Count; i++ ) { if( Neighbors[i].Blocked || !NeighborLOS[i] ) continue; //Draw lines Vector2 neighbor = Neighbors[i].BBox.Centroid(); neighbor = centroid + ((neighbor - centroid) * 0.6f); lineList.Add(new VertexPositionColor( new Vector3(centroid.X, centroid.Y, 0.0f), Color.Red)); lineList.Add(new VertexPositionColor( new Vector3(neighbor.X, neighbor.Y, 0.0f), Color.Red)); } VertexPositionColor[] lineArray = lineList.ToArray(); s_Effect.View = aCamera.View; s_Effect.Projection = aCamera.Projection; s_Effect.Begin(); for (int i = 0; i < s_Effect.CurrentTechnique.Passes.Count; ++i) { s_Effect.CurrentTechnique.Passes[i].Begin(); aDevice.VertexDeclaration = new VertexDeclaration(aDevice, VertexPositionColor.VertexElements); aDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, lineArray, 0, lineArray.Length / 2); s_Effect.CurrentTechnique.Passes[i].End(); } s_Effect.End(); } if( SpatialGraphManager.Instance.DrawGridPoints ) { if (s_defaultTexture == null) s_defaultTexture = Angel.World.Instance.Game.Content.Load<Texture2D>("white"); Color pointColor = Color.Red; List<Vector2> gridPoints; int xPoints, yPoints; GetGridPoints(out gridPoints, out xPoints, out yPoints); aBatch.Begin(); for( int i = 0; i < gridPoints.Count; i++ ) { Vector2 screenLoc = aCamera.WorldToScreen(gridPoints[i]); Rectangle rect = new Rectangle((int)screenLoc.X, (int)screenLoc.Y, 5, 5); aBatch.Draw(s_defaultTexture, rect, pointColor); } aBatch.End(); } }
public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch) { // TODO: FIX ME!!! Doing this just to test text rendering for now. SpriteFont font = FontCache.Instance[Font]; aBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); for (int i = 0; i < _displayStrings.Length; i++) { Vector2 position = aCamera.WorldToScreen(_displayStrings[i]._position); aBatch.DrawString(font, _displayStrings[i]._string, position, this.Color); } aBatch.End(); }
public void Render(Color aColor, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch) { if (s_defaultTexture == null) s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white"); Vector2 screenPos = aCamera.WorldToScreen(Centroid()); Vector2 screenSize = aCamera.WorldSizeToScreenSize(Max - Min); Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y); aBatch.Begin(); aBatch.Draw(s_defaultTexture, destRect, null, aColor, 0.0f, new Vector2(s_defaultTexture.Width / 2, s_defaultTexture.Height / 2), SpriteEffects.None, 0.0f); aBatch.End(); }