Basic user interaction
From Linderdaum Engine
Here we will learn how to enhance Engine initialization application with simple reactions to user input.
We would like to:
Rotation with mouse
Let's start with mouse and add the following code to DrawOverlay() fucntion:
bool MousePressedL = Env->GUI->IsKeyPressed( LK_LBUTTON ); Env->Engine->GetViewport()->UpdateTrackball( &Trackball, 10.0f, MousePressedL );
Trackball and rotation matrices should be declared beforehand:
and the use both rotation matrices to create new modelview matrix for our cube:
Env->Context->BeginTransform( Trackball.GetRotationMatrix() * ModelView );
You can now rotate the cube with left mouse button.