rendered paste bodyusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall.Graphics;
using Microsoft.Xna.Framework.Graphics;
using FlatRedBall;
using Microsoft.Xna.Framework;
namespace FlatRedBallXnaTemplate1
{
public class SpriteBatchDrawableBatch : IDrawableBatch
{
SpriteBatch mSpriteBatch;
Texture2D mTexture;
public float X
{
get;
set;
}
public float Y
{
get;
set;
}
public float Z
{
get;
set;
}
public SpriteBatchDrawableBatch()
{
mSpriteBatch = new SpriteBatch(FlatRedBallServices.GraphicsDevice);
mTexture = FlatRedBallServices.Load<Texture2D>("redball.bmp", "Content Manager Name");
}
public bool UpdateEveryFrame
{
get { return true; }
}
public void Draw(FlatRedBall.Camera camera)
{
Vector3 cameraPosition = camera.Position;
int width = camera.DestinationRectangle.Width;
int height = camera.DestinationRectangle.Height;
cameraPosition.X *= width/2.0f;
cameraPosition.Y *= height/2.0f;
cameraPosition.Y *= -1;
Matrix projection = Matrix.CreatePerspectiveFieldOfView(
camera.FieldOfView,
camera.AspectRatio,
camera.NearClipPlane,
camera.FarClipPlane);
Vector3 cameraTarget = cameraPosition + camera.RotationMatrix.Forward;
Vector3 tempUpVector = camera.RotationMatrix.Up;
Matrix lookAt = Matrix.CreateLookAt(
cameraPosition, // Position of the camera eye
cameraTarget, // Point that the eye is looking at
tempUpVector);
Matrix viewProjection;
Matrix.Multiply(ref lookAt, ref projection, out viewProjection);
mSpriteBatch.Begin(SpriteBlendMode.None,
SpriteSortMode.Immediate,
SaveStateMode.SaveState,
viewProjection
);
Rectangle destination = new Rectangle( (int)(.225 * -width), (int)(.293 * -height), width, height);
mSpriteBatch.Draw(mTexture, destination, Color.White);
mSpriteBatch.End();
}
public void Update()
{
}
public void Destroy()
{
}
}
}