The principle of the helmet is very simple, roughly the use of two lenses, shorten the focal length of the eye, the two eyes can be seen into one another to create a dual-screen 3D effect.
So I began to imagine: since the 3D effect, in order to achieve a more immersive experience, why not the head of the movement also mapped to the virtual world? With this idea in mind, we have made the following attempt:
The head data (such as rotation angle, pitch angle, etc.) with the gyroscope received back to the computer, for the sake of simplicity, quick effect, direct mobile phone, and then wrote an app on the phone, responsible for using WiFi to send gyroscope data to pc,pc received data, I wrote a DLL, shared memory, constantly update that piece of memory , when the host program is used, just call that piece of data, the method is very simple.
I do not understand the Android client, so it was written by my classmates. I only say the C + + DLL code, for the sake of convenience I used a simple sender to simulate the gyroscope sent back data.
//Sender#include <iostream>#include<Windows.h>#include<tchar.h>#include<ctime>using namespacestd;structdatastruct{floatx; floaty; floatz;};#defineBuf_size 1024TCHAR szname[]=text ("Global\\myfilemappingobject");intMain () {HANDLE hmapfile; float*PBuf; Hmapfile=createfilemapping (Invalid_handle_value,NULL, Page_readwrite,0, Buf_size, SzName);if(Hmapfile = =NULL) {_tprintf (TEXT ("Could not create file mapping object (%d). \ n"), GetLastError ()); return 1; } PBuf= (float*) MapViewOfFile (hmapfile, File_map_all_access,0, 0, buf_size); if(PBuf = =NULL) {_tprintf (TEXT ("Could not map view of file (%d). \ n"), GetLastError ()); CloseHandle (Hmapfile); return 1; } while(1) { floats[3] = {1.0f,33.2f,12.3f}; size_t a=sizeof(s); Srand (Clock ()); *s = rand ()/(Double)(3.2); * (s+1) = rand ()/(Double)(3.2); * (s+2) = rand ()/(Double)(3.2);cout<<s[0]<<" "<<s[1]<<" "<<s[2]<<Endl; memcpy ((PVOID) PBuf, (void*) S,sizeof(s)); }}
Receive DLL code
#include <windows.h>#include<string.h>#include<string>#include<iostream>#include<tchar.h>#include"recevedate.h"using namespacestd;#defineBuf_size 1024TCHAR szname[]=text ("Global\\myfilemappingobject"); HANDLE Hmapfile;float*PBuf;intDll_data_init () {Hmapfile=createfilemapping (Invalid_handle_value,//Use paging fileNull//Default SecurityPage_readwrite,//read/write Access 0,//Maximum object size (High-order DWORD)Buf_size,//Maximum object size (Low-order DWORD)SzName);//Name of mapping object if(Hmapfile = =NULL) {_tprintf (TEXT ("Could not create file mapping object (%d). \ n"), GetLastError ()); return-1; } PBuf= (float*) MapViewOfFile (Hmapfile,//handle to map objectFile_map_all_access,//read/write Permission 0, 0, buf_size); if(PBuf = =NULL) {_tprintf (TEXT ("Could not map view of file (%d). \ n"), GetLastError ()); CloseHandle (Hmapfile); return-1; } return 0;}floatget_x () {returnpbuf[0];}floatget_y () {returnpbuf[1];}floatget_z () {returnpbuf[2];}floatGet_dx () {returnpbuf[3];}floatGet_dy () {returnpbuf[4];}floatGet_dz () {returnpbuf[5];}voidDll_data_ter () {unmapviewoffile (PBUF); CloseHandle (hmapfile);}
Initializes the call to the int dll_data_init () function, calls void dll_data_ter ()when exiting, and obtains the specified data directly in the middle.
usingUnityengine;usingSystem.Collections;usingSystem;usingSystem.Runtime.InteropServices; Public classDll:monobehaviour {[DllImport ("Daterecive.dll")] Public Static extern intDll_data_init (); [DllImport ("Daterecive.dll")] Public Static extern voidDll_data_ter (); [DllImport ("Daterecive.dll")] Public Static extern floatget_x (); [DllImport ("Daterecive.dll")] Public Static extern floatget_y (); [DllImport ("Daterecive.dll")] Public Static extern floatget_z (); //Use this for initialization voidStart () {dll_data_init (); } //Update is called once per frame voidUpdate () {//GetData (); } voidOnapplicationquit () {dll_data_ter (); }}
After initialization, these functions can be called, modify the camera code or other code.
A scene was processed in unity and the experiment was done:
The upper left corner is the data returned, because it is analog data, so it is not very real.
With this DLL, this system can be easily extended to a lot of game engine, I also did a similar attempt in the UE4.
As for the display, as long as the scene is dual screen:
Finally, the entire device is formed:
Relatively humble don't care about the details, it looks very good, but do not know how to show ...
A simple "virtual helmet" implementation