public virtual void DrawOverModel(RenderContext context, GameModel model) { var camera = context.Camera; Vector3 center = context.GraphicsDevice.Viewport.Project(new Vector3(model.Position,0), camera.Projection, camera.View, Matrix.Identity); Position = new Vector2(center.X - Width/2, center.Y - Height/2); context.SpriteBatch.Begin(); context.SpriteBatch.Draw(m_Texture, Position, DrawRect, new Color(Color.R, Color.G, Color.B, 1.0f), MathHelper.ToRadians(Rotation), Vector2.Zero, ObjectScale, Effect, 1); context.SpriteBatch.End(); context.Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
public void Update(float dt,RenderContext context,GameModel model) { //Project onto a model var camera = context.Camera; Vector3 center = context.GraphicsDevice.Viewport.Project(new Vector3(model.Position, 0), camera.Projection, camera.View, Matrix.Identity); Position = new Vector2(center.X, center.Y); Velocity += Acceleration * dt; Position += Velocity * dt; //Position.Y += 120 * dt; Rotation += RotSpeed * dt; TimeSinceStart += dt; }
/// <summary> /// overriden from DrawableGameComponent, Update will update all of the active /// particles. /// </summary> /// public void SetProjectionSettings(RenderContext context, GameModel model) { m_RenderContext = context; m_Model = model; }
protected void RemoveChild(GameModel child) { m_Child.Remove(child); child = null; }
protected void AddChild(GameModel child) { if (child != null) m_Child.Add(child); }