74 typedef std::unordered_map<std::string, bool> CompositorList;
75 typedef std::list<std::string> CompositorIndexList;
76 class StereoCameraListener;
77 class StereoRTTListener;
78 class StereoViewportListener;
79 class StereoFrameListener;
83 struct StereoViewportData
85 CompositorList mCompList;
86 CompositorIndexList mCompIndexList;
91 Ogre::String mMaterialScheme;
93 Ogre::ColourValue mOldBackgroundColor;
95 Ogre::Vector3 mOldPos;
96 Ogre::Vector2 mOldOffset;
99 Ogre::Matrix4 mOldMatrix;
100 Ogre::Matrix4 mBaseCameraMatrix;
101 bool mOldUseCustomMatrix;
102 Ogre::Camera* mCamera;
103 StereoCameraListener* leftCameraListener;
104 StereoCameraListener* rightCameraListener;
105 StereoRTTListener* rttListener;
106 StereoViewportListener* viewportListener;
107 StereoFrameListener* frameListener;
108 Ogre::Viewport* mOriginalViewport;
109 Ogre::Vector2 mOriginalViewportSize;
110 Ogre::Viewport* mLastLeftViewport;
111 Ogre::Viewport* mLastRightViewport;
112 Ogre::SceneManager* mScene;
113 Ogre::SceneManager* mStereoScene;
114 Ogre::Rectangle2D* mRect;
115 Ogre::SceneNode* mStereoCameraNode;
116 Ogre::Camera* mStereoCamera;
117 Ogre::ColourValue mBackgroundColor;
118 Ogre::TexturePtr mLeftRenderTexture;
119 Ogre::TexturePtr mRightRenderTexture;
120 Ogre::Entity* mLeftEntity;
121 Ogre::Entity* mRightEntity;
122 StereoViewportData() : mFlipEyes(false), mShadowEnable(false), mOverlayEnable(false), mSkyEnable(false), frameTime(0.0), mOldBackgroundColor(
Ogre::ColourValue::Black), mMask(0xffffffff), mOldPos(
Ogre::Vector3::ZERO), mOldOffset(
Ogre::Vector2::ZERO), mOldRatio(0.0f), mOldFOV(
Ogre::Radian()), mOldMatrix(
Ogre::Matrix4::IDENTITY), mBaseCameraMatrix(
Ogre::Matrix4::IDENTITY), mOldUseCustomMatrix(false), mCamera(0), leftCameraListener(0), rightCameraListener(0), rttListener(0), viewportListener(0), frameListener(0), mOriginalViewport(0), mLastLeftViewport(0), mLastRightViewport(0), mScene(0), mStereoScene(0), mRect(0), mStereoCameraNode(0), mStereoCamera(0), mBackgroundColor(
Ogre::ColourValue::Black), mLeftRenderTexture(), mRightRenderTexture(), mLeftEntity(0), mRightEntity(0) {}
128 class StereoRTTListener :
public Ogre::Resource::Listener
133 StereoManager* mStereoMgr;
134 StereoManager::StereoViewportData* viewportData;
140 StereoRTTListener(StereoManager* stereoMgr, StereoManager::StereoViewportData* stereoViewportData);
145 virtual void loadingComplete(Ogre::Resource* resource);
150 virtual void unloadingComplete(Ogre::Resource* resource);
164 StereoManager* mStereoMgr;
165 StereoManager::StereoViewportData* viewportData;
166 Ogre::Viewport* mOriginalViewport;
173 StereoCameraListener(StereoManager* stereoMgr,
bool isLeftCamera, Ogre::Viewport* originalViewport, StereoManager::StereoViewportData* stereoViewportData);
178 virtual void preRenderTargetUpdate(
const Ogre::RenderTargetEvent& evt);
183 virtual void postRenderTargetUpdate(
const Ogre::RenderTargetEvent& evt);
197 StereoManager* mStereoMgr;
198 StereoManager::StereoViewportData* viewportData;
204 StereoViewportListener(StereoManager* stereoMgr, StereoManager::StereoViewportData* stereoViewportData);
209 virtual void preRenderTargetUpdate(
const Ogre::RenderTargetEvent& evt);
214 virtual void postRenderTargetUpdate(
const Ogre::RenderTargetEvent& evt);
228 StereoManager* mStereoMgr;
229 StereoManager::StereoViewportData* viewportData;
235 StereoFrameListener(StereoManager* stereoMgr, StereoManager::StereoViewportData* stereoViewportData);
240 virtual bool frameStarted(
const Ogre::FrameEvent& evt);
245 virtual bool frameRenderingQueued(
const Ogre::FrameEvent& evt);
250 virtual bool frameEnded(
const Ogre::FrameEvent& evt);
264 StereoManager* mStereoMgr;
270 DeviceLostListener(StereoManager* stereoMgr);
275 virtual void eventOccurred(
const Ogre::String &eventName,
const Ogre::NameValuePairList *parameters);
279 typedef std::map<StereoMode, Ogre::String> StereoModeList;
280 StereoModeList mAvailableModes;
281 typedef std::map<Ogre::Viewport*, StereoViewportData*> StereoViewports;
282 StereoViewports stereoViewports;
285 Ogre::Real mEyesSpacing;
286 Ogre::uint32 mLeftMask, mRightMask;
293 bool mIsCustomProjection;
294 bool mIsCustomOffset;
297 bool mIsCustomDistortion;
298 bool mIsCustomChromAbCorrection;
300 Ogre::Vector4 mDistortion;
301 Ogre::Vector4 mChromAbCorrection;
302 Ogre::Matrix4 mLeftCustomProjection, mRightCustomProjection;
303 Ogre::Matrix4 mLeftStartWarpMatrix, mLeftEndWarpMatrix;
304 Ogre::Matrix4 mRightStartWarpMatrix, mRightEndWarpMatrix;
305 Ogre::Real mCenterOffset;
308 Ogre::Vector2 mLeftUVScale;
309 Ogre::Vector2 mLeftUVOffset;
310 Ogre::Vector2 mRightUVScale;
311 Ogre::Vector2 mRightUVOffset;
314 Ogre::MeshPtr mLeftMesh;
315 Ogre::MeshPtr mRightMesh;
316 bool mHasExternalWindow;
319 int mWindowMonitorIndex;
320 Ogre::RenderWindow* mExternalWindow;
321 Ogre::Viewport* mExternalViewport;
425 void SetTimeWarpMatrix(
const Ogre::Matrix4 &leftStartMatrix,
const Ogre::Matrix4 &leftEndMatrix,
const Ogre::Matrix4 &rightStartMatrix,
const Ogre::Matrix4 &rightEndMatrix);
427 void SetStereoMeshUVConfig(Ogre::Vector2 leftuvscale, Ogre::Vector2 leftuvoffset, Ogre::Vector2 rightuvscale, Ogre::Vector2 rightuvoffset);
429 void SetStereoMeshLeft(std::vector<Ogre::Vector3> vertices, std::vector<std::vector<Ogre::Vector2> > uvs, std::vector<Ogre::Real> vignetteColor, std::vector<Ogre::Real> warp, std::vector<int> indexs);
430 void SetStereoMeshRight(std::vector<Ogre::Vector3> vertices, std::vector<std::vector<Ogre::Vector2> > uvs, std::vector<Ogre::Real> vignetteColor, std::vector<Ogre::Real> warp, std::vector<int> indexs);
446 void InitializeViewport(Ogre::Viewport* viewport, StereoViewportData* viewportData);
450 void ShutdownViewport(Ogre::Viewport* viewport, StereoViewportData* viewportData);
454 void InitializeStereo(Ogre::Viewport* viewport, StereoViewportData* viewportData);
458 void ShutdownStereo(Ogre::Viewport* viewport, StereoViewportData* viewportData);
462 void InitializeListeners(Ogre::Viewport* viewport, StereoViewportData* viewportData);
466 void ShutdownListeners(Ogre::Viewport* viewport, StereoViewportData* viewportData);