Ray struct, used to fire rays into a 3D scene to find out what we can
hit with that ray (for mouse picking and other simple collision stuff).
View code on GitHub
Namespace: DeltaEngine.DatatypesAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Ray type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Ray(String) | Initializes a new instance of the Ray class | |
Ray(Vector3D, Vector3D) | Initializes a new instance of the Ray class |
Methods
Name | Description | |
---|---|---|
Equals | ||
ToString | (Overrides ValueType ToString .) |
Fields
Name | Description | |
---|---|---|
Direction | ||
Origin |
Remarks
Examples
[Test] public void EqualityOfRay() { Assert.AreEqual(new Ray(Vector3D.UnitZ, Vector3D.One), new Ray(Vector3D.UnitZ, Vector3D.One)); Assert.AreNotEqual(new Ray(Vector3D.UnitX, Vector3D.One), new Ray(Vector3D.UnitZ, Vector3D.One)); Assert.AreNotEqual(new Ray(Vector3D.UnitZ, Vector3D.One), new Ray(Vector3D.UnitZ, Vector3D.One * 2)); }
[Test] public void CreateRay() { var ray = new Ray(Vector3D.Zero, Vector3D.UnitZ); Assert.AreEqual(ray.Origin, Vector3D.Zero); Assert.AreEqual(ray.Direction, Vector3D.UnitZ); }
[Test] public void CanConvertToStringAndBack() { var ray = new Ray(Vector3D.UnitX, Vector3D.UnitY); var stringRay = ray.ToString(); Assert.AreEqual("Ray({1, 0, 0},{0, 1, 0})", stringRay); var retrievedRay = new Ray(stringRay); Assert.AreEqual(ray.Origin, retrievedRay.Origin); Assert.AreEqual(ray.Direction, retrievedRay.Direction); }
See Also