OgreOde -- Python-Ogre problems

cxxD

04-03-2010 15:45:11

Hi guys,

i posted this in the ode-forum but someone advised me to put it here because my problem was more python-ogre-specific...

i tried to use ogreode for my project (written in python-ogre) but somehow i cant run the code, especially this line:

body = ode.Body(world)

i think this is quite an often used line so this has to be my fault (and not ogreode's). Anyone who can help me?
[or someone please do some ogre-ode tutorials, those I've found seem a bit outdated)

I'm using pyogre 1.6

########
edit:
it crashes without any signs in the debug log or something like that... it loads the ressources and then it gets killed... this is weird

when i try to import the module in the shell i get errors but it apparently works when i run the program, the line quoted above does work in shell, too. This is really weird...

it even gets weirder... :) yesterday i could call the body function in the shell... but now its gone... i'm NOT kidding

I tried to figure out what has been done in the demos but somehow 7/9 of my demos contain really stupid mistakes...

dermont

04-03-2010 16:31:00


when i try to import the module in the shell i get errors but it apparently works when i run the program, the line quoted above does work in shell, too. This is really weird...

it even gets weirder... :) yesterday i could call the body function in the shell... but now its gone... i'm NOT kidding


Did you import the ogre module first?

>>>import ogre.renderer.OGRE as ogre
>>>import ogre.physics.OgreOde as OgreOde
>>>dir(OgreOde)



i posted this in the ode-forum but someone advised me to put it here because my problem was more python-ogre-specific...

Did you try the example in the link I posted?


body = ode.Body(world)

When you created the OgreOde world did you try self.world so it stays in scope, e.g:

self.world = OgreOde.World(sceneManager)
..
body = ode.Body(self.world)



I'm using pyogre 1.6

What version of python-ogre are you using 1.6.1 or 1.6.4, maybe a mismatched version of OgreOde, something not updated correctly?

Post a simple self-contained example showing you problem.

cxxD

04-03-2010 17:14:59

I sure did import ogre .. along with several other modules...
i think the scope thing cant be the problem.. its all written in the same function.

ill post the code:

#world
world = ode.World(sceneManager)
world.setGravity(ogre.Vector3(0, -980.665, 0))
world.setCFM(0.00001)
world.setERP(0.8)
world.setAutoSleep(True)
world.setAutoSleepAverageSamplesCount(10)
world.setContactCorrectionVelocity(1.0)

#space
space = world.getDefaultSpace()

#stephandler
timestep = 0.5
timescale = 1.7
maxframetime = 0.25
stepper = ode.StepHandler(world, ode.StepHandler.QuickStep, timestep, maxframetime, timescale)

#objects
th = sceneManager.createEntity("th", "Cube.004.mesh")
th.castShadows = True
thNode = sceneManager.getRootSceneNode().createChildSceneNode("thNode", (200, 900, 200))
thNode.setScale(15, 15, 15)
thNode.attachObject(th)
#body = ode.Body(world)
## thNode.attachObject(body)

## geom = ode.BoxGeometry((10, 10, 10), world, space)
## mass = ode.BoxMass(0.5, (10,10,10))
## body.setMass(mass)
## geom.setBody(body)
## th.setUserObject(geom)


this is directly from the tutorial (which you posted btw)
here i commented out the lines that didnt work...

my version must be 1.6.4 (the last one before 1.7) i downloaded both directories at the same time... so i dont really know how to mismatch something...

andy

06-03-2010 08:59:28

Can you confirm that the demos work ok (in demos/ogreode)... If not what happens when you try and run the demos...

And if so could you post an entire program showing the issue you are having...

Thanks
Andy

cxxD

06-03-2010 10:02:39

no, 7 out of 9 (or 10 or whatever...) don't really work... but when i check the code there are really stupid coding mistakes... But the racing demo for example does work.

well... how i wrote in the other thread it just crashes without any debug log or something like that.. it loads the resources and then it shuts down (the code is shown above and resembles to the tutorial in the wiki)

andy

06-03-2010 13:15:43

OK lets try this a step at a time..

There are 2 demos for ogreode - Demo_GranTurism (which you state works) and Demo_Scenes (there is Demo_Tri but thats more of a 'test').

So does Demo_Scenes work or is it the one with the "really stupid coding mistakes" :) ?

If there are errors with the demos (and assuming you are using the latest Python-Ogre build) perhaps you could post a patch or at least let me know what they are so they can be fixed...

While the code you presented is of interest it is not complete (it doesn't show how you are loading modules, creating the scenemanager etc) so if possible could you post a complete program so that we can take a look at it in it's entirety and see what we can do to help...

Thanks
Andy

cxxD

06-03-2010 13:37:07

ok --- granturismo works fine

the others dont really do what they are supposed to:
-Demoscenes rises a syntax error
-Demotri rises an internal error

so my code for creating the scene manager:
#scenemanager setup
self.sceneManager = self.root.createSceneManager(ogre.ST_GENERIC, "Main SceneManager")
sceneManager = self.sceneManager
sceneManager.shadowTechnique = ogre.SHADOWTYPE_STENCIL_ADDITIVE


my code for importing modules:
try:
import ogre.renderer.OGRE as ogre
import ogre.io.OIS as OIS
import ogre.gui.CEGUI as CEGUI
import ogre.addons.raknet as raknet
import ogre.physics.OgreOde as ode
import random, math , time
except ImportError:
print "importerror"


the scenemanager part is of course followed by the body creation code (not otherwise as expected in the other thread)

#########
edit: sorry i just found out that the syntax error is in the simplescenes.py:

somewhere around here:
if node:
name = node.getName()
num = node.numAttachedObjects()
clearList = [node.getAttachedObject(j)
for j in range(node.numAttachedObjects()):
if node.getAttachedObject(j).getMovableType() != body.getMovableType():
for i in clearList:
if (i.getMovableType() == "Entity") :
print "Deleting " + str(i)
self._mgr.destroyMovableObject(i)
self._mgr.getRootSceneNode().removeAndDestroyChild(name)


ill try to fix the demoscenes - demo and post it to you

andy

06-03-2010 14:23:18

You might also want to grab the latest from the SVN in case it's already been fixed..

Andy

cxxD

06-03-2010 15:28:42

howto??

so.. looks like the svn demos arent broken... :)

i just realized that none of the demos uses the body-function... do i really need it? And if not: how can i achieve the same results without it?

i tried to install the svn version and it seems not to work again.. so they must be broken, too. Could there be a problem with loading times or something like that (because it takes 15 sec. to fire up everything and then it crashes), my computer isn't the fastest :D.

andy

12-03-2010 00:44:03

The problem is that you need to 'self.' some variables as while they are in the same function as soon as you exit the function the underlying C++ variables are deleted and OgreOde (the C++ library) crashes.. You can see how this works in the demo code...

Code needs to look like something like:

#world
self.world = ode.World(sceneManager)
self.world.setGravity(ogre.Vector3(0, -980.665, 0))
self.world.setCFM(0.00001)
self.world.setERP(0.8)
self.world.setAutoSleep(True)
self.world.setAutoSleepAverageSamplesCount(10)
self.world.setContactCorrectionVelocity(1.0)

#space
self.space = self.world.getDefaultSpace()

#stephandler
timestep = 0.5
timescale = 1.7
maxframetime = 0.25
stepper = ode.StepHandler(self.world, ode.StepHandler.QuickStep, timestep, maxframetime, timescale)

#objects
th = sceneManager.createEntity("th", "crate.mesh")
th.castShadows = True
thNode = sceneManager.getRootSceneNode().createChildSceneNode("thNode", (200, 900, 200))
thNode.setScale(15, 15, 15)
thNode.attachObject(th)
self.body = ode.Body(self.world)
thNode.attachObject(self.body)

geom = ode.BoxGeometry((10, 10, 10), self.world, self.space)
mass = ode.BoxMass(0.5, (10,10,10))
self.body.setMass(mass)
geom.setBody(self.body)
th.setUserAny(geom)