A Pretty Rifty Cheetah
by Michael Reino · in Torque 3D Professional · 12/19/2013 (11:06 am) · 10 replies
I have created a GitHub branch with changes that allow mounting the cheetah while using the Oculus Rift. This is my first attempt at using GutHub, so I hope I did things right. I followed the Tutorial as closely as I could. This is not ready to become a pull request. I'm posting in hopes of getting some people to test and give some feedback so it can be polished up and become worthy of a pull request.
You can get it here: github.com/OTHGMars/Torque3D/tree/rift_mounting
The engine crash when mounting vehicles was corrected by replacing some Move pointers with ExtendedMove pointers. I also added some code so that the absolute rotations from the ExtendedMove would be used in the vehicle classes. I really wasn't sure if the head rotation should affect the pitch and yaw of the vehicle or should affect just the camera rotation. I implemented and tested both. While it was a lot of fun to steer with my head, I prefer to be able to look around while driving straight. There are 2 defines at the top of vehicle.h (EM_ABSPY_STEERSVEHICLE
and EM_ABSPYR_TURNSCAMERA) uncomment one or the other depending on your preferred control method. EM_ABSPYR_TURNSCAMERA is used as built.
I also committed some files to make it easier to test. None of these changes are required and should not be included if this becomes a pull request.
art/datablocks/vehicles/cheetahCar.cs added cameraCanBank = true so when using the rotations to change the camera, you get the roll as well as pitch and yaw.
scripts/client/default.bind.cs Added some keybinds to switch from the standard PlayGui to HudlessPlayGui in stereo rendering mode. Ctrl-R toggles the rift view so you don't need to open the console and type the commands. I also uncommented the vehicle map toggleFirstPerson (tab) bind so you can drive in first person view while looking around. Sure would be nice to have a better node position for that, but you can get the effect. I also included a compiled release build and added a cheetah to Empty Terrain.mis so those that want to see it work before compiling or checking out the changes can do so.
To build with the project manager, select Full template, Extended Move Class, Torque physics and OVR SDK.
If you try this out, please let me know how it worked for you and what you would like to see improved. Thanks.
You can get it here: github.com/OTHGMars/Torque3D/tree/rift_mounting
The engine crash when mounting vehicles was corrected by replacing some Move pointers with ExtendedMove pointers. I also added some code so that the absolute rotations from the ExtendedMove would be used in the vehicle classes. I really wasn't sure if the head rotation should affect the pitch and yaw of the vehicle or should affect just the camera rotation. I implemented and tested both. While it was a lot of fun to steer with my head, I prefer to be able to look around while driving straight. There are 2 defines at the top of vehicle.h (EM_ABSPY_STEERSVEHICLE
and EM_ABSPYR_TURNSCAMERA) uncomment one or the other depending on your preferred control method. EM_ABSPYR_TURNSCAMERA is used as built.
I also committed some files to make it easier to test. None of these changes are required and should not be included if this becomes a pull request.
art/datablocks/vehicles/cheetahCar.cs added cameraCanBank = true so when using the rotations to change the camera, you get the roll as well as pitch and yaw.
scripts/client/default.bind.cs Added some keybinds to switch from the standard PlayGui to HudlessPlayGui in stereo rendering mode. Ctrl-R toggles the rift view so you don't need to open the console and type the commands. I also uncommented the vehicle map toggleFirstPerson (tab) bind so you can drive in first person view while looking around. Sure would be nice to have a better node position for that, but you can get the effect. I also included a compiled release build and added a cheetah to Empty Terrain.mis so those that want to see it work before compiling or checking out the changes can do so.
To build with the project manager, select Full template, Extended Move Class, Torque physics and OVR SDK.
If you try this out, please let me know how it worked for you and what you would like to see improved. Thanks.
About the author
Recent Threads
#2
So I am now able to hop into a shuttle or turret when using the Rift, however there is no head tracking when in the vehicle. Head tracking continues to work great in the rest of the game though.
Made sure I added the cameraCanBank=true line to all the vehicle datablocks, and that cameraroll was set to false as well like in the Cheetah example.
At this point I'm just happy to not be crashing, and it's great being able to fly around in the Rift now, but it would be awesome to be able to look around when in third person view.
Any ideas of what I may have missed?
Thanks again
P
12/19/2013 (9:52 pm)
Wow, this stopped the crash, thank you!!So I am now able to hop into a shuttle or turret when using the Rift, however there is no head tracking when in the vehicle. Head tracking continues to work great in the rest of the game though.
Made sure I added the cameraCanBank=true line to all the vehicle datablocks, and that cameraroll was set to false as well like in the Cheetah example.
At this point I'm just happy to not be crashing, and it's great being able to fly around in the Rift now, but it would be awesome to be able to look around when in third person view.
Any ideas of what I may have missed?
Thanks again
P
#3
What class does your shuttle derive from? If it's one of the vehicle classes, I'm surprised the head tracking is not working, Is it working in the Cheetah for you? One thing that threw me off for a while was forgetting to add the bind to the vehicle move map.
vehicleMap.bind( oculusvr, ovr_sensorrotang0, OVRSensorRotEuler );
Your statement "but it would be awesome to be able to look around when in third person view" has me wondering, Is that something that should be an option: The ability to have it automatically toggle between having the head turn the vehicle when in 1st person view and the camera when in 3rd person view?
12/20/2013 (3:15 am)
I've never worked with TurretShape. They derive from Item and not Vehicle, so the tracking changes made to vehicle steering and camera transform would not be available there. From looking at the class, it should be a pretty straight forward change, but brings up the issue of duplicating code. Player, Vehicle and Item all derive from ShapeBase, but all use the move very differently. My changes are largely just copied from the changes Dave Wyand made to the Player class. Is there a resource somewhere with a working example of a mountable turret? I'd be happy to update my branch with a fix for that if I had a means to test it.What class does your shuttle derive from? If it's one of the vehicle classes, I'm surprised the head tracking is not working, Is it working in the Cheetah for you? One thing that threw me off for a while was forgetting to add the bind to the vehicle move map.
vehicleMap.bind( oculusvr, ovr_sensorrotang0, OVRSensorRotEuler );
Your statement "but it would be awesome to be able to look around when in third person view" has me wondering, Is that something that should be an option: The ability to have it automatically toggle between having the head turn the vehicle when in 1st person view and the camera when in 3rd person view?
#4
Oooh, that would be really something, good idea!
As for our shuttle class, it derives from FlyingVehicle I think - but that in turn derives from vehicle which is where the changes have been made... I just figured they would cascade down to all vehicles.
But I did not have anything in the vehiclemap.bind for this, so perhaps that will fix it, thanks for the tip!
Regarding the turret - we are using Paul Dana's turret resource, and have some AI turrets and one that can be mounted by the player just for fun (an enemy fighter appears when you mount the turret and you get to try and blast it out of the sky). It's not really a key part of the game, so no biggy if we can't get the head tracking to work on that... But I would really like to get it working when mounted in the FlyingVehicle.
Will keep plugging away and will post back when I figure more out.
Cheers
P
12/20/2013 (10:56 am)
Quote:
Your statement "but it would be awesome to be able to look around when in third person view" has me wondering, Is that something that should be an option: The ability to have it automatically toggle between having the head turn the vehicle when in 1st person view and the camera when in 3rd person view?
Oooh, that would be really something, good idea!
As for our shuttle class, it derives from FlyingVehicle I think - but that in turn derives from vehicle which is where the changes have been made... I just figured they would cascade down to all vehicles.
But I did not have anything in the vehiclemap.bind for this, so perhaps that will fix it, thanks for the tip!
Regarding the turret - we are using Paul Dana's turret resource, and have some AI turrets and one that can be mounted by the player just for fun (an enemy fighter appears when you mount the turret and you get to try and blast it out of the sky). It's not really a key part of the game, so no biggy if we can't get the head tracking to work on that... But I would really like to get it working when mounted in the FlyingVehicle.
Will keep plugging away and will post back when I figure more out.
Cheers
P
#5
12/26/2013 (7:20 am)
I committed a couple changes. I fixed two places I missed changing the initialization of a move pointer from NullMove to NullExtendedMove. These could cause debug assertions in the packUpdate calls for vehicles. I also removed the defines for selecting the tracking mode and replaced with two datablock fields. There is a setting for first person and third person view. So if you want the absolute rotations to turn the vehicle in first person and the camera in third person, that can be set through the datablock now.
#7
www.garagegames.com/community/blogs/view/22570
01/28/2014 (9:34 am)
Just posted a blog about our trials and tribulations with integrating the Oculus Rift, check it out:www.garagegames.com/community/blogs/view/22570
#8
I am on a new laptop so i'm not sure if it's me or the code changes
02/09/2014 (5:29 pm)
I've just tried to add this to a new T3D and it doesn't seem to work and still crashes it was working on a previous build before the changes made for the datablock fields.I am on a new laptop so i'm not sure if it's me or the code changes
#9
02/10/2014 (10:39 pm)
@NiN-NiN I've made a lot of game-specific changes to the rift code so I haven't worked with that build in weeks, but I did compile and test it on two different systems (1 was a laptop). Paul Weston is the only person I know of that's tried the code and I don't know if he had to make any changes to get it to run. I would be happy to help you work out whatever problem you're having with it. You can contact me via the email in my profile if you'd like.
#10
But we are working off T3D MIT 3.0 which we find really solid... Did not test in latest 3.5. Although I did add in the 3.5 fixes into our build that related to the Rift, so maybe that's contributing to our results being different than yours?
FYI - was unable to get Camera head tracking working in 3rd person, probably due to using AFX camera... So we have 3rd person head tracking set to control Vehicle... But Camera in 1st person works great, can look around inside our shuttle vehicle while we fly, really nice!
02/11/2014 (6:29 am)
I didn't have to alter any code, it all worked great :)But we are working off T3D MIT 3.0 which we find really solid... Did not test in latest 3.5. Although I did add in the 3.5 fixes into our build that related to the Rift, so maybe that's contributing to our results being different than yours?
FYI - was unable to get Camera head tracking working in 3rd person, probably due to using AFX camera... So we have 3rd person head tracking set to control Vehicle... But Camera in 1st person works great, can look around inside our shuttle vehicle while we fly, really nice!
NiN-NiN
Thank you for the fix and the time you spent on this it's fantastic to be able to drive while in a car in the rift I can't wait :D