User Interface Event Handlers – Talk
Jump to navigation
Jump to search
The values returned by the "onMouseMoving" event of a display are most probably not "some kind of x and y delta position" but rotation angles. Treating these values as azimuth and elevation and applying them to, let's say, a camera results in a perfectly smooth camera movement:
mycam = "camera" camCreate (player modelToWorld [0, -5, 3]); mycam setDir getDir player; mycam cameraEffect ["INTERNAL", "BACK"]; showCinemaBorder false; ax = 0; ay = getDir player; myhandler = ' ax = ax + (_this select 2); ay = ay + (_this select 1); _cx = cos -ax; _cy = cos -ay; _sx = sin -ax; _sy = sin -ay; mycam setVectorDirAndUp [ [_cx * -_sy, _cx * _cy, _sx], [_sx * _sy, -_sx * _cy, _cx] ]; '; (findDisplay 46) displayAddEventHandler ["MouseMoving", myhandler];
Worldeater 20:55, 10 October 2010 (CEST)