User Tools

Site Tools


public:t-gede-13-1:lab5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:t-gede-13-1:lab5 [2013/02/19 12:40] hannespublic:t-gede-13-1:lab5 [2024/04/29 13:33] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== LAB5: Scene Graph ====== ====== LAB5: Scene Graph ======
  
-This lab is based on "Chapter 6: Scene Managers" in the book "Ogre 3d 1.7 Beginner's Guide"+This lab is based on "Chapter 6: Scene Managers" in the book "Ogre 3d 1.7 Beginner's Guide" by Felix Kerger
  
 ===== Discussion ===== ===== Discussion =====
Line 63: Line 63:
 </code> Finally, after we have added all the entities to our ''field'', we need to ask the static geometry to "bake"/optimize with the following call: <code>field->build(); </code> Finally, after we have added all the entities to our ''field'', we need to ask the static geometry to "bake"/optimize with the following call: <code>field->build();
 </code>Now you should try running the scene again and see if there is any improved performance!  </code>Now you should try running the scene again and see if there is any improved performance! 
 +  - **Testing Another Scene Manager** The so called "world geometry" of a game is often considered static and can be highly optimized for rendering. One optimized format for representing a static world is the BSP level format used originally by id's Quake engine. Ogre can read worlds in this format and display them using the ''BspSceneManager''. To try this, add the following method in your application<code> void loadQuakeMap() {     
 + // add the Quake archive to the world resource group
 + Ogre::ResourceGroupManager& rgm = Ogre::ResourceGroupManager::getSingleton();
 + rgm.addResourceLocation("/Development/OgreSDK_vc10_v1-8-1/media/packs/chiropteraDM.pk3", "Zip", rgm.getWorldResourceGroupName(), true);
 + // associate the world geometry with the world resource group, and then load the group
 + rgm.linkWorldGeometryToResourceGroup(rgm.getWorldResourceGroupName(),"maps/chiropteradm.bsp", _sceneManager);
 + rgm.initialiseResourceGroup(rgm.getWorldResourceGroupName());
 + rgm.loadResourceGroup(rgm.getWorldResourceGroupName(), false);
 + }
 +</code>Of course replace the absolute path here with a path that is correct on your system. To initialize the camera to properly view this map (it's actually rotated), add the following camera initialization method:<code> void setupQuakeMapView(Ogre::Camera* cam){
 + // modify camera for close work
 + cam->setNearClipDistance(4);
 + cam->setFarClipDistance(4000);
 + // set a random player starting point
 + Ogre::ViewPoint vp = _sceneManager->getSuggestedViewpoint(true);
 + // Quake uses the Z axis as the up axis, so make necessary adjustments
 + cam->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z);
 + cam->pitch(Ogre::Degree(90));
 + cam->setPosition(vp.position);
 + cam->rotate(vp.orientation);
 + }  
 +</code>
 +Finally, you need to tell Ogre to use the BSP scene manager, which you do when you create your scene manager in the ''startup()'' method of your application. You can name the scene manager explicitly like this:<code>_sceneManager =_root->createSceneManager("BspSceneManager");
 +</code> Now you have everything you need to display the Quake level, all you have to do is to call ''loadQuakeMap()'' and ''setupQuakeMapView(camera) from your ''startup'' method and comment out some of the other things you don't wish to include (e.g. the grass above). Also, you may want to free up the camera movement (i.e. go back to the free mouse movement of camera, instead of having camera following the Ogre).
 +
 +
  
  
/var/www/cadia.ru.is/wiki/data/attic/public/t-gede-13-1/lab5.1361277657.txt.gz · Last modified: 2024/04/29 13:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki