If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
Table of contents
Intro
This is a really sparse example based on the Practical Application tutorial
by Gregory Junker. I haven't used his exact structure, but you will be able to achieve the same thing, which is to start OGRE without the configuration dialog popping up.
Code
import pyogre.ogre as ogre class testApp( object ): def __init__( self ): self.root = ogre.Root( ogre.getPluginPath() ) self._initResources() self._configure() self.root.initialise( False ) self.window = self.root.createRenderWindow( "PyOgreWindow", 640, 480, False ) self.sceneManager = self.root.getSceneManager( ogre.ST_GENERIC ) self.camera = self.sceneManager.createCamera( "PlayerCam" ) self.camera.position = (0, 0, 500) self.camera.lookAt((0, 0, -300)) self.camera.nearClipDistance = 5 self.viewport = self.window.addViewport( self.camera ) self.viewport.backgroundColour = (0, 0, 0) ogre.TextureManager.getSingleton().defaultNumMipmaps = 5 ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups() # create the scene # add a frameListener for input etc, off you go def _initResources( self ): "Set resource group paths." # Set up resource paths configFile = ogre.ConfigFile() configFile.loadFromFile( "resources.cfg" ) # File format is: # [ResourceGroupName] # ArchiveType=Path # .. repeat # For example: # [General] # FileSystem=media/ # Zip=packages/level1.zip for section, key, path in configFile.values: ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section ) def _configure( self ): """ Examine config options and set OGRE options accordingly. For now we're going to hard-code the settings just to prove the concept. """ renList = self.root.getAvailableRenderers() for r in renList: #print r.name if r.name.startswith( "OpenGL" ): self.root.renderSystem = r return print "OpenGL renderer not found!" if __name__ == "__main__": ta = testApp()
Discussion
It will look for "resources.cfg" in the same directory as the .py file. (This is true on Windows, at least. Other platforms might not behave the same way, so you may need to tell Python the path to the current directory.)
Obviously this could be expanded a lot, modularized, and generally made more flexible (especially the _configure() function). But the point of this was to do things in a straight-forward manner in order to learn quickly.
-by Jason, from Grim Inventions Interactive
Contributors to this page: jacmoe
and
OgreWikiBot
.
Page last modified on Thursday 31 of December, 2009 03:21:48 UTC by jacmoe
.
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.

