[1163] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | You may use this sample code for anything you like, it is not covered by the
|
---|
| 11 | LGPL like the rest of the engine.
|
---|
| 12 | -----------------------------------------------------------------------------
|
---|
| 13 | */
|
---|
| 14 | /*
|
---|
| 15 | -----------------------------------------------------------------------------
|
---|
| 16 | Filename: ExampleFrameListener.h
|
---|
| 17 | Description: Defines an example frame listener which responds to frame events.
|
---|
| 18 | This frame listener just moves a specified camera around based on
|
---|
| 19 | keyboard and mouse movements.
|
---|
| 20 | Mouse: Freelook
|
---|
| 21 | W or Up: Forward
|
---|
| 22 | S or Down:Backward
|
---|
| 23 | A: Step left
|
---|
| 24 | D: Step right
|
---|
| 25 | PgUp: Move upwards
|
---|
| 26 | PgDown: Move downwards
|
---|
| 27 | F: Toggle frame rate stats on/off
|
---|
| 28 | R: Render mode
|
---|
| 29 | T: Cycle texture filtering
|
---|
| 30 | Bilinear, Trilinear, Anisotropic(8)
|
---|
| 31 | P: Toggle on/off display of camera position / orientation
|
---|
| 32 | -----------------------------------------------------------------------------
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | #ifndef __KdTreeAppListener_H__
|
---|
| 36 | #define __KdTreeAppListener_H__
|
---|
| 37 |
|
---|
| 38 | #include "Ogre.h"
|
---|
| 39 | #include "OgreKeyEvent.h"
|
---|
| 40 | #include "OgreEventListeners.h"
|
---|
| 41 | #include "OgreStringConverter.h"
|
---|
| 42 | #include "OgreException.h"
|
---|
| 43 |
|
---|
[1187] | 44 | #define VIZ_VIEWPORT_Z_ORDER 10
|
---|
| 45 |
|
---|
[1163] | 46 | using namespace Ogre;
|
---|
| 47 |
|
---|
| 48 | class KdTreeAppListener: public FrameListener, public KeyListener
|
---|
| 49 | {
|
---|
| 50 | protected:
|
---|
| 51 | int mSceneDetailIndex ;
|
---|
| 52 | Real mMoveSpeed;
|
---|
| 53 | Degree mRotateSpeed;
|
---|
| 54 | Real mRotationPeriod;
|
---|
| 55 | bool mShowTree;
|
---|
[1170] | 56 | bool mFreeMove;
|
---|
[1163] | 57 |
|
---|
[1183] | 58 | Real mDelayedQueriesIssued;
|
---|
| 59 | Real mDelayedTraversedNodes;
|
---|
| 60 |
|
---|
[1163] | 61 | int mSeqNum;
|
---|
| 62 |
|
---|
[1183] | 63 | Overlay* mDebugOverlay;
|
---|
| 64 | Overlay* mKdTreeOverlay;
|
---|
| 65 |
|
---|
| 66 | OverlayElement *mKdTreeMaxDepthInfo;
|
---|
| 67 | OverlayElement *mKTInfo;
|
---|
| 68 | OverlayElement *mKIInfo;
|
---|
| 69 | OverlayElement *mHighlightLevelInfo;
|
---|
| 70 | OverlayElement *mBuildMethodInfo;
|
---|
| 71 | OverlayElement *mRenderMethodInfo;
|
---|
| 72 | OverlayElement *mMovementInfo;
|
---|
| 73 |
|
---|
| 74 | OverlayElement *mFrustumCulledNodesInfo;
|
---|
| 75 | OverlayElement *mQueryCulledNodesInfo;
|
---|
| 76 | OverlayElement *mTraversedNodesInfo;
|
---|
| 77 | OverlayElement *mHierarchyNodesInfo;
|
---|
| 78 | OverlayElement *mRenderedNodesInfo;
|
---|
| 79 | OverlayElement *mObjectsCountInfo;
|
---|
| 80 | OverlayElement *mQueriesIssuedInfo;
|
---|
| 81 |
|
---|
[1187] | 82 | EventProcessor* mEventProcessor;
|
---|
| 83 | InputReader* mInputDevice;
|
---|
| 84 | SceneNode *mCamNode;
|
---|
| 85 | Camera* mCamera;
|
---|
| 86 | Camera* mTopCam;
|
---|
| 87 | SceneManager *mSceneMgr;
|
---|
| 88 | Radian mDeathAngle;
|
---|
[1183] | 89 |
|
---|
[1187] | 90 | Vector3 mTranslateVector;
|
---|
| 91 | RenderWindow* mWindow;
|
---|
| 92 | bool mStatsOn;
|
---|
| 93 | bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
|
---|
| 94 | unsigned int mNumScreenShots;
|
---|
| 95 | float mMoveScale;
|
---|
| 96 | Degree mRotScale;
|
---|
| 97 | // just to stop toggles flipping too fast
|
---|
| 98 | Real mTimeUntilNextToggle ;
|
---|
| 99 | Radian mRotX, mRotY;
|
---|
| 100 | TextureFilterOptions mFiltering;
|
---|
| 101 | int mAniso;
|
---|
[1163] | 102 |
|
---|
[1187] | 103 | // stuff for the viz camera
|
---|
| 104 | bool mVizCamera;
|
---|
| 105 | Vector3 mVizCamTransVect;
|
---|
[1163] | 106 |
|
---|
[1187] | 107 | void updateStats(void);
|
---|
[1163] | 108 |
|
---|
| 109 | public:
|
---|
| 110 |
|
---|
[1183] | 111 | // visualization modes for scene nodes
|
---|
| 112 | enum
|
---|
| 113 | {
|
---|
| 114 | NODEVIZ_NONE,
|
---|
| 115 | NODEVIZ_RENDER_NODES,
|
---|
| 116 | NODEVIZ_RENDER_NODES_AND_CONTENT,
|
---|
| 117 | NODEVIZ_MODES_NUM
|
---|
| 118 | };
|
---|
| 119 |
|
---|
[1163] | 120 | // Constructor takes a RenderWindow because it uses that to determine input context
|
---|
| 121 | KdTreeAppListener(RenderWindow* win, SceneManager* sm, Real rs, Real ms, Real rp,
|
---|
[1187] | 122 | bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
|
---|
[1163] | 123 |
|
---|
[1187] | 124 | virtual ~KdTreeAppListener();
|
---|
[1163] | 125 |
|
---|
[1183] | 126 | void initOverlayElement(OverlayElement **elInfo, String ext,
|
---|
[1187] | 127 | String name, int top, String caption);
|
---|
[1183] | 128 |
|
---|
[1187] | 129 | void initStatsOverlay();
|
---|
[1183] | 130 |
|
---|
[1187] | 131 | void initKdTreeOverlay();
|
---|
[1183] | 132 |
|
---|
[1187] | 133 | void showDebugOverlay(bool show);
|
---|
[1183] | 134 |
|
---|
[1187] | 135 | void toggleVizCamera();
|
---|
[1183] | 136 |
|
---|
[1187] | 137 | virtual bool processUnbufferedKeyInput(const FrameEvent& evt);
|
---|
[1183] | 138 |
|
---|
[1187] | 139 | bool processUnbufferedMouseInput(const FrameEvent& evt);
|
---|
[1183] | 140 |
|
---|
[1187] | 141 | void moveCamera();
|
---|
[1163] | 142 |
|
---|
| 143 | // Override frameStarted event to process that (don't care about frameEnded)
|
---|
[1187] | 144 | bool frameStarted(const FrameEvent& evt);
|
---|
[1163] | 145 |
|
---|
[1187] | 146 | bool frameEnded(const FrameEvent& evt);
|
---|
[1163] | 147 |
|
---|
[1187] | 148 | void switchMouseMode();
|
---|
[1163] | 149 |
|
---|
[1187] | 150 | void switchKeyMode();
|
---|
[1163] | 151 |
|
---|
[1187] | 152 | void keyClicked(KeyEvent* e);
|
---|
[1163] | 153 |
|
---|
[1187] | 154 | void keyPressed(KeyEvent* e) {};
|
---|
| 155 | void keyReleased(KeyEvent* e) {};
|
---|
[1163] | 156 | };
|
---|
| 157 |
|
---|
| 158 | #endif
|
---|
| 159 |
|
---|