I wrote a small example for FPS-systems with the sensitivity parameter and the ability to invert the mouse. Also, the sensitivity can be adjusted separately for the axes, as well as the inversion.
Note: Lemur’s InputMapper (which can be used even if you don’t use the rest of Lemur) supports scaling the mappings which can be used to set the sensitivity of joystick axes or mouse axes (even separately).
Since you can treat keys and input axes the same, it applies to keys as well.
It’s a bit different than what you are doing but would let the look code be sensitivity independent meaning you could have different sensitivities for keyboab-based axes versus joystick axes versus mouse axes.
It also seems strange to base the sensitivity on camera size since you will turn just as fast no matter what size the screen is… I guess for trying to pinpoint a specific target… but anyway, you could always update the Lemur InputMapper mappings based on screen size I guess.
Also, camera.getRotation().getZ() and camera.getRotation().getX() are not what you think they are. These are magic quaternion values and it makes no sense to treat them like angles. You are just lucky that they happen to be reasonably lined up in your example but it’s not right at all.
toAngles()… but this won’t work for all angles. You cannot reliably get predictable euler angles as you want them from a Quaternion.
(starts tape player) Quaternions are compact representation of orientation. Euler angles are a totally ambiguous, often redundant, representation of orientation. Thus if you put some set of euler angles into a quaternion then you will not necessarily get them back out again.
…if you want to base orientation on yaw and pitch as you are doing then you need to keep yaw and pitch, modify those, and create your rotation from them. You can’t go into a quaternion and out again.
Fortunately, I have an example of exactly this using Lemur’s InputMapper.
Looking at the camera in jME3, this is a kind of mythical object. Why does not it have spatial properties?
I can not attach it to the node, if there was such an opportunity, it made life easier.
I transferred the FPS camera, but as it should, it was not without problems. If you disable vertical synchronization, this works poorly. I think this problem is connected: Engine having lagspikes on high-end gaming pc
After a simple experiment with removing from the code tpf, I found out that this would be a problem, I suppose it does not provide the correct data.
Use your own class for time control. do not use tpf as delta, intead of that use timeActionStart, timeActionEnd and actual time. you can calculate every position as f(t).
Yeah, I’m looking at the code and you’re right. Part of a larger problem I guess.
Still, I guess it comes up rarely that a user would turn one direction significantly more often than another unless the game is clamping input. JME should probably provide a way to reset the internal counters in that case.