Forum

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).

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
Hello,

I have modified “Jungle Outpost” example. It uses a recently released b4w.min.js from the developers preview and a new callback rotation_cb.
Let me know if this is required behavior.
23 November 2015 20:30
The free and pro packages still contain the old version of the scene - no rotation_cb in the .js file.
24 November 2015 10:09
Ответ на сообщение пользователя dallas3d
The free and pro packages still contain the old version of the scene - no rotation_cb in the .js file.
Yes. And they don't have to contain it.
I attached a modified example to the previous comment. Attaching it again to this message.
24 November 2015 12:23
I missed the paper clip - it's been a very tiring month.
24 November 2015 13:03
Ответ на сообщение пользователя dallas3d
I missed the paper clip - it's been a very tiring month.
Hope, my example will help to resolve your task
24 November 2015 13:22
Making progress at last! I still have two issues:

- 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

24 November 2015 13:36
Making progress at last! I still have two issues:

- 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
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?

[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
Mystery solved! I was so locked in on getting this issue fixed that I never noticed the browser flashing a pointer-hiding permission dialog off to the side.

Also, thanks for the cache disabling tip - I have had to clear it at times, and it's annoying.
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.
 
Please register or log in to leave a reply.