Mouse move -> camera/character rotation
22 November 2015 00:13
Since my last post went in a different (but important) direction, I'm going to shift my big problem over here. I'm also going to explain in another way, hopefully making my problem clearer.
I want to know how to replace the second part of the code with manifolds so that it can be used with the first (I used semi-stiff constraint in my scene, because I want to be able to rotate the camera up and down independently of the character).
code to be replaced:
I can refine the rest after, but this is where I'm still stuck.
I want to know how to replace the second part of the code with manifolds so that it can be used with the first (I used semi-stiff constraint in my scene, because I want to be able to rotate the camera up and down independently of the character).
var rotate_left_right = m_ctl.create_mouse_move_sensor("X");
var rotate_up_down = m_ctl.create_mouse_move_sensor("Y")
code to be replaced:
if (oldX < e.pageX) {
m_phy.character_rotation_inc(_character, -.01, 0);
} else {
m_phy.character_rotation_inc(_character, .01, 0);
}
if (oldY < e.pageY) {
_camang = m_cam.get_camera_angles(_cam);
_camang[1] = _camang[1] - _caminc;
m_cam.rotate_camera(_cam, _camang[0], _camang[1], true, true);
} else {
_camang = m_cam.get_camera_angles(_cam);
_camang[1] = _camang[1] + _caminc;
m_cam.rotate_camera(_cam, _camang[0], _camang[1], true, true);
}
oldX = e.pageX;
oldY = e.pageY;
I can refine the rest after, but this is where I'm still stuck.
23 November 2015 13:55
23 November 2015 20:30
24 November 2015 10:09
24 November 2015 13:03
24 November 2015 13:22
24 November 2015 13:36
Making progress at last! I still have two issues:I tested it on Linux/Windows Chrome, Firefox 41/42 and haven't experienced any of the described issues. The pointer bug is a really strange one. Maybe, you have some specifics in your code? And what OS do you use?
- This works for me in Chrome but not Firefox (v 42.0)
- In Chrome, the pointerlock does not disengage when I let go of the mouse button
[EDIT] Probably, your server cached some files. It is always better to disable cache (locally, or on the server) when developing apps.
24 November 2015 13:48
24 November 2015 14:24
One last thing and I'm all set:
I would like to be able to use the mouse pointer to click-select objects in the same scene. Pointerlock interferes with that. How do I integrate the two 'modes' smoothly? If possible I'd like to have the pointerlock only engaged when the lmb is being held down, or, if not, do this in a way that avoids pointerlock.
To boil it down in simple statements:
- lmb held down -> rotate character/camera
- lmb clicked -> select object in scene
Thanks for all the help, this thing's been a real headache so it'll be nice to put it to bed.
I would like to be able to use the mouse pointer to click-select objects in the same scene. Pointerlock interferes with that. How do I integrate the two 'modes' smoothly? If possible I'd like to have the pointerlock only engaged when the lmb is being held down, or, if not, do this in a way that avoids pointerlock.
To boil it down in simple statements:
- lmb held down -> rotate character/camera
- lmb clicked -> select object in scene
Thanks for all the help, this thing's been a real headache so it'll be nice to put it to bed.