Python Ogre Documentation

Shaun

14-05-2011 10:27:13

Hi guys I was wondering where is the documentation of Python Ogre? I can't seem to find any of it, I'm left wondering is there any? Some API reference? Or list of functions, and variables with brief descriptions? How can I map all the functionality at my disposal for Python Ogre at this stage? Am I supposed to use the dir() function and the doc-strings to find out what I all is at my disposal and how I can use it?

iwanantonowitsch

14-05-2011 15:56:05

Use the ogre API in C, its not hard to figure out the equivalents (it's what everyone here does)

Shaun

15-05-2011 05:34:57

Hmmm... I see. Yea that shouldn't be too hard with dir() and __doc__. I hope she's putting doc strings though. They've worked hard on this project.

Mohican

17-05-2011 11:02:06

Using the C API is fairly easy indeed.
The only difficulty I had was when I needed to cast pointers.
In such cases, you use .get() on the pointer.
(It took me hours to find this out...)

iwanantonowitsch

17-05-2011 17:50:07

what are pointers?

Mohican

18-05-2011 05:36:20

what are pointers?

A pointer is the memory address of something (can be a simple variable, or class instance...).
You need to cast it in order to use the pointed object itself.

iwanantonowitsch

18-05-2011 13:11:14

do i need this?

Mohican

18-05-2011 15:50:28

do i need this?

Here is a practical example, from the codebase of our project:

# Disable Normal Mapping (get() casts the pointer!)
if normalTerrain is 0:
matProfile = self.terrainGlobals.getDefaultMaterialGenerator().get().getActiveProfile()
matProfile.setLayerNormalMappingEnabled(False);


Here is the corresponding documentation: Ogre C API

As you can see, the value returned by getDefaultMaterialGenerator() is a 'TerrainMaterialGeneratorPtr'.
The 'Ptr' means that you get a pointer to an instance of the TerrainMaterialGenerator class.

To modify that object, you need first to cast the pointer using .get()
Then .getActiveProfile() is a method from the actual cast object.

dermont

19-05-2011 04:42:25

do i need this?

In most cases casting should be automatically handled by python-ogre so you shouldn't need ".get()" etc. For cases where you need an explicit cast look at the casting member functions e.g. ogre.Bone castAsNode, it should be obvious from there names what they do.

The problem with the above TerrainMaterialGenerator SharedPtr looks to me a bug and
can be easily fixed in the code generators.