source: OGRE/trunk/ogrenew/Samples/BSP/src/BSP.cpp @ 692

Revision 692, 3.9 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10You may use this sample code for anything you like, it is not covered by the
11LGPL like the rest of the engine.
12-----------------------------------------------------------------------------
13*/
14
15#include "Ogre.h"
16#include "ExampleApplication.h"
17#include "ExampleLoadingBar.h"
18
19/**
20    \file
21        BSP.cpp
22    \brief
23        Shows the indoor level rendering (Binary Space Partition or BSP based).
24    \par
25        Also demonstrates loading levels from Quake3Arena and using
26        curved bezier surfaces (as demonstrated in the Bezier example)
27        in a large level.
28*/
29
30class BspApplication : public ExampleApplication
31{
32public:
33        BspApplication()
34        {
35
36
37        }
38
39protected:
40
41        String mQuakePk3;
42        String mQuakeLevel;
43        ExampleLoadingBar mLoadingBar;
44
45        void loadResources(void)
46        {
47
48                mLoadingBar.start(mWindow, 1, 1, 0.75);
49
50                // Turn off rendering of everything except overlays
51                mSceneMgr->clearSpecialCaseRenderQueues();
52                mSceneMgr->addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
53                mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
54
55                // Set up the world geometry link
56                ResourceGroupManager::getSingleton().linkWorldGeometryToResourceGroup(
57                        ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
58                        mQuakeLevel, mSceneMgr);
59
60                // Initialise the rest of the resource groups, parse scripts etc
61                ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
62                ResourceGroupManager::getSingleton().loadResourceGroup(
63                        ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
64                        false, true);
65
66                // Back to full rendering
67                mSceneMgr->clearSpecialCaseRenderQueues();
68                mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
69
70                mLoadingBar.finish();
71
72
73        }
74
75        // Override resource sources (include Quake3 archives)
76        void setupResources(void)
77        {
78
79                // Load Quake3 locations from a file
80                ConfigFile cf;
81
82                cf.load("quake3settings.cfg");
83
84                mQuakePk3 = cf.getSetting("Pak0Location");
85                mQuakeLevel = cf.getSetting("Map");
86
87                ExampleApplication::setupResources();
88                ResourceGroupManager::getSingleton().addResourceLocation(
89                        mQuakePk3, "Zip", ResourceGroupManager::getSingleton().getWorldResourceGroupName());
90
91        }
92        // Override scene manager (use indoor instead of generic)
93        void chooseSceneManager(void)
94        {
95                mSceneMgr = mRoot->createSceneManager("BspSceneManager");
96        }
97        // Scene creation
98        void createScene(void)
99        {
100
101                // modify camera for close work
102                mCamera->setNearClipDistance(4);
103                mCamera->setFarClipDistance(4000);
104
105                // Also change position, and set Quake-type orientation
106                // Get random player start point
107                ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
108                mCamera->setPosition(vp.position);
109                mCamera->pitch(Degree(90)); // Quake uses X/Y horizon, Z up
110                mCamera->rotate(vp.orientation);
111                // Don't yaw along variable axis, causes leaning
112                mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);
113
114
115        }
116
117};
118
119
120#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
121#define WIN32_LEAN_AND_MEAN
122#include "windows.h"
123
124INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
125#else
126int main(int argc, char**argv)
127#endif
128{
129    // Create application object
130    BspApplication app;
131
132    try {
133        app.go();
134    } catch( Ogre::Exception& e ) {
135#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
136        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
137#else
138        std::cerr << "An exception has occured: " <<
139            e.getFullDescription().c_str() << std::endl;
140#endif
141    }
142
143    return 0;
144}
Note: See TracBrowser for help on using the repository browser.