Skip to main content

History: PyExample

Source of version: 2 (current)

Copy to clipboard
            __PyOgre__ example (\Python24\pyogre\demos):

{CODE(wrap="1", colors="python")} # This code is a complete OGRE application with a space sky plane
 # and a dragon in the middle of the space
 # move your camera with the mouse and use W-A-S-D keys
{CODE}
Don't forget to install prior to starting the example listed below:
* [http://www.python.org/download/|Python 2.4]
* [http://psyco.sourceforge.net/|Psyco]
* [https://developer.berlios.de/projects/pyogre/|PyOgre (Media + PyOgre)] (unzip the media folder to ''C:\Python24\pyogre\demos'')



{CODE(wrap="1", colors="python")} import pyogre.ogre as ogre
 import SampleFramework as sf
 
 class SkyPlaneApplication(sf.Application):
     def _createScene( self ):
         sceneManager = self.sceneManager
         camera = self.camera
         
         sceneManager.ambientLight = (0.5, 0.5, 0.5)   
 
         plane = ogre.Plane()
         n = plane.normal
         n.x, n.y, n.z = 0, -1, 0
         plane.d = 5000
         #sceneManager.setSkyDome(True, 'Examples/CloudySky', 5, 8)
         sceneManager.setSkyPlane(True, plane, 'Examples/SpaceSkyPlane', 10000, 3)
  
         light = sceneManager.createLight('MainLight')
         light.position = (20, 80, 50) 
 
         entity = sceneManager.createEntity('dragon', 'Cube.mesh')
         sceneManager.rootSceneNode.attachObject(entity)
 
 if __name__ == '__main__':
     application = SkyPlaneApplication()
     application.go()
{CODE}
To run this application, go to folder C:\Python24\pyogre\demos and start one of the example applications (files ending *.py) by typing:
{CODE(wrap="1", colors="python")} python SkyPlaneApplication.py
{CODE}