#region File Description
//-----------------------------------------------------------------------------
// CollideRay.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#endregion
namespace RobotGameData.Collision
{
///
/// It's a collision ray.
///
public class CollideRay : CollideElement
{
#region Fields
///
/// local position of the bounding ray
///
protected Vector3 localPosition = Vector3.Zero;
///
/// local direction of the bounding ray
///
protected Vector3 localDirection = Vector3.Zero;
///
/// Bounding ray
///
protected Ray ray;
#endregion
#region Properties
public Ray Ray
{
get { return ray; }
}
#endregion
///
/// Constructor.
///
/// position of the ray
/// direction of the ray
public CollideRay(Vector3 position, Vector3 direction)
: base()
{
localPosition = position;
localDirection = direction;
ray = new Ray(localPosition, localDirection);
}
///
/// Set to new transform matrix.
///
public override void Transform(Matrix matrix)
{
ray.Position = Vector3.Transform(localPosition, matrix);
ray.Direction = Vector3.Transform(localDirection, matrix);
ray.Direction.Normalize();
base.Transform(matrix);
}
}
}