Key Mappings could be different for each tutorial.
Actually, the key mappings are part of the tutorial codes and you could find them in the source files. For example rendering tutorials 2 make the cubes rotate when "Space" is pressed.
For camera movements, we use a SimplyCube feature named "Controllers". A controller could be attached to any SceneNode and performs an operation on each update. We provide a default controller in the engine that move a node according keyboard, mouse and gamepad inputs named "DefaultFreeController".
The mapping for this controller is :
- LeftAlt+LeftMouse pressed => pan tilt
- LeftAlt+RightMouse pressed => move forward, backward
- LeftAlt+MiddleMouse pressed => move up, down, left, right
- LeftShift => increase movement speed
- Up,Down,Left,Right or Q,S,D,Z => move up, down, left, right
Q,S,D,Z is useful on AZERTY keyboard and not QWERTY. Our controller doesn't test the keyboard type. We will improve that for the release.
If you want to have your own binding, you could :
- totally rewrite a controller (implement the SimplySim.Xna.Engine.Scene.Controllers.INodeController interface, and add you controller to the camera scene node)
- write a class that implements SimplySim.Xna.Engine.Scene.Controllers.IFreeControllerDevice and add its to the "Devices" list on the DefaultFreeController. To give you an idea, I join the code for the default keyboard controller (the AZERTY one)
Code:
class DefaultFreeKeyboardController : IFreeControllerDevice
{
public void Update(EngineWindow window, EngineTime time, ref Vector3 position, ref float pan, ref float tilt, float TranslateSpeed, float RotateSensivity)
{
float realNodeSpeed = TranslateSpeed;
if (window.KeyboardState.IsKeyDown(Keys.LeftShift) || window.KeyboardState.IsKeyDown(Keys.RightShift))
{
realNodeSpeed *= 10;
}
// Forward
if (window.KeyboardState.IsKeyDown(Keys.Up) || window.KeyboardState.IsKeyDown(Keys.Z))
{
Vector3 v = new Vector3(0, 0, realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds);
position += v;
}
// Backward
else if (window.KeyboardState.IsKeyDown(Keys.Down) || window.KeyboardState.IsKeyDown(Keys.S))
{
Vector3 v = new Vector3(0, 0, -realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds);
position += v;
}
// Left
if (window.KeyboardState.IsKeyDown(Keys.Left) || window.KeyboardState.IsKeyDown(Keys.Q))
{
Vector3 v = new Vector3(realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds, 0, 0);
position += v;
}
// Right
else if (window.KeyboardState.IsKeyDown(Keys.Right) || window.KeyboardState.IsKeyDown(Keys.D))
{
Vector3 v = new Vector3(-realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds, 0, 0);
position += v;
}
}
}
Regards