Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO.MemoryMappedFiles;
- using System.Runtime.InteropServices;
- using System.Threading;
- namespace FakeFreeTrack
- {
- [StructLayout(LayoutKind.Sequential)]
- public struct TFreeTrackData
- {
- public int DataID;
- public int CamWidth;
- public int CamHeight;
- // virtual pose
- public float Yaw; // positive yaw to the left
- public float Pitch; // positive pitch up
- public float Roll; // positive roll to the left
- public float X;
- public float Y;
- public float Z;
- // raw pose with no smoothing, sensitivity, response curve etc.
- public float RawYaw;
- public float RawPitch;
- public float RawRoll;
- public float RawX;
- public float RawY;
- public float RawZ;
- // raw points, sorted by Y, origin top left corner
- public float X1;
- public float Y1;
- public float X2;
- public float Y2;
- public float X3;
- public float Y3;
- public float X4;
- public float Y4;
- };
- class Program
- {
- static void Main(string[] args)
- {
- var random = new Random();
- var count = 0;
- using (var memoryMappedFile = MemoryMappedFile.CreateOrOpen("FT_SharedMem", Marshal.SizeOf(typeof(TFreeTrackData))))
- {
- using (var accessor = memoryMappedFile.CreateViewAccessor())
- {
- while (true)
- {
- count++;
- TFreeTrackData model = new TFreeTrackData();
- model.DataID = count;
- model.CamWidth = 320;
- model.CamHeight = 240;
- model.Yaw = random.Next(0, 120) / (float)(180.0 / Math.PI);
- accessor.Write(0, ref model);
- Thread.Sleep(5);
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment