Exemple #1
0
		/// <summary>
		/// Position and rotation report
		/// </summary>
		/// <param name="rep">The report of the device</param>
		/// <description>Applies the new postition and rotation to the GameObject</description>
		public void ReportButtons(VRPNButtonReport brep){

				
			//Debug.Log (brep.button + " " + brep.state);
			          
				if(brep.button == 0 && brep.state == 1)
				{
					
					button0 = true;
				}
				
				if(brep.button == 0 && brep.state == 0)
				{
					
					button0 = false;
				}
				
				if(brep.button == 1 && brep.state == 1)
				{
					
					button1 = true;
				}
				
				if(brep.button == 1 && brep.state == 0)
				{
					
					button1 = false;
				}
				
				
				
				
			
		}
Exemple #2
0
		/// <summary>
		/// Reports initialisation
		/// </summary>
		/// <description>Initialiation and allocation of the memory for reports. The process involves Marshaling, in order to exchange data between Unity and the C++ VRPN wrapper</description>
		protected void initializeReports ()
		{

			reports = new IntPtr[maxNumberOfReports];
			bReports = new IntPtr[maxNumberOfReports];
			VRPNReport report = new VRPNReport();
			VRPNButtonReport bReport = new VRPNButtonReport();
			
			report.sensor = 0;
			report.pos = new double[3];
			report.quat = new double[4];
			report.quat[3] = 1.0f;
			bReport.button = 0;
			bReport.state = 0;
			
			
			for(int i = 0; i < maxNumberOfReports; i++)
			{
				//Allocation of the memory
				reports[i] = Marshal.AllocHGlobal(Marshal.SizeOf (typeof(VRPNReport)));
				// Copy the report struct to unmanaged memory (reports array)
				Marshal.StructureToPtr(report, reports[i], true);

				//Allocation of the memory
				bReports[i] = Marshal.AllocHGlobal(Marshal.SizeOf (typeof(VRPNButtonReport)));
				// Copy the report struct to unmanaged memory (reports array)
				Marshal.StructureToPtr(bReport, bReports[i], true);
				
				
				
			}
			
			trackReport = Marshal.AllocHGlobal(Marshal.SizeOf (typeof(VRPNReport)));
			Marshal.StructureToPtr (report, trackReport, true);
			
			
			velReport = Marshal.AllocHGlobal(Marshal.SizeOf (typeof(VRPNReport)));
			Marshal.StructureToPtr (report, velReport, true);
		}