tbgeorge Posted July 22, 2016 Share Posted July 22, 2016 Hello, I'm trying to use a Device Orientation Camera for a game. I want it to be looking in a specific direction in the game every time you start the game, regardless of your real world rotation. But whenever I start the game, the camera immediately rotates to where I'm looking in the real world instead of starting up looking in my starting direction. I know this must be pretty confusing, but hopefully someone can understand it and help me out. Thanks Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 22, 2016 Share Posted July 22, 2016 (edited) Something like: Settimeout {scene.activeCamera.attatchControl},100000000} :).http://doc.babylonjs.com/tutorials/Camerashttps://doc.babylonjs.com/tutorials/Customizing_Camera_Inputs Instead of Settimeout:http://doc.babylonjs.com/overviews/Observables Edited July 22, 2016 by Nabroski Quote Link to comment Share on other sites More sharing options...
tbgeorge Posted July 22, 2016 Author Share Posted July 22, 2016 (edited) That works until the timeout hits, then the camera just snaps to where it wants to be. I need to be able to get this functionality: psuedocode: DeviceCam.setTarget( Vec3( 0, 1, 0 ) ); and have the camera look in that direction as soon as the app starts up and any movements after that are all based off of that direction. With setTimeout, the camera is looking in that direction until the timeout is done, then it snaps to where the device orientation thinks it's looking. Basically, I need to be able to set the initial direction for the DeviceOrientationCamera and not have the input manager change it to something drastically different as soon as I attach control. I have this scene: http://client.elementxcreative.com/bjs/DeviceOrientation/index.html I have exported it from unity with the camera facing the set of 4 cubes, though when you load the game in various different phone orientations it's looking at various different sets of cubes. ( FYI, there are 4 sets of cubes: 1 cube, 2 cubes, 3 cubes, and 4 cubes ). I need it to always look at the 4 boxes when I load the scene, no matter my orientation. Edited July 22, 2016 by tbgeorge Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 23, 2016 Share Posted July 23, 2016 HelloDeviceCam is not my strongest Skill maybe this help ??? You can set the Animation Begin with a ButtonClick or Event for initialProsition of the Player.psuedocode: If Player click on Start ->beginAnimation in 1 min > getTarget();http://www.babylonjs-playground.com/#4HUQQ#121 and full of bugshttp://babylonjs-playground.com/#1DLDGX#0 when not just ping someone with @[andthename] Hm. Also when you have a 3d Program, why not set the initialPosition their, i made this playground with blender, and in looks on any device the same, with the same InitialPosition of the Player. Quote Link to comment Share on other sites More sharing options...
tranlong021988 Posted July 23, 2016 Share Posted July 23, 2016 I think if we can change alpha,beta,gamma input, everything will be fine but don't know how to modify Device Orientation operation. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 23, 2016 Share Posted July 23, 2016 Hello I think this should work : https://www.eternalcoding.com/?p=213 Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 23, 2016 Share Posted July 23, 2016 Hi, The camer's rotation is set by the device's orientation. This cannot be changed, because this is the main functionality of this camera. However - there is a possibility to add an initial rotation, that will constantly be applied to the device orientation's rotation. Meaning - if you want your "straight" rotation to be pointing up, you set the initial quaternion to point up. this is more than possible to implement, let me see how I can provide you with an "initial rotation" the easiest. technically you can do it on your own, if you multiply your initial quaternion with the camera's rotation quaternion in each frame. I will work on implementing this internally in the (very) near future as it seems like it is needed Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 24, 2016 Share Posted July 24, 2016 I was thinking about this, and wanted to ask a few questions just to be clear (before I implement something that is not needed): you want that when the user opens the scene, he will see a certain object, no matter his device's orientation. What happens when he starts moving his device? should the rotation be reset (and the device's orientation should kick in) or should this current transformation, that the user started in, be the base for his device's orientation? If it is case 1 - it will be easy to implement code-wise, but not so easy UX-wise. When will you start updating the rotation? The user will have to click " I am ready" or something similar. If it is case 2 - this is my solution from above. I have to say thou, that the user will be rather puzzled when not understand why the scene is rotated in a wrong way while traveling through it. It will make sense if you only take the rotation around the Y axis as a base rotation. So if the user is currently looking north (as "to the right" is completely wrong ) north will be the "0" in the Y axis. same thing if he looks to the south or any other base-direction. Waiting for your answer (or any remarks from anyone) before I implement it. Nabroski 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 25, 2016 Share Posted July 25, 2016 @tbgeorge - I personally don't believe that setting a specific camera device orintation for the VRcamera is a good idea. As I travel allot lately, using my GearVR provides me a poor experience if I am not permitted to set a specific device orientation for my headset regardless of my seat orientation. This most often provides a poor experience in the game as well, and I personally recommend to always allow the user to set the default camera orientation for each game and/or media experience uniquely - especially if camera orientation control is part of the gameplay for position, direction, etc. These are strictly my own thoughts, as it certainly depends on the game. However, I find this to be the case as much as 95% of the time. Cheers, DB Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 25, 2016 Share Posted July 25, 2016 Hi dbawel, I believe the suggestion here will actually solve your fights problem. Set the main scene's rotation to your current y rotation, and you get a wonderful experience whichever direction you are facing. I'm work on that this evening. Quote Link to comment Share on other sites More sharing options...
jellix Posted August 1, 2016 Share Posted August 1, 2016 @RaananW - that sounds good! The Scene-Object can't be rotated so you suggest to create a "master"-Object (a Mesh) that should contain every Object of the scene, right? For that I would have to recode some things, but the solution sounds okay. Just want to be sure to go the right way, now. Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 1, 2016 Share Posted August 1, 2016 Hi @jellix, I should have written here, but this is already integrated in 2.5 alpha. You can "reset" the camera's rotation in any axis you wish, and this will be the initial rotation. To see how it works - http://www.babylonjs-playground.com/#2FOPX7#3 . A mouseclick on the canvas will reset the rotation in the y axis. Quote Link to comment Share on other sites More sharing options...
jellix Posted August 1, 2016 Share Posted August 1, 2016 @RaananW - how cool that is :-) Thanks for the info! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.