Using Pyogre with game logic

Jedo

23-02-2006 14:40:09

It seems that all of the pyogre tutorials here are about how to do stuff inside of ogre. However, I haven't really seen anything that describes how Pyogre communicates with the python game code.

I would think it would be like; events would need to happen then they would trigger certain things in pyogre.
For example, the user's HP would reach 0 and the code would tell pyogre to begin the death animation

Could someone point to information on how pyogre interacts with the main game code.

Thanks

Kerion

24-02-2006 01:08:34

I am curious about this as well. I would like to use PyOGRE to simply expose OGRE functionality to my game logic code. For instance, when a designer is writing code for a new Actor type (lets say, Monster), he simply extends the Actor class and implements it's event handling structure...but he may need to get at the OGRE internals, such as the scene node, or the animation state. As the above poster said, he may need to play the death animation (though we hope this would be a more standard action handled by a super class).

griminventions

24-02-2006 12:59:37

Well that's what a game framework does. :) You have to create an event system, an entity manager, input handling, etc etc. Ogre doesn't provide any game logic at all, other than what's necessary for rendering and minimal input.

Jedo

24-02-2006 13:14:27

So, if I just import the ogre script in the logic file I'll have access to all the entity varibles and such?

griminventions

24-02-2006 13:28:24

Yes, you just
import pyogre.ogre as ogre
and then (for example)
root = ogre.Root( ogre.getPluginPath() )
root.doOgreStuff()

or any other Ogre system is accessible that way.
Or, if you are using the sample application framework, you just import that file and all its variables, classes, and functions are available.

You might want to brush up on basic Python to get going. :)

Kerion

24-02-2006 15:40:52

Well that's what a game framework does. :) You have to create an event system, an entity manager, input handling, etc etc. Ogre doesn't provide any game logic at all, other than what's necessary for rendering and minimal input.

Right, I understand all of that, which is why I have all of those systems in various forms of completeness in my engine.

I just want to know that my scripters can do something like:


class SlimyMonster(Actor):
def onAIUpdate(self, amt):
if self.getEntity().isVisible():
self.getEntity().setCastShadows(1)


Obviously that is just random psuedo-style code, I doubt anyone would ever really write something akin to that, but you get where I am going.

My game framework will handle actually managing the actors and events, but I want the scripters to have access to the lower level OGRE objects, so they can manipulate the scene graph if they need to. From what I understand, I can use PyOGRE for this very thing....though, the more I think about it, the more I realize I may want to use parts of PyOGRE but not all of it. I don't know if I want scripters having access to the Root object and things of that nature. I will just have to play with it :)

griminventions

25-02-2006 01:16:15

PyOgre has access to pretty much everything that you can access in C++.

OvermindDL1

03-03-2006 09:23:17

Now just need a convienient way to plug it into a current application rather then purely extending. :)

willism

18-03-2006 16:14:46

Are we talking about initial game development, or the ability for end users to easily "mod" the game? If it's mainly the initial game development, I would suggest implementing a Model-View-Controller pattern. Ogre would serve as the view. The controller would be either Ogre's simple input event system, or CEGUI. The model would then be where your game-domain data and logic lives.

I would develop some sort of game-domain event system, in which the model publishes events to the view (i.e. "Actor X was spawned", "Door Y just opened", "Actor Z has died", etc.). Then have the view (the PyOgre code) know how to represent those events graphically.

If you're not familiar with MVC, do some google searching on it, there's plenty of talk about it in documents, tutorials, and blogs.