OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: PyOgreDirectorySetup
View page
Source of version: 2
(current)
''Article written by Srekel.'' This is how I set up the directories (and thus the code) for our game. I did it because it was annoying to have the dlls mixed with the source code. Note that I am not sure how this works in Linux; I have only tried it out in Windows so far. Feel free to use the same structure, or change it however you please. {maketoc} !!The directory structure This is what it looks like on our setup: * ViolentWorld\ - root directory ** configs\ - contains ogre configs; plugins.cfg and resources.cfg ** dlls\ - contains ogre dlls (and any other dlls you might use) ** gamedata\ - contain non-media game-related data, such as level information ** media\ - same as the directory that comes with PyOgre, but with added files for the project, of course. :) ** src\ - the python files Now, in order to get this working, there are some things you will need to change in your initialization of Ogre. !!Modifying paths These are things you need to change to get everything to point in the right place. There is one thing that needs to be explained. The application must be started from the "dlls" directory, because it will only look in the directory it starts at for the dll-files. This means that you need to perform some tricks to get stuff working - because you got the source files in "src", right? Well, it's not that difficult. But I'll get to that. * __Creating the root:__ self.root = ogre.Root("../configs/plugins.cfg") * __Setting up resources:__ We've based our code on the PyOgre SampleFramework. You should recognize this method, just change it to the following. {CODE(wrap="1", colors="python")} def _setUpResources(self): """This sets up Ogre's resources, which are required to be in resources.cfg.""" config = ogre.ConfigFile() config.loadFromFile('../configs/resources.cfg' ) for sectionName, mm in config.getSectionIterator(): if mm: for key, path in mm.items(): ogre.ResourceGroupManager.getSingleton().addResourceLocation(path, key, sectionName){CODE} * __Anything else:__ Just remember that the program starts in the dlls-folder, so every path reference should begin there. Usually this means doing something like {CODE(wrap="1", colors="python")} loadData("../myFolder/" + filename) {CODE} !!Running the game As mentioned, you need to run the .py file, but you also need to make the program think it's being run from the dlls-folder. How do you accomplish this? With a .bat file! (Probably works with a shortcut as well). StartGame.bat: {CODE(wrap="1", colors="python")} cd dlls python.exe ..\src\GameApplication.py cd ..{CODE} Place it in the root folder of your project. What it does is go into the dlls-folder, and then starts the application from there. Quite simple. :) !!Making an executable If you want to use this with py2exe, well, here's my setup.py: {CODE(wrap="1", colors="python")} from distutils.core import setup import py2exe setup(windows=["GameApplication.py"]) {CODE} Then I use a makeExe.bat file to make things a little bit easier for me: {CODE(wrap="1", colors="python")} python setup.py py2exe pause echo "copying" copy dist\* ..\dlls echo "done!" pause {CODE} The bat-file is placed in the src-folder. !!End notes That's basically it. There may be better ways to solve this problem that I don't know of - if so, feel free to add something to this page. :)
Search by Tags
Search Wiki by Freetags
Latest Changes
One Function Ogre
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
...more
Search
Find
Advanced
Search Help
Online Users
235 online users