private void glCanvas1_KeyPress(object sender, KeyPressEventArgs e)
{
const float deltaDistance = 0.1f;
ICamera camera = this.scene.FirstCamera;
if (e.KeyChar == 'w')
{
vec3 front = camera.GetFront();
front.y = 0;
this.position += deltaDistance * front.normalize();
SetDirection(this.movableRenderer, front);
}
else if (e.KeyChar == 's')
{
vec3 back = camera.GetBack();
back.y = 0;
this.position += deltaDistance * back.normalize();
SetDirection(this.movableRenderer, back);
}
else if (e.KeyChar == 'a')
{
vec3 left = camera.GetLeft();
left.y = 0;
this.position += deltaDistance * left.normalize();
SetDirection(this.movableRenderer, left);
}
else if (e.KeyChar == 'd')
{
vec3 right = camera.GetRight();
right.y = 0;
this.position += deltaDistance * right.normalize();
SetDirection(this.movableRenderer, right);
}
else if (e.KeyChar == 'r')
{
this.position = new vec3(0, 0, 0);
}
this.movableRenderer.WorldPosition = this.position;
this.lblCubePosition.Text = string.Format("Cube Pos: {0}", this.position);
}