i've faced some strange behaviour: i rotate a default camera around X axis once, then rotate around Y axis in each iteration. i expected camera direction's Y value remain same, but it doesn't ??? am i missing something?
a simple test case:
Camera camera = new Camera();
camera.rotateCameraX(0.5f);
System.out.println(camera.getDirection());
for (int i = 0; i < 100; i++) {
camera.rotateCameraY(0.1f);
System.out.println(camera.getDirection());
}
genarates this output:
(0.0,0.47942555,0.87758255)
(0.09983342,0.47703043,0.87319833)
(0.19866934,0.46986896,0.86008936)
(0.2955202,0.4580127,0.83838665)
(0.3894183,0.44158012,0.80830705)
(0.47942552,0.42073545,0.77015114)
(0.5646425,0.39568692,0.7243002)
(0.64421767,0.36668482,0.6712122)
(0.7173561,0.33401895,0.6114177)
(0.78332686,0.29801565,0.5455141)
(0.84147096,0.2590347,0.4741599)
(0.89120734,0.21746553,0.39806813)
(0.9320391,0.17372355,0.31799892)
(0.96355814,0.12824576,0.23475236)
(0.98544973,0.08148658,0.14916027)
(0.997495,0.033913214,0.062077798)
(0.9995736,-0.013999004,-0.02562493)
(0.99166477,-0.06177134,-0.11307162)
(0.9738477,-0.10892649,-0.19938853)
(0.9463001,-0.15499327,-0.28371322)
(0.90929747,-0.19951141,-0.36520314)
(0.8632094,-0.2420361,-0.4430441)
(0.8084964,-0.28214246,-0.5164583)
(0.7457052,-0.31942976,-0.5847122)
(0.6754632,-0.35352537,-0.6471239)
(0.5984721,-0.38408872,-0.7030697)
(0.5155013,-0.41081437,-0.7519906)
(0.42737985,-0.43343526,-0.7933979)
(0.33498812,-0.45172545,-0.8268779)
(0.23924929,-0.4655021,-0.85209596)
(0.14111997,-0.47462767,-0.86880016)
(0.041580625,-0.47901088,-0.8768236)
(-0.05837419,-0.47860798,-0.8760861)
(-0.15774575,-0.473423,-0.86659503)
(-0.25554118,-0.46350774,-0.84844524)
(-0.35078332,-0.44896123,-0.821818)
(-0.44252056,-0.4299289,-0.7869795)
(-0.52983624,-0.40660077,-0.7442778)
(-0.61185795,-0.37921008,-0.6941395)
(-0.6877662,-0.34803045,-0.63706553)
(-0.7568025,-0.3133734,-0.5736263)
(-0.8182771,-0.2755852,-0.50445545)
(-0.87157583,-0.2350435,-0.43024442)
(-0.91616595,-0.19215329,-0.3517344)
(-0.95160204,-0.14734314,-0.26971)
(-0.9775301,-0.101060815,-0.18499076)
(-0.993691,-0.053768713,-0.09842313)
(-0.9999232,-0.0059393654,-0.010872105)
(-0.99616456,0.041949324,0.07678756)
(-0.9824526,0.08941887,0.16368)
(-0.95892423,0.13599499,0.248937)
(-0.9258147,0.18121228,0.3317067)
(-0.8834546,0.22461894,0.41116208)
(-0.83226746,0.26578128,0.48650926)
(-0.77276444,0.30428803,0.5569954)
(-0.7055403,0.33975443,0.6219163)
(-0.6312666,0.37182614,0.6806231)
(-0.55068547,0.40018266,0.73252946)
(-0.4646021,0.4245407,0.7771165)
(-0.3738766,0.44465685,0.8139389)
(-0.2794154,0.46033013,0.8426287)
(-0.18216243,0.47140402,0.8628993)
(-0.08308933,0.47776774,0.87454796)
(0.016813975,0.47935775,0.87745845)
(0.11654928,0.47615823,0.87160176)
(0.21512006,0.46820104,0.8570363)
(0.3115414,0.45556572,0.83390754)
(0.40484998,0.4383786,0.8024467)
(0.4941134,0.41681132,0.76296806)
(0.5784398,0.3910794,0.71586615)
(0.6569866,0.3614399,0.6616115)
(0.7289691,0.32818907,0.6007462)
(0.7936679,0.29165906,0.5338785)
(0.8504367,0.2522149,0.46167642)
(0.8987081,0.2102507,0.3848614)
(0.938,0.16618574,0.30420104)
(0.9679197,0.120460294,0.2205012)
(0.98816824,0.07353123,0.13459817)
(0.9985433,0.025867486,0.047350273)
(0.9989413,-0.022054719,-0.04037072)
(0.9893582,-0.06975656,-0.12768835)
(0.96988976,-0.116761416,-0.21373016)
(0.9407305,-0.16259962,-0.29763645)
(0.9021718,-0.20681317,-0.37856883)
(0.8545988,-0.24896036,-0.45571876)
(0.798487,-0.28862,-0.5283152)
(0.73439705,-0.32539585,-0.5956329)
(0.6629692,-0.35892045,-0.65699923)
(0.5849171,-0.38885882,-0.71180105)
(0.50102085,-0.4149119,-0.75949085)
(0.41211846,-0.43681926,-0.79959196)
(0.31909832,-0.45436206,-0.8317039)
(0.22288986,-0.46736506,-0.8555057)
(0.124454334,-0.4756983,-0.8707596)
(0.02477531,-0.4792785,-0.87731314)
(-0.075151265,-0.4780699,-0.8751008)
(-0.17432697,-0.4720846,-0.8641448)
(-0.27176085,-0.46138236,-0.84455454)
(-0.3664794,-0.44607013,-0.81652576)
(-0.45753616,-0.42630094,-0.7803385)
(-0.5440214,-0.40227225,-0.73635435)
Well, the coordinate system isn't fixed. It's just an accumulation of rotations so that the Y that you rotate around in the second step is the default Y rotated by the rotation around X. I.e. the axes are fixed only if you are thinking in camera space but not in world space.
so what's the correct way of rotating camera around world space's Y axis ?
Use
camera.rotateCameraAxis(camera.getYAxis(), 0.1f);
instead. However, if you want to do this on Android, i guess i'll have to add some get?Axis(<SimpleVector>)-methods... ;)
mm thanks, i tried Camera.getUpVector() but forgot Camera.getYAxis().
no, i wont use this in android, at least for now. i'm making a sky box, and this was for quick testing it. but sooner or later someone will need it ;)