zoukankan      html  css  js  c++  java
  • Axiom3D学习日记 5.Frame Listeners, and Input Handling

    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 * e.TimeSinceLastFrame
           }
           void Instance_FrameStarted(object sender, FrameEventArgs e)
           {
               HandleKeyboardInput(e);
               HandleMouseInput(e);
           }
    简单易懂,无需多说.
  • 相关阅读:
    系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式(分享二十二)
    某云数据中心网络解决方案(分享二十一)
    oracle 12c 管理(分享二十)
    Codeforces 356D 倍增优化背包
    Codeforces 360D Levko and Sets (数论好题)
    gym/102253C Colorful Tree 树上计数
    Codeforces 360E 贪心 最短路
    Codeforces 360C DP 计算贡献
    Codeforces 354B 博弈, DP,记忆化搜索
    Codeforces 354C 暴力 数论
  • 原文地址:https://www.cnblogs.com/niconico/p/5009351.html
Copyright © 2011-2022 走看看