Frame Listeners
In Ogre's C++, we would register a class to receive notification before and after a frame is rendered to the screen. Such a class is known as a Frame Listener. In Axiom this behavior has been translated to .NET events. This means that using frame listeners is silghtly different in Axiom compared to Ogre. In Ogre it is necessary to register a whole class as a frame listener (observer pattern) and implement several methods for all the events described below. In Axiom on the other hand we just use events and we register single methods only to the events we are interested in.
(废话一堆,意思就是Orge用一个类监听Frame渲染,Axiom中使用C#的event委托方式监听)
Frame Events
捞干的就这些:
FrameStarted |
渲染之前调用的事件 |
FrameRenderingQueued |
在 viewport 渲染之后, 在渲染窗口交换缓冲区之前 |
FrameEnded |
在窗口渲染之后 |
监听事件:
Root.Instance.FrameStarted +=
new
EventHandler<FrameEventArgs>(Instance_FrameStarted);
Input Handling
请允许我以如此偷懒方式记录键盘监听处理方法,对于我来说,这样就很足够,看不懂朋友不要介意.
void HandleKeyboardInput(FrameEventArgs e) {input.Capture();
if (input.IsKeyPressed(Input.KeyCodes.I)) { translateVector.z -= 1; }} void Instance_FrameStarted(object sender, FrameEventArgs e) { HandleKeyboardInput(e); } public override void CreateScene() { Root.Instance.FrameStarted += new EventHandler<FrameEventArgs>(Instance_FrameStarted); }
Mouse
上面是键盘,下面是鼠标:
void HandleMouseInput(FrameEventArgs e) {input.RelativeMouseX
} void Instance_FrameStarted(object sender, FrameEventArgs e) { HandleKeyboardInput(e); HandleMouseInput(e); }* e.TimeSinceLastFrame
简单易懂,无需多说.