using System;
using System.Collections.Generic;
using System.Text;
namespace UnityEngine.XR.ARFoundation
{
///
/// A structure for camera-related information pertaining to a particular frame.
/// This is used to communicate information in the event.
///
public struct ARCameraFrameEventArgs : IEquatable
{
///
/// The associated with this frame.
///
public ARLightEstimationData lightEstimation { get; set; }
///
/// The time, in nanoseconds, associated with this frame.
/// Use timestampNs.HasValue to determine if this data is available.
///
public long? timestampNs { get; set; }
///
/// Gets or sets the projection matrix for the AR Camera. Use
/// projectionMatrix.HasValue to determine if this data is available.
///
public Matrix4x4? projectionMatrix { get; set; }
///
/// Gets or sets the display matrix for use in the shader used
/// by the .
/// Use displayMatrix.HasValue to determine if this data is available.
///
public Matrix4x4? displayMatrix { get; set; }
///
/// The textures associated with this camera frame. These are generally
/// external textures, which exist only on the GPU. To use them on the
/// CPU, e.g., for computer vision processing, you will need to read
/// them back from the GPU.
///
public List textures { get; set; }
///
/// Ids of the property name associated with each texture. This is a
/// parallel List to the list.
///
public List propertyNameIds { get; set; }
///
/// The exposure duration in seconds with sub-millisecond precision. Used in calculating motion blur.
///
///
/// can be null if platform does not support exposure duration.
///
public double? exposureDuration { get; set; }
///
/// The offset of camera exposure. Used to scale scene lighting in post-processed lighting stage.
///
///
/// can be null if platform does not support exposure offset.
///
public float? exposureOffset { get; set; }
///
/// The list of keywords to be enabled for the material.
///
public List enabledMaterialKeywords { get; internal set; }
///
/// The list of keywords to be disabled for the material.
///
public List disabledMaterialKeywords { get; internal set; }
///
/// The camera grain texture effect.
///
public Texture cameraGrainTexture { get; internal set; }
///
/// The camera grain noise intensity.
///
public float noiseIntensity { get; internal set; }
///
/// Generates a hash suitable for use with containers like `HashSet` and `Dictionary`.
///
/// A hash code generated from this object's fields.
public override int GetHashCode()
{
unchecked
{
var hash = lightEstimation.GetHashCode();
hash = hash * 486187739 + timestampNs.GetHashCode();
hash = hash * 486187739 + projectionMatrix.GetHashCode();
hash = hash * 486187739 + displayMatrix.GetHashCode();
hash = hash * 486187739 + HashCodeUtil.ReferenceHash(textures);
hash = hash * 486187739 + HashCodeUtil.ReferenceHash(propertyNameIds);
hash = hash * 486187739 + exposureDuration.GetHashCode();
hash = hash * 486187739 + exposureOffset.GetHashCode();
hash = hash * 486187739 + cameraGrainTexture.GetHashCode();
hash = hash * 486187739 + noiseIntensity.GetHashCode();
hash = hash * 486187739 + (enabledMaterialKeywords == null ? 0 : enabledMaterialKeywords.GetHashCode());
hash = hash * 486187739 + (disabledMaterialKeywords == null ? 0 : disabledMaterialKeywords.GetHashCode());
return hash;
}
}
///
/// Tests for equality.
///
/// The `object` to compare against.
/// `True` if is of type and
/// also returns `true`; otherwise `false`.
public override bool Equals(object obj)
=> (obj is ARCameraFrameEventArgs) && Equals((ARCameraFrameEventArgs)obj);
///
/// Generates a string representation of this struct suitable for debug
/// logging.
///
/// A string representation of this struct suitable for debug
/// logging.
public override string ToString()
{
var stringBuilder = new StringBuilder();
stringBuilder.Append("lightEstimation: " + lightEstimation.ToString());
stringBuilder.Append("\ntimestamp: " + timestampNs);
if (timestampNs.HasValue)
stringBuilder.Append("ns");
stringBuilder.Append("\nprojectionMatrix: " + projectionMatrix);
stringBuilder.Append("\ndisplayMatrix: " + displayMatrix);
stringBuilder.Append("\ntexture count: " + (textures == null ? 0 : textures.Count));
stringBuilder.Append("\npropertyNameId count: " + (propertyNameIds == null ? 0 : propertyNameIds.Count));
return stringBuilder.ToString();
}
///
/// Tests for equality.
///
/// The other to compare against.
/// `True` if every field in is equal to this , otherwise false.
public bool Equals(ARCameraFrameEventArgs other)
{
return
lightEstimation.Equals(other.lightEstimation)
&& timestampNs == other.timestampNs
&& projectionMatrix == other.projectionMatrix
&& displayMatrix == other.displayMatrix
&& ((textures == null) ? (other.textures == null) : textures.Equals(other.textures))
&& ((propertyNameIds == null) ? (other.propertyNameIds == null)
: propertyNameIds.Equals(other.propertyNameIds))
&& (exposureDuration == other.exposureDuration)
&& (exposureOffset == other.exposureOffset)
&& (cameraGrainTexture == other.cameraGrainTexture)
&& (noiseIntensity == other.noiseIntensity)
&& ((enabledMaterialKeywords == null) ? (other.enabledMaterialKeywords == null)
: enabledMaterialKeywords.Equals(other.enabledMaterialKeywords))
&& ((disabledMaterialKeywords == null) ? (other.disabledMaterialKeywords == null)
: disabledMaterialKeywords.Equals(other.disabledMaterialKeywords));
}
///
/// Tests for equality. Same as .
///
/// The left-hand side of the comparison.
/// The right-hand side of the comparison.
/// `True` if is equal to , otherwise `false`.
public static bool operator ==(ARCameraFrameEventArgs lhs, ARCameraFrameEventArgs rhs) => lhs.Equals(rhs);
///
/// Tests for inequality. Same as `!`.
///
/// The left-hand side of the comparison.
/// The right-hand side of the comparison.
/// `True` if is not equal to , otherwise `false`.
public static bool operator !=(ARCameraFrameEventArgs lhs, ARCameraFrameEventArgs rhs) => !lhs.Equals(rhs);
}
}