// Constructors public ProgramMotionData(BINAReader reader) { MotionType = (MotionTypes)reader.ReadUInt32(); reader.JumpAhead(12); Axis = reader.ReadVector3(); reader.JumpAhead(4); Power = reader.ReadSingle(); SpeedScale = reader.ReadSingle(); Time = reader.ReadSingle(); reader.JumpAhead(4); }
public void MoveEntity(IEntity entity, Vector3 delta, MotionTypes motionTypes) { if (motionTypes.HasFlag(MotionTypes.Position)) { const int maxBlocks = 8; if (delta.LengthSquared() > maxBlocks * maxBlocks) { _networkClient.Send(new MessageClientEntityTeleport.Message( entity.Id, entity.Position, entity.Rotation, entity.Grounded )); } else { const int scale = short.MaxValue / maxBlocks; if (motionTypes.HasFlag(MotionTypes.Rotation)) { _networkClient.Send(new MessageClientEntityMoveRotate.Message( entity.Id, (short)(delta.X * scale), (short)(delta.Y * scale), (short)(delta.Z * scale), entity.Rotation, entity.Grounded )); } else { _networkClient.Send(new MessageClientEntityMove.Message( entity.Id, (short)(delta.X * scale), (short)(delta.Y * scale), (short)(delta.Z * scale), entity.Grounded )); } } } else if (motionTypes.HasFlag(MotionTypes.Rotation)) { _networkClient.Send(new MessageClientEntityRotate.Message( entity.Id, entity.Rotation, true )); } }
/// <summary> /// Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 . /// </summary> /// <param name="templateImage">single-channel template image; CV_8U or CV_32F array.</param> /// <param name="inputImage">single-channel input image which should be warped with the final warpMatrix in /// order to provide an image similar to templateImage, same type as templateImage.</param> /// <param name="warpMatrix">floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp).</param> /// <param name="motionType">parameter, specifying the type of motion</param> /// <param name="criteria">parameter, specifying the termination criteria of the ECC algorithm; /// criteria.epsilon defines the threshold of the increment in the correlation coefficient between two /// iterations(a negative criteria.epsilon makes criteria.maxcount the only termination criterion). /// Default values are shown in the declaration above.</param> /// <param name="inputMask">An optional mask to indicate valid values of inputImage.</param> /// <returns></returns> public static double FindTransformECC( InputArray templateImage, InputArray inputImage, InputOutputArray warpMatrix, MotionTypes motionType = MotionTypes.Affine, TermCriteria?criteria = null, InputArray?inputMask = null) { if (templateImage == null) { throw new ArgumentNullException(nameof(templateImage)); } if (inputImage == null) { throw new ArgumentNullException(nameof(inputImage)); } if (warpMatrix == null) { throw new ArgumentNullException(nameof(warpMatrix)); } templateImage.ThrowIfDisposed(); inputImage.ThrowIfDisposed(); warpMatrix.ThrowIfDisposed(); inputMask?.ThrowIfDisposed(); var criteriaValue = criteria.GetValueOrDefault(new TermCriteria(CriteriaType.Count | CriteriaType.Eps, 50, 0.001)); NativeMethods.HandleException( NativeMethods.video_findTransformECC2( templateImage.CvPtr, inputImage.CvPtr, warpMatrix.CvPtr, (int)motionType, criteriaValue, inputMask?.CvPtr ?? IntPtr.Zero, out var ret)); GC.KeepAlive(templateImage); GC.KeepAlive(inputImage); GC.KeepAlive(warpMatrix); GC.KeepAlive(inputMask); return(ret); }
/// <summary> /// Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 . /// </summary> /// <param name="templateImage">single-channel template image; CV_8U or CV_32F array.</param> /// <param name="inputImage">single-channel input image which should be warped with the final warpMatrix in /// order to provide an image similar to templateImage, same type as templateImage.</param> /// <param name="warpMatrix">floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp).</param> /// <param name="motionType">parameter, specifying the type of motion</param> /// <param name="criteria">parameter, specifying the termination criteria of the ECC algorithm; /// criteria.epsilon defines the threshold of the increment in the correlation coefficient between two /// iterations(a negative criteria.epsilon makes criteria.maxcount the only termination criterion). /// Default values are shown in the declaration above.</param> /// <param name="inputMask">An optional mask to indicate valid values of inputImage.</param> /// <param name="gaussFiltSize">An optional value indicating size of gaussian blur filter; (DEFAULT: 5)</param> /// <returns></returns> public static double FindTransformECC( InputArray templateImage, InputArray inputImage, InputOutputArray warpMatrix, MotionTypes motionType, TermCriteria criteria, InputArray?inputMask = null, int gaussFiltSize = 5) { if (templateImage == null) { throw new ArgumentNullException(nameof(templateImage)); } if (inputImage == null) { throw new ArgumentNullException(nameof(inputImage)); } if (warpMatrix == null) { throw new ArgumentNullException(nameof(warpMatrix)); } templateImage.ThrowIfDisposed(); inputImage.ThrowIfDisposed(); warpMatrix.ThrowIfDisposed(); inputMask?.ThrowIfDisposed(); NativeMethods.HandleException( NativeMethods.video_findTransformECC1( templateImage.CvPtr, inputImage.CvPtr, warpMatrix.CvPtr, (int)motionType, criteria, inputMask?.CvPtr ?? IntPtr.Zero, gaussFiltSize, out var ret)); GC.KeepAlive(templateImage); GC.KeepAlive(inputImage); GC.KeepAlive(warpMatrix); GC.KeepAlive(inputMask); return(ret); }