Function _IrrSetMousePosition

au3Irr2

au3Irr2 Function Reference

_IrrSetMousePosition

Sets relative position of the mouse pointer and returns relative position before this change.

#Include <au3Irrlicht2.au3>
_IrrSetMousePosition(ByRef $f_XPos, ByRef $f_YPos)

 

Parameters

$f_XPos Fractional value for new horizontal position (0-1).
$f_YPos Fractional value for new vertical position (0-1).

 

Return Value

success: True and sets $f_XPos and $f_YPos to relative position where the mouse was before (both 0-1).
failure: False

 

Remarks

This function works independent from the resolution of current Irrlicht display. Expected and returned values are fractional values, where 0/0 is top left and 1/1 bottom right of the Irrlicht display.

 

Related

_IrrReadMouseEvent, _IrrGetAbsoluteMousePosition

 

Example


#include "au3Irrlicht2.au3"

_IrrStart()

_IrrAddSkyDomeToScene(_IrrGetTexture("./media/au3irr2_logo.jpg"), 16, 16, 1, 2)
local $nodeCamera = _IrrAddCamera( 0,0,5, 0,0,0 )
local $X, $Y, $camY

_IrrHideMouse()
WHILE _IrrRunning()
    _IrrBeginScene(0, 0, 25)

    ; center mouse cursor
    $X = .5
    $Y = .5
    _IrrSetMousePosition($X, $Y)

    ; add any mouse movement to the cam-Y position ...
    $camY += (0.5 - $Y)

    ; ... and reset it slowly back to centre of the display:
    if $camY > 0 then $camY -= 0.005
    if $camY < 0 then $camY += 0.005
    _IrrSetCameraTarget($nodeCamera, 0, $camY, 0)

    _IrrDrawScene()
    _IrrEndScene()
WEND

_IrrStop()