1 | /* |
---|
2 | =========================================================================== |
---|
3 | Copyright (C) 2010 Jared Prince |
---|
4 | |
---|
5 | This file is part of bsp-renderer source code. |
---|
6 | |
---|
7 | bsp-renderer is free software: you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU General Public License as published by |
---|
9 | the Free Software Foundation, either version 3 of the License, or |
---|
10 | (at your option) any later version. |
---|
11 | |
---|
12 | bsp-renderer is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU General Public License |
---|
18 | along with bsp-renderer. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | |
---|
20 | */ |
---|
21 | //||||||||||||||||||||||||||||||||||||||||||||||| |
---|
22 | |
---|
23 | #ifndef OGRE_FRAMEWORK_HPP |
---|
24 | #define OGRE_FRAMEWORK_HPP |
---|
25 | |
---|
26 | //||||||||||||||||||||||||||||||||||||||||||||||| |
---|
27 | |
---|
28 | #include <OgreCamera.h> |
---|
29 | #include <OgreEntity.h> |
---|
30 | #include <OgreLogManager.h> |
---|
31 | #include <OgreOverlay.h> |
---|
32 | #include <OgreOverlayElement.h> |
---|
33 | #include <OgreOverlayManager.h> |
---|
34 | #include <OgreRoot.h> |
---|
35 | #include <OgreViewport.h> |
---|
36 | #include <OgreSceneManager.h> |
---|
37 | #include <OgreRenderWindow.h> |
---|
38 | #include <OgreConfigFile.h> |
---|
39 | #include <OgreManualObject.h> |
---|
40 | #include <OgreMaterialManager.h> |
---|
41 | #include <OgreRenderSystem.h> |
---|
42 | #include <OgreOverlayContainer.h> |
---|
43 | #include <OgreHardwarePixelBuffer.h> |
---|
44 | #include <OgreRenderQueueListener.h> |
---|
45 | #include <OgreHardwareOcclusionQuery.h> |
---|
46 | #include <OgreTextureUnitState.h> |
---|
47 | #include "OgreGpuCommandBufferFlush.h" |
---|
48 | |
---|
49 | |
---|
50 | #include "ExampleFrameListener.h" |
---|
51 | //#include <OgreFrameListener.h> |
---|
52 | //#include <OgreRenderTargetListener.h> |
---|
53 | |
---|
54 | |
---|
55 | #include <OIS/OIS.h> |
---|
56 | #include <OIS/OISEvents.h> |
---|
57 | #include <OIS/OISInputManager.h> |
---|
58 | #include <OIS/OISKeyboard.h> |
---|
59 | #include <OIS/OISMouse.h> |
---|
60 | |
---|
61 | #include "Q3Map.h" |
---|
62 | |
---|
63 | //#include "JarDebug.h" //!! just for debugging, remove from final build |
---|
64 | |
---|
65 | |
---|
66 | #define CHECKDELETE_ARRAY(x, y) if(x) { delete [] x ; x=0 ; m_nNewCount-- ; m_nNewCheck[y]-- ;} |
---|
67 | #define CHECKDELETE_POINTER(x, y) if(x) { delete x ; x=0 ; m_nNewCount-- ; m_nNewCheck[y]-- ;} |
---|
68 | |
---|
69 | enum { |
---|
70 | NEW_CHECK_m_pRawBspFile=0, |
---|
71 | NEW_CHECK_m_Q3Map, |
---|
72 | NEW_CHECK_m_pZoneMO, |
---|
73 | NEW_CHECK_m_pZoneMesh, |
---|
74 | NEW_CHECK_m_pZoneEntity, |
---|
75 | NEW_CHECK_m_pZoneEntityMaterialType, |
---|
76 | NEW_CHECK_m_pZoneEntityMaterial_Base, |
---|
77 | NEW_CHECK_m_pZoneEntityMaterial_Fast, |
---|
78 | NEW_CHECK_m_pZoneEntityMaterial_Black, |
---|
79 | NEW_CHECK_m_pZoneEntityMaterial_DfShColour, |
---|
80 | NEW_CHECK_m_pZoneEntityMaterial_Shadow, |
---|
81 | NEW_CHECK_m_pZoneEntityMaterial_ShadeFront, |
---|
82 | NEW_CHECK_m_pZoneEntityMaterial_ShadeBack, |
---|
83 | NEW_CHECK_m_pZoneEntityMaterial_DfShPosition, |
---|
84 | NEW_CHECK_m_pZoneEntityMaterial_DfShDiffuse, |
---|
85 | NEW_CHECK_m_pZoneEntityMaterial_DfShFuncTNB, |
---|
86 | NEW_CHECK_m_pZoneEntityMaterial_DfShSpecular, |
---|
87 | NEW_CHECK_m_pZoneEntityMaterial_DfShEmissive, |
---|
88 | NEW_CHECK_m_pZoneEntityMaterial_DfShMix, |
---|
89 | NEW_CHECK_pVertIndex, |
---|
90 | NEW_CHECK_m_pEntityInfo, |
---|
91 | NEW_CHECK_m_pVisibleEntity, |
---|
92 | NEW_CHECK_m_pFrustumEntity, |
---|
93 | MAX_NEW_CHECK |
---|
94 | } ; |
---|
95 | |
---|
96 | #define MAXFRAME 1000 // debugging/testing, copy out data on a per-frame basis |
---|
97 | |
---|
98 | #define MAXGPUQUERY 4 |
---|
99 | |
---|
100 | #define MAXVISIBLELIGHT 128 // most shadow lights ever visible. |
---|
101 | #define MAXLIGHTPERLOOP 1 // most shadow lights rendered per deferred shader sub-loop. So shadow lights are rendered in lots of 4// no longer used |
---|
102 | |
---|
103 | #define NEARCLIP 1 // camera default near clip distance |
---|
104 | #define FARCLIP 10000 // camera default far clip distance |
---|
105 | |
---|
106 | #define CAMERA_EPSILON 0.000001f // small value to check for up/down cameras that would break with Ogre's fixed Yaw. |
---|
107 | |
---|
108 | #define IGNORE_LIGHT -1 |
---|
109 | |
---|
110 | enum GoggleMode |
---|
111 | { |
---|
112 | GOGGLE_MODE_OFF = 0, |
---|
113 | GOGGLE_MODE_TEST, |
---|
114 | GOGGLE_MODE_ON, |
---|
115 | GOGGLE_MODE_MAX |
---|
116 | } ; |
---|
117 | |
---|
118 | #define MAT_OPAQUE 1 // Typical solid stuff. Can have emissive parts. |
---|
119 | #define MAT_TRANS 2 // Unused |
---|
120 | #define MAT_GLOW 4 // Only rendered in the deferred shader emmisive pass. Used to create the hdr bloom for light points. |
---|
121 | #define MAT_GEL 8 // Translucent, colours spotlights that pass through it. |
---|
122 | #define MAT_ALPHAPF 16 // Same as MAT_OPAQUE, but with alpha testing. |
---|
123 | #define MAT_LAMP 32 // The bounding boxes of deferred shading lights (lamps). Rendered as the last phase in deferred shading. |
---|
124 | |
---|
125 | #define BZN_CONFIG_SIZE 1024 |
---|
126 | |
---|
127 | class rQueueListener: public Ogre::RenderQueueListener |
---|
128 | { |
---|
129 | public: |
---|
130 | |
---|
131 | rQueueListener() {} |
---|
132 | ~rQueueListener() {} |
---|
133 | |
---|
134 | Ogre::HardwareOcclusionQuery* Query[MAXGPUQUERY] ; |
---|
135 | |
---|
136 | void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation) {} |
---|
137 | void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation) {} |
---|
138 | }; |
---|
139 | |
---|
140 | //////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
141 | |
---|
142 | #define MAX_SUBMESH 16 // most submeshes allowed in a mesh. |
---|
143 | #define MAX_ZONEPERENTITY 8 // the most zones an entity can touch at once. |
---|
144 | #define INDEX_ENTITYZONECOUNT 8 // index to value that holds the count of how many zones this entity touches |
---|
145 | #define MAX_LIGHTPERENTITY 64 // most shadowing lights that an entity can be lit by |
---|
146 | #define INDEX_LIGHTPERENTITY 64 // index to value |
---|
147 | typedef struct |
---|
148 | { |
---|
149 | int Active ; |
---|
150 | int Visible ; |
---|
151 | int Frustum ; |
---|
152 | int LightTouch ; |
---|
153 | |
---|
154 | int TriangleCount ; |
---|
155 | |
---|
156 | Ogre::Vector3 Postition ; |
---|
157 | Ogre::Quaternion Orientation ; |
---|
158 | |
---|
159 | Ogre::AxisAlignedBox AABB ; |
---|
160 | Ogre::Vector3 Centre ; |
---|
161 | float AABBMin[3] ; |
---|
162 | float AABBMax[3] ; |
---|
163 | |
---|
164 | unsigned short Zone[MAX_ZONEPERENTITY+1] ; // the zones this entity touches. Last value is a count of how many zones were touched. |
---|
165 | unsigned short Light[MAX_LIGHTPERENTITY+1] ; // the shadow casting spotlights this entity touches. Last value is a count of how many lights. |
---|
166 | |
---|
167 | int MaxSubMesh ; |
---|
168 | int SubMeshMaterialType[MAX_SUBMESH] ; |
---|
169 | |
---|
170 | Ogre::Entity* pEnt ; |
---|
171 | Ogre::SceneNode* pMasterNode ; |
---|
172 | |
---|
173 | Ogre::MaterialPtr Material_Base[MAX_PROJECTORTEX][MAX_SUBMESH] ; |
---|
174 | Ogre::MaterialPtr Material_Fast[MAX_PROJECTORTEX][MAX_SUBMESH] ; |
---|
175 | |
---|
176 | Ogre::MaterialPtr Material_Black[MAX_SUBMESH] ; |
---|
177 | |
---|
178 | Ogre::MaterialPtr Material_DfShColour[MAX_SUBMESH] ; |
---|
179 | Ogre::MaterialPtr Material_Shadow[MAX_SUBMESH] ; |
---|
180 | Ogre::MaterialPtr Material_ShadeFront[MAX_SUBMESH] ; |
---|
181 | Ogre::MaterialPtr Material_ShadeBack[MAX_SUBMESH] ; |
---|
182 | Ogre::MaterialPtr Material_DfShPosition[MAX_SUBMESH] ; |
---|
183 | Ogre::MaterialPtr Material_DfShDiffuse[MAX_SUBMESH] ; |
---|
184 | Ogre::MaterialPtr Material_DfShFuncTNB[MAX_SUBMESH] ; |
---|
185 | Ogre::MaterialPtr Material_DfShSpecular[MAX_SUBMESH] ; |
---|
186 | Ogre::MaterialPtr Material_DfShEmissive[MAX_SUBMESH] ; |
---|
187 | Ogre::MaterialPtr Material_DfShMix[MAX_SUBMESH] ; |
---|
188 | } |
---|
189 | ENTITYINFO; |
---|
190 | |
---|
191 | typedef struct |
---|
192 | { |
---|
193 | |
---|
194 | int Type ; |
---|
195 | |
---|
196 | Ogre::ParticleSystem* PSystem ; |
---|
197 | Ogre::SceneNode* PNode ; |
---|
198 | |
---|
199 | } |
---|
200 | PARTICLEINFO; |
---|
201 | |
---|
202 | //||||||||||||||||||||||||||||||||||||||||||||||| |
---|
203 | |
---|
204 | class OgreFramework : public Ogre::Singleton<OgreFramework>, OIS::KeyListener, OIS::MouseListener, public RenderTargetListener |
---|
205 | { |
---|
206 | public: |
---|
207 | OgreFramework(); |
---|
208 | ~OgreFramework(); |
---|
209 | |
---|
210 | int m_nNewCount ; |
---|
211 | int m_nNewCheck[MAX_NEW_CHECK] ; |
---|
212 | |
---|
213 | int m_nStartTime ; |
---|
214 | int m_nTime ; |
---|
215 | |
---|
216 | // CJarDebug OFBug ; //!! just for debugging, remove from final build |
---|
217 | char m_chBug[10240] ; |
---|
218 | int m_nFrameTime[MAXFRAME][10] ; |
---|
219 | int m_nFrame ; |
---|
220 | char m_chFrame[1024] ; |
---|
221 | int m_nGotInput ; |
---|
222 | |
---|
223 | void initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener = 0, OIS::MouseListener *pMouseListener = 0); |
---|
224 | void AdditionalSetup() ; |
---|
225 | |
---|
226 | void updateOgre(double timeSinceLastFrame); |
---|
227 | void updateStats(); |
---|
228 | void moveCamera(); |
---|
229 | void getInput(); |
---|
230 | |
---|
231 | bool isOgreToBeShutDown()const{return m_bShutDownOgre;} |
---|
232 | |
---|
233 | bool keyPressed(const OIS::KeyEvent &keyEventRef); |
---|
234 | bool keyReleased(const OIS::KeyEvent &keyEventRef); |
---|
235 | |
---|
236 | bool mouseMoved(const OIS::MouseEvent &evt); |
---|
237 | bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id); |
---|
238 | bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id); |
---|
239 | |
---|
240 | Ogre::Root* m_pRoot; |
---|
241 | Ogre::SceneManager* m_pSceneMgr; |
---|
242 | Ogre::RenderWindow* m_pRenderWnd; |
---|
243 | Ogre::Camera* m_pCamera; |
---|
244 | Ogre::Viewport* m_pViewport; |
---|
245 | Ogre::Log* m_pLog; |
---|
246 | Ogre::Timer* m_pTimer; |
---|
247 | |
---|
248 | Ogre::Camera* m_pCameraCopy ; |
---|
249 | Ogre::Camera* m_pCameraNoJitter ; |
---|
250 | |
---|
251 | float m_flAspectRatio ; |
---|
252 | float m_flFOV ; |
---|
253 | |
---|
254 | |
---|
255 | //RawFilePtr m_pRawBspFile ; bool m_bRawBspFileIsLoaded ; |
---|
256 | |
---|
257 | char *m_pRawBspFile ; |
---|
258 | bool m_bRawBspFileIsLoaded ; |
---|
259 | |
---|
260 | OIS::InputManager* m_pInputMgr; |
---|
261 | OIS::Keyboard* m_pKeyboard; |
---|
262 | OIS::Mouse* m_pMouse; |
---|
263 | |
---|
264 | int nMap ; |
---|
265 | Ogre::String m_MapName ; |
---|
266 | int m_nLoadToggle ; |
---|
267 | |
---|
268 | int m_nJumpToggle ; |
---|
269 | int m_nJumpVal; |
---|
270 | |
---|
271 | int m_nToggle ; |
---|
272 | |
---|
273 | void UnloadMap(bool bShutdown) ; |
---|
274 | int LoadMap(void) ; |
---|
275 | int m_nMapLoaded ; |
---|
276 | |
---|
277 | int m_nDebugLightBox ; |
---|
278 | int m_nZoneCullingActive ; |
---|
279 | int m_nPortalDebug ; |
---|
280 | int m_nPortalToggle ; |
---|
281 | int m_nPortalState ; |
---|
282 | |
---|
283 | // Add this to OgreFramework and initialize it from 0 to MAXGPUQUERY |
---|
284 | // If you're good you'll make it private and add some get/set functions, |
---|
285 | // I just made it public for now. |
---|
286 | |
---|
287 | // A value of 0 means don't mess with the GPU buffers at all. There |
---|
288 | // might be some systems where the queries cause problems, so let the user |
---|
289 | // deactivate the queries completely if desired. |
---|
290 | |
---|
291 | // A value of 1 means we flush every frame, so no GPU command buffering. |
---|
292 | // This is good for low FPS because even just 1 buffer gives noticable |
---|
293 | // input lag. However users with high FPS can afford a few buffers. |
---|
294 | |
---|
295 | int m_nMaxGPUQuery ; |
---|
296 | |
---|
297 | |
---|
298 | int m_nDebugA ; |
---|
299 | int m_nDebugB ; |
---|
300 | int m_nDebugC ; |
---|
301 | int m_nVisibleLightCount ; |
---|
302 | int m_nVisibleZoneCount ; |
---|
303 | |
---|
304 | float m_flDebugMatrix[4][4] ; |
---|
305 | |
---|
306 | int m_nRecurseCount ; |
---|
307 | char m_chDebug[10240] ; |
---|
308 | float m_flDebug0 ; |
---|
309 | float m_flDebug1 ; |
---|
310 | float m_flDebug2 ; |
---|
311 | float m_flDebug3 ; |
---|
312 | float m_flDebug4 ; |
---|
313 | float m_flDebug5 ; |
---|
314 | |
---|
315 | |
---|
316 | |
---|
317 | Ogre::ManualObject* m_pGoggleL ; |
---|
318 | Ogre::ManualObject* m_pGoggleR ; |
---|
319 | Ogre::SceneNode* m_pNodeGoggles ; |
---|
320 | int m_nGoggleMode ; |
---|
321 | float m_flGoggleAspectRatio ; |
---|
322 | float m_flGoggleZPos ; |
---|
323 | float m_flGoggleXGap ; |
---|
324 | float m_flGoggleXScale ; |
---|
325 | float m_flGoggleYScale ; |
---|
326 | int m_nGoggleTestImage ; |
---|
327 | void DestroyGoggles() ; |
---|
328 | int CreateGogglesTestImage() ; |
---|
329 | int CreateGoggles() ; |
---|
330 | |
---|
331 | |
---|
332 | void UpdateRenderTargets() ; |
---|
333 | |
---|
334 | double m_GameTime ; |
---|
335 | |
---|
336 | char m_chBZNConfig[BZN_CONFIG_SIZE] ; |
---|
337 | void ParseBZNConfig(void) ; |
---|
338 | |
---|
339 | void FinalShutdown(void) ; |
---|
340 | |
---|
341 | private: |
---|
342 | OgreFramework(const OgreFramework&); |
---|
343 | OgreFramework& operator= (const OgreFramework&); |
---|
344 | |
---|
345 | Ogre::Overlay* m_pDebugOverlay; |
---|
346 | Ogre::Overlay* m_pInfoOverlay; |
---|
347 | int m_iNumScreenShots; |
---|
348 | |
---|
349 | bool m_bShutDownOgre; |
---|
350 | |
---|
351 | Ogre::Vector3 m_TranslateVector; |
---|
352 | Ogre::Real m_MoveSpeed; |
---|
353 | Ogre::Degree m_RotateSpeed; |
---|
354 | float m_MoveScale; |
---|
355 | Ogre::Degree m_RotScale; |
---|
356 | |
---|
357 | int m_nKeyDown_Shift ; |
---|
358 | int m_nKeyDown_Ctrl ; |
---|
359 | |
---|
360 | |
---|
361 | |
---|
362 | |
---|
363 | |
---|
364 | //RawFileManager *mRawFileManager; |
---|
365 | |
---|
366 | char* m_TempMem ; |
---|
367 | Q3Map *m_Q3Map; |
---|
368 | |
---|
369 | |
---|
370 | Ogre::SceneNode* m_pCubeNode; |
---|
371 | Ogre::Entity* m_pCubeEntity; |
---|
372 | |
---|
373 | Ogre::SceneNode *m_pOpaqueNode[MAX_ZONE] ; |
---|
374 | int m_nOpaqueNodeUsed[MAX_ZONE] ; |
---|
375 | Ogre::SceneNode *m_pTransNode[MAX_ZONE] ; |
---|
376 | int m_nTransNodeUsed[MAX_ZONE] ; |
---|
377 | Ogre::SceneNode *m_pLampNode[MAX_ZONE] ; |
---|
378 | int m_nLampNodeUsed[MAX_ZONE] ; |
---|
379 | Ogre::SceneNode *m_pGlowNode[MAX_ZONE] ; |
---|
380 | int m_nGlowNodeUsed[MAX_ZONE] ; |
---|
381 | |
---|
382 | Ogre::Matrix4 m_ViewMatrix ; |
---|
383 | Ogre::Matrix4 m_ProjectionMatrix ; |
---|
384 | |
---|
385 | Ogre::ManualObject** m_pZoneMO ; // the Zone's manualObject array |
---|
386 | Ogre::MeshPtr* m_pZoneMesh ; |
---|
387 | Ogre::Entity** m_pZoneEntity ; |
---|
388 | int* m_pZoneEntityMaterialType ; |
---|
389 | |
---|
390 | Ogre::MaterialPtr* m_pZoneEntityMaterial_Base[MAX_PROJECTORTEX] ; |
---|
391 | Ogre::MaterialPtr* m_pZoneEntityMaterial_Fast[MAX_PROJECTORTEX] ; |
---|
392 | |
---|
393 | Ogre::MaterialPtr* m_pZoneEntityMaterial_Black ; |
---|
394 | |
---|
395 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShColour ; |
---|
396 | Ogre::MaterialPtr* m_pZoneEntityMaterial_Shadow ; |
---|
397 | Ogre::MaterialPtr* m_pZoneEntityMaterial_ShadeFront ; |
---|
398 | Ogre::MaterialPtr* m_pZoneEntityMaterial_ShadeBack ; |
---|
399 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShPosition ; |
---|
400 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShDiffuse ; |
---|
401 | //Ogre::MaterialPtr* m_pZoneEntityMaterial_DSNormal ; |
---|
402 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShFuncTNB ; |
---|
403 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShSpecular ; |
---|
404 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShEmissive ; |
---|
405 | //Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShData ; |
---|
406 | Ogre::MaterialPtr* m_pZoneEntityMaterial_DfShMix ; |
---|
407 | |
---|
408 | Ogre::MaterialPtr* m_pZoneEntityMaterial_BlurA ; |
---|
409 | |
---|
410 | |
---|
411 | ///////////////////////////////////////////////////////////////////////////////// |
---|
412 | |
---|
413 | |
---|
414 | |
---|
415 | |
---|
416 | Ogre::MeshPtr* m_pGameMesh ; |
---|
417 | ENTITYINFO* m_pEntityInfo ; |
---|
418 | int* m_pVisibleEntity ; // entities that are in a visible zone |
---|
419 | int* m_pFrustumEntity ; // entities that are in a visible zone and also in the view frustum |
---|
420 | |
---|
421 | int m_nMaxGameMesh ; |
---|
422 | int m_nMaxEntity ; |
---|
423 | int m_nMaxVisibleEntity ; |
---|
424 | int m_nMaxFrustumEntity ; |
---|
425 | int m_nVisibleEntityTriangleCount ; |
---|
426 | int m_nFrustumEntityTriangleCount ; |
---|
427 | int m_nTotalTriangles ; |
---|
428 | int m_nZoneTriangleCount[MAX_ZONE] ; |
---|
429 | |
---|
430 | ///////////////////////////////////////////////////////////////////////////////// |
---|
431 | |
---|
432 | // for debugging/testing, make light volumes into meshes |
---|
433 | Ogre::ManualObject** m_pLightMO ; // the manualObject array |
---|
434 | int AddLightCullingBoxes(void) ; |
---|
435 | |
---|
436 | // for debugging/testing, make portal volumes into meshes |
---|
437 | Ogre::ManualObject** m_pPortalMO ; // the manualObject array |
---|
438 | Ogre::Node** m_pPortalNode ; // the node of this portal |
---|
439 | int AddPortalBoxes(void) ; |
---|
440 | |
---|
441 | ///////////////////////////////////////////////////////////////////////////////// |
---|
442 | |
---|
443 | |
---|
444 | |
---|
445 | |
---|
446 | |
---|
447 | void SetupResourceLocations() ; |
---|
448 | |
---|
449 | |
---|
450 | |
---|
451 | float m_flStereoFrustumTweak ; // in stereoscopic mode the portal frustums might be too tight, so enlarge them a bit. |
---|
452 | |
---|
453 | |
---|
454 | bool m_IsOpenGL ; |
---|
455 | |
---|
456 | |
---|
457 | void initLight() ; |
---|
458 | |
---|
459 | Ogre::Matrix4 CreateTextureViewProjectionMatrix(Ogre::Camera* pCamera) ; |
---|
460 | bool SetupSingleVisibleLightAndShadowCamera(int nLt, char* pLightVis, unsigned short* pVisibleLightList, Ogre::Camera* pCamera) ; |
---|
461 | |
---|
462 | |
---|
463 | int SetupParticles() ; |
---|
464 | Ogre::ParticleSystem* m_ps; |
---|
465 | Ogre::SceneNode* m_pParticleNode; |
---|
466 | |
---|
467 | int m_nMaxParticleSystem ; |
---|
468 | |
---|
469 | |
---|
470 | int ConstructMapFromTriangles(void) ; |
---|
471 | |
---|
472 | int SetupGameEntities(void) ; |
---|
473 | int SetupEntity(int nEntity, char *chMeshName) ; |
---|
474 | |
---|
475 | |
---|
476 | |
---|
477 | int m_nKeyToggle[OIS::KC_MEDIASELECT+1] ; // for preventing multiple key triggers when needed. |
---|
478 | |
---|
479 | int m_nFlashLight ; |
---|
480 | |
---|
481 | |
---|
482 | |
---|
483 | |
---|
484 | |
---|
485 | |
---|
486 | |
---|
487 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
488 | |
---|
489 | // left/mono visibility info |
---|
490 | char m_chZoneVisL[MAX_ZONE] ; |
---|
491 | char m_chLightVisL[MAX_LIGHT] ; |
---|
492 | char m_chSubLightVisL[MAX_SUBLIGHT] ; |
---|
493 | char m_chPortalVisL[MAX_PORTAL] ; |
---|
494 | int m_nMaxVisibleZoneL ; |
---|
495 | unsigned short m_uVisibleZoneListL[MAX_ZONE] ; // if MAX_ZONE goes above 65536 this will need to change to an int |
---|
496 | int m_nMaxVisibleLightL ; |
---|
497 | unsigned short m_uVisibleLightListL[MAXVISIBLELIGHT]; // if MAX_LIGHT goes above 65536 this will need to change to an int |
---|
498 | int m_nCameraZoneL ; // zone player left eye is in. |
---|
499 | |
---|
500 | // right visibility info |
---|
501 | char m_chZoneVisR[MAX_ZONE] ; |
---|
502 | char m_chLightVisR[MAX_LIGHT] ; |
---|
503 | char m_chSubLightVisR[MAX_SUBLIGHT] ; |
---|
504 | char m_chPortalVisR[MAX_PORTAL] ; |
---|
505 | int m_nMaxVisibleZoneR ; |
---|
506 | unsigned short m_uVisibleZoneListR[MAX_ZONE] ; // if MAX_ZONE goes above 65536 this will need to change to an int |
---|
507 | int m_nMaxVisibleLightR ; |
---|
508 | unsigned short m_uVisibleLightListR[MAXVISIBLELIGHT]; // if MAX_LIGHT goes above 65536 this will need to change to an int |
---|
509 | int m_nCameraZoneR ; // zone player right eye is in. |
---|
510 | |
---|
511 | int m_nCameraZone ; // zone player is in. |
---|
512 | |
---|
513 | |
---|
514 | |
---|
515 | |
---|
516 | |
---|
517 | char* m_pGlobal_ZoneVis ; |
---|
518 | char* m_pGlobal_LightVis ; |
---|
519 | unsigned short* m_pGlobal_VisibleZoneList ; |
---|
520 | int* m_pGlobal_MaxVisibleZone ; |
---|
521 | unsigned short* m_pGlobal_VisibleLightList ; |
---|
522 | int* m_pGlobal_MaxVisibleLight ; |
---|
523 | |
---|
524 | char m_chPortalState[MAX_PORTAL] ; |
---|
525 | |
---|
526 | int m_nMaxVisibleLight ; |
---|
527 | |
---|
528 | |
---|
529 | |
---|
530 | |
---|
531 | |
---|
532 | |
---|
533 | |
---|
534 | int m_nZoneMOStart[MAX_ZONE+1] ; // index into m_pZoneMO for each zone, since each material within a zone is another manualObject. |
---|
535 | |
---|
536 | void CalculateZoneVisibility(Ogre::Camera* pCamera, int *pCameraZone, char* pZoneVis, char* pLightVis, char* pSubLightVis, char* pPortalVis, int* pMaxVisibleLight, unsigned short* pVisibleLightList) ; |
---|
537 | void SetupEntityZones(void) ; |
---|
538 | void CalculateEntityVisibility(Ogre::Camera* pCamera, char* pZoneVis) ; |
---|
539 | |
---|
540 | void SetAllLightsOff(void) ; |
---|
541 | void SetSingleVisibleLight(int nLt, bool bOn) ; |
---|
542 | void UpdateVisibleZoneList(char* pZoneVis, unsigned short* pVisibleZoneList, int* pMaxVisibleZone) ; |
---|
543 | |
---|
544 | void SetZoneNodeAttachments(unsigned short* pVisibleZoneList, int* pMaxVisibleZone, int nMaterialFlags) ; |
---|
545 | void SetZoneNodeAttachments(unsigned short* pVisibleZoneList, int* pMaxVisibleZone, int nMaterialFlags, int nLight) ; |
---|
546 | bool LightTouchesZone(int nLight, int nZone) ; |
---|
547 | |
---|
548 | void PortalScan(Ogre::Camera *pCamera, int nZone, Ogre::Real ScaleX, Ogre::Real ScaleY, char* pZoneVis, char* pLightVis, char* pSubLightVis, char* pPortalVis, int* pMaxVisibleLight, unsigned short* pVisibleLightList) ; |
---|
549 | int m_nOriginalZoneOpenPortals ; |
---|
550 | void CheckMultiZoneLights(int nCameraZone, char* pZoneVis, char* pLightVis, char* pSubLightVis) ; |
---|
551 | void AddZonesFromMultiZoneLights(char* pZoneVis, char* pLightVis, char* pSubLightVis) ; |
---|
552 | int CalculatePortalFrustum(Ogre::Camera *pCamera, int nPortal, Ogre::Real* pPortalL, Ogre::Real* pPortalR, Ogre::Real* pPortalT, Ogre::Real* pPortalB, Ogre::Real ScaleX, Ogre::Real ScaleY) ; |
---|
553 | |
---|
554 | |
---|
555 | |
---|
556 | |
---|
557 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
558 | |
---|
559 | |
---|
560 | |
---|
561 | |
---|
562 | //int ApplyCGDefines(void) ; |
---|
563 | |
---|
564 | |
---|
565 | |
---|
566 | |
---|
567 | int m_nSpeedRender ; |
---|
568 | int m_nRenderHDR ; |
---|
569 | int m_nColouredShadow ; |
---|
570 | int m_nShadowMapSize ; |
---|
571 | int m_nShadowRGBSize ; |
---|
572 | |
---|
573 | int m_nDisplayInfoMode ; |
---|
574 | |
---|
575 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
576 | // render to texture quasi-deferred shading stuff |
---|
577 | |
---|
578 | void CreateRTTAssets() ; |
---|
579 | void DestroyRTTAssets() ; |
---|
580 | int m_nRTTAssetsExist ; |
---|
581 | |
---|
582 | // Shadow |
---|
583 | Rectangle2D* miniScreen_Shadow; |
---|
584 | Ogre::SceneNode* miniScreenNode_Shadow; |
---|
585 | Ogre::TexturePtr RTT_Texture_Shadow ; |
---|
586 | Ogre::RenderTexture* renderTexture_Shadow ; |
---|
587 | Ogre::MaterialPtr RTT_Mat_Shadow ; |
---|
588 | Ogre::Technique* RTT_Technique_Shadow ; |
---|
589 | |
---|
590 | // ShadeFront |
---|
591 | Rectangle2D* miniScreen_ShadeFront; |
---|
592 | Ogre::SceneNode* miniScreenNode_ShadeFront; |
---|
593 | Ogre::TexturePtr RTT_Texture_ShadeFront ; |
---|
594 | Ogre::RenderTexture* renderTexture_ShadeFront ; |
---|
595 | Ogre::MaterialPtr RTT_Mat_ShadeFront ; |
---|
596 | Ogre::Technique* RTT_Technique_ShadeFront ; |
---|
597 | |
---|
598 | // ShadeBack |
---|
599 | Rectangle2D* miniScreen_ShadeBack; |
---|
600 | Ogre::SceneNode* miniScreenNode_ShadeBack; |
---|
601 | Ogre::TexturePtr RTT_Texture_ShadeBack ; |
---|
602 | Ogre::RenderTexture* renderTexture_ShadeBack ; |
---|
603 | Ogre::MaterialPtr RTT_Mat_ShadeBack ; |
---|
604 | Ogre::Technique* RTT_Technique_ShadeBack ; |
---|
605 | |
---|
606 | // DfShPosition |
---|
607 | Rectangle2D* miniScreen_DfShPosition; |
---|
608 | SceneNode* miniScreenNode_DfShPosition; |
---|
609 | TexturePtr RTT_Texture_DfShPosition ; |
---|
610 | RenderTexture* renderTexture_DfShPosition ; |
---|
611 | MaterialPtr RTT_Mat_DfShPosition ; |
---|
612 | Technique* RTT_Technique_DfShPosition ; |
---|
613 | RenderTargetListener* Listener_DfShPosition ; |
---|
614 | |
---|
615 | // DfShDiffuse |
---|
616 | Rectangle2D* miniScreen_DfShDiffuse; |
---|
617 | Ogre::SceneNode* miniScreenNode_DfShDiffuse; |
---|
618 | Ogre::TexturePtr RTT_Texture_DfShDiffuse ; |
---|
619 | Ogre::RenderTexture* renderTexture_DfShDiffuse ; |
---|
620 | Ogre::MaterialPtr RTT_Mat_DfShDiffuse ; |
---|
621 | Ogre::Technique* RTT_Technique_DfShDiffuse ; |
---|
622 | |
---|
623 | /* |
---|
624 | // DSNormal // UNUSED |
---|
625 | Rectangle2D* miniScreen_DSNormal; |
---|
626 | Ogre::SceneNode* miniScreenNode_DSNormal; |
---|
627 | Ogre::TexturePtr RTT_Texture_DSNormal ; |
---|
628 | Ogre::RenderTexture* renderTexture_DSNormal ; |
---|
629 | Ogre::MaterialPtr RTT_Mat_DSNormal ; |
---|
630 | Ogre::Technique* RTT_Technique_DSNormal ; |
---|
631 | */ |
---|
632 | |
---|
633 | // DfShFuncTNB |
---|
634 | Rectangle2D* miniScreen_DfShFuncTNB; |
---|
635 | Ogre::SceneNode* miniScreenNode_DfShFuncTNB; |
---|
636 | Ogre::TexturePtr RTT_Texture_DfShFuncTNB ; |
---|
637 | Ogre::RenderTexture* renderTexture_DfShFuncTNB ; |
---|
638 | Ogre::MaterialPtr RTT_Mat_DfShFuncTNB ; |
---|
639 | Ogre::Technique* RTT_Technique_DfShFuncTNB ; |
---|
640 | |
---|
641 | // DfShSpecular |
---|
642 | Rectangle2D* miniScreen_DfShSpecular; |
---|
643 | Ogre::SceneNode* miniScreenNode_DfShSpecular; |
---|
644 | Ogre::TexturePtr RTT_Texture_DfShSpecular ; |
---|
645 | Ogre::RenderTexture* renderTexture_DfShSpecular ; |
---|
646 | Ogre::MaterialPtr RTT_Mat_DfShSpecular ; |
---|
647 | Ogre::Technique* RTT_Technique_DfShSpecular ; |
---|
648 | |
---|
649 | // DfShEmissive |
---|
650 | Rectangle2D* miniScreen_DfShEmissive; |
---|
651 | Ogre::SceneNode* miniScreenNode_DfShEmissive; |
---|
652 | Ogre::TexturePtr RTT_Texture_DfShEmissive ; |
---|
653 | Ogre::RenderTexture* renderTexture_DfShEmissive ; |
---|
654 | Ogre::MaterialPtr RTT_Mat_DfShEmissive ; |
---|
655 | Ogre::Technique* RTT_Technique_DfShEmissive ; |
---|
656 | |
---|
657 | // DfShLamp |
---|
658 | Rectangle2D* miniScreen_DfShLamp; |
---|
659 | Ogre::SceneNode* miniScreenNode_DfShLamp; |
---|
660 | Ogre::TexturePtr RTT_Texture_DfShLamp ; |
---|
661 | Ogre::RenderTexture* renderTexture_DfShLamp ; |
---|
662 | Ogre::MaterialPtr RTT_Mat_DfShLamp ; |
---|
663 | Ogre::Technique* RTT_Technique_DfShLamp ; |
---|
664 | |
---|
665 | /* |
---|
666 | // DfShData |
---|
667 | Rectangle2D* miniScreen_DfShData; |
---|
668 | Ogre::SceneNode* miniScreenNode_DfShData; |
---|
669 | Ogre::TexturePtr RTT_Texture_DfShData ; |
---|
670 | Ogre::RenderTexture* renderTexture_DfShData ; |
---|
671 | Ogre::MaterialPtr RTT_Mat_DfShData ; |
---|
672 | Ogre::Technique* RTT_Technique_DfShData ; |
---|
673 | */ |
---|
674 | |
---|
675 | // DfShMix |
---|
676 | Rectangle2D* miniScreen_DfShMix; |
---|
677 | Ogre::SceneNode* miniScreenNode_DfShMix; |
---|
678 | Ogre::TexturePtr RTT_Texture_DfShMix ; |
---|
679 | Ogre::RenderTexture* renderTexture_DfShMix ; |
---|
680 | Ogre::MaterialPtr RTT_Mat_DfShMix ; |
---|
681 | Ogre::Technique* RTT_Technique_DfShMix ; |
---|
682 | |
---|
683 | |
---|
684 | // DfShTemp |
---|
685 | Rectangle2D* miniScreen_DfShTemp; |
---|
686 | Ogre::SceneNode* miniScreenNode_DfShTemp; |
---|
687 | Ogre::TexturePtr RTT_Texture_DfShTemp ; |
---|
688 | Ogre::RenderTexture* renderTexture_DfShTemp ; |
---|
689 | Ogre::MaterialPtr RTT_Mat_DfShTemp ; |
---|
690 | Ogre::Technique* RTT_Technique_DfShTemp ; |
---|
691 | |
---|
692 | Rectangle2D* miniScreen_DfShMaster; |
---|
693 | Ogre::SceneNode* miniScreenNode_DfShMaster; |
---|
694 | |
---|
695 | int m_nRTTWidth ; |
---|
696 | int m_nRTTHeight ; |
---|
697 | |
---|
698 | // blur for hdr |
---|
699 | Rectangle2D* miniScreen_BlurA; |
---|
700 | Ogre::SceneNode* miniScreenNode_BlurA; |
---|
701 | Ogre::TexturePtr RTT_Texture_BlurA ; |
---|
702 | Ogre::RenderTexture* renderTexture_BlurA ; |
---|
703 | Ogre::MaterialPtr RTT_Mat_BlurA ; |
---|
704 | Ogre::Technique* RTT_Technique_BlurA ; |
---|
705 | |
---|
706 | Rectangle2D* miniScreen_BlurB; |
---|
707 | Ogre::SceneNode* miniScreenNode_BlurB; |
---|
708 | Ogre::TexturePtr RTT_Texture_BlurB ; |
---|
709 | Ogre::RenderTexture* renderTexture_BlurB ; |
---|
710 | Ogre::MaterialPtr RTT_Mat_BlurB ; |
---|
711 | Ogre::Technique* RTT_Technique_BlurB ; |
---|
712 | |
---|
713 | |
---|
714 | |
---|
715 | Ogre::MaterialPtr pClearMaterial ; |
---|
716 | |
---|
717 | |
---|
718 | }; |
---|
719 | |
---|
720 | //||||||||||||||||||||||||||||||||||||||||||||||| |
---|
721 | |
---|
722 | #endif |
---|
723 | |
---|
724 | //||||||||||||||||||||||||||||||||||||||||||||||| |
---|