• 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);
           }
    简单易懂,无需多说.
  • 相关阅读:
    javascript解决方案插件
    vscode前端快速开发插件
    html5新增语义标签
    vscode快捷键大全
    vscode/sublime前端开发快捷键
    vscode自动缩进快捷键
    Android平台OpenGL ES/Assimp/OpenCV/GLM集成说明
    将AOSP源码导入到Android Studio进行查看
    Android OTA升级
    Android构建系统
  • 原文地址:https://www.cnblogs.com/niconico/p/5009351.html
Copyright © 2020-2023  润新知