CHAPTER 4 ■ WORKING WITH MODELS
327
protected override void Draw(GameTime gameTime)
{
//define World matrices
float time = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;
Matrix worldM1 = Matrix.CreateScale(0.01f) *
➥
Matrix.CreateRotationY(MathHelper.PiOver2) * ➥
Matrix.CreateTranslation(-10, 0, 0);
Matrix worldM2 = Matrix.CreateScale(0.01f) *
➥
Matrix.CreateRotationY(-MathHelper.PiOver2) * ➥
Matrix.CreateTranslation(10, 3, 0);
worldM2 = worldM2 * Matrix.CreateTranslation(-time * 3.0f, 0, 0);
//check for collision
if (FinerCheck(myModel, worldM1, myModel, worldM2))
{
Window.Title = "Collision!!";
device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer,
➥
Color.Red, 1, 0);
}
else
{
Window.Title = "No collision ...";
device.Clear(ClearOptions.Target ...