Forum Discussion
skavee
11 years agoExplorer
[Help] Cloning window to the Rift and adding distortion
Hi there,
Background:
I'm very new to 3D Programming and I'm currently implementing Rift support for the Car Simulator we have at our institute at university. (This would be my Bachelor Thesis). The main function of this simulator is to test control engineering systems and it provides the graphical display as a added feature. A user can freely move the camera around the whole landscape where the car is driving in addition to features like fixing the camera to a inside view of the car.
The simulator Software already exists and was not programmed by us. However I managed to get some info about how rendering is done and they are using a combination of this TCL - Skript language (probably because of the control sys part) and an OpenGL - TCL extension.
What I have:
The (beauty) is that I can *fairly* simple add features to the simulator by loading an additional TCL script on startup. What I have done is write a .DLL that wraps the Rift functionality (for sensor data) and gets loaded when the display window is opened. This TCL script then periodically calls a function on that .DLL that returns the current yaw,pitch,roll, and x,y,z-Offsets of the Rift.
The function is this one:
https://github.com/myzb/OculusVr-CmDLL/blob/master/OculusVr-CmDLL/OculusVr-CmDLL.cpp#L70
(you can find the rest of the project files there aswell)
With this information the Simulator creates a split window view with a specified eye separation and orients the camera accordingly. So basically the simulator polls for sensor data calling "tclovrGetData" using the .DLL and then orients the view. The TCL code that does this looks like this:
The result looks like this:
https://www.youtube.com/watch?v=hrt8z-8O3sU
To get the image back to the Rift I basically tell the simulator to send the window to "monitor 2" which is the Rift. Now as you can imagine that image is missing all the distortion adjustments.
What I want:
Now ideally, I'd like in the end to have the .DLL adjust the camera orientation according to the sensor information, add the distortion and remove the above TCL outtake from the TCL.
I've tried to use the OculusRoomTiny as knowledgebase but if I do understand things right I don't need to render the scene because it is already on the window. How I see it I *only* have to:
Now my questions:
1. Would I need any other information regarding the graphic data from the simulator, to have my Rift-.DLL manipulate the orientation or are the matrix operations on "<window-name>" enough? I know there is this "FindWindow function" I could use: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx
Remeber that since I'm loading a .DLL I have already attached the Rift to the Simulator Windows-process and could therefore call "functions" to get the missing data...?
2. To add distortion I only would need to call this?
But What about the textures? I mean I already have them on screen, like in the video.
I hope I have managed to mention all the relevant information and that I could express myself good enough ;) I hope I'm not completely shooting into the dark here and would be greatful if someone could point me into the right direction and if it is possible to do at all without intervening into the simulator code.
Best regards,
~skaa
Background:
I'm very new to 3D Programming and I'm currently implementing Rift support for the Car Simulator we have at our institute at university. (This would be my Bachelor Thesis). The main function of this simulator is to test control engineering systems and it provides the graphical display as a added feature. A user can freely move the camera around the whole landscape where the car is driving in addition to features like fixing the camera to a inside view of the car.
The simulator Software already exists and was not programmed by us. However I managed to get some info about how rendering is done and they are using a combination of this TCL - Skript language (probably because of the control sys part) and an OpenGL - TCL extension.
What I have:
The (beauty) is that I can *fairly* simple add features to the simulator by loading an additional TCL script on startup. What I have done is write a .DLL that wraps the Rift functionality (for sensor data) and gets loaded when the display window is opened. This TCL script then periodically calls a function on that .DLL that returns the current yaw,pitch,roll, and x,y,z-Offsets of the Rift.
The function is this one:
https://github.com/myzb/OculusVr-CmDLL/blob/master/OculusVr-CmDLL/OculusVr-CmDLL.cpp#L70
(you can find the rest of the project files there aswell)
With this information the Simulator creates a split window view with a specified eye separation and orients the camera accordingly. So basically the simulator polls for sensor data calling "tclovrGetData" using the .DLL and then orients the view. The TCL code that does this looks like this:
gl pushmatrix
gl loadidentity
gl translate $x $y $z
gl rotate $xrot 1 0 0
gl rotate $yrot 0 1 0
gl rotate $zrot 0 0 1
gl translate $offx $offy $offz
lassign [lrange [OGL get modelviewmatrix] 12 14] tx ty tz
gl popmatrix
The result looks like this:
https://www.youtube.com/watch?v=hrt8z-8O3sU
To get the image back to the Rift I basically tell the simulator to send the window to "monitor 2" which is the Rift. Now as you can imagine that image is missing all the distortion adjustments.
What I want:
Now ideally, I'd like in the end to have the .DLL adjust the camera orientation according to the sensor information, add the distortion and remove the above TCL outtake from the TCL.
I've tried to use the OculusRoomTiny as knowledgebase but if I do understand things right I don't need to render the scene because it is already on the window. How I see it I *only* have to:
[PSEUDOCODE]
// Initialization()
// sensor init already present in the project
add missing initalization to support video
attach Rift to Window named: "CarMaker View 1"
// RenderingLoop()
// Move the above Matrix opeartions into the rendering loop
add the distortions
end
Now my questions:
1. Would I need any other information regarding the graphic data from the simulator, to have my Rift-.DLL manipulate the orientation or are the matrix operations on "<window-name>" enough? I know there is this "FindWindow function" I could use: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx
Remeber that since I'm loading a .DLL I have already attached the Rift to the Simulator Windows-process and could therefore call "functions" to get the missing data...?
2. To add distortion I only would need to call this?
// Let OVR do distortion rendering, Present and flush/sync.
ovrHmd_EndFrame(hmd, headPose, eyeTextures);
But What about the textures? I mean I already have them on screen, like in the video.
I hope I have managed to mention all the relevant information and that I could express myself good enough ;) I hope I'm not completely shooting into the dark here and would be greatful if someone could point me into the right direction and if it is possible to do at all without intervening into the simulator code.
Best regards,
~skaa
No RepliesBe the first to reply
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 1 month ago
- 1 month ago
- 9 months ago