[SOLVED]ogreNewt set world size

saladin

19-11-2007 13:31:25

Hi,

I was working on terrain clamping for my project which uses python-ogre ogreNewt. At the start of my program immediately after I created the physics world I set its size like this:
self.worldAABB = ogre.AxisAlignedBox(ogre.Vector3(-400, -400, -400), ogre.Vector3(400, 400, 400))
self.physicsWorld.setWorldSize(self.worldAABB)

But when running the program I found that the world size is still around (-100, -100, -100) to (100, 100, 100) which might be the default newton world size. And strangely if I call the set size code again during runtime in the pycrust console, the world size seems to be changed correctly.

I'm wondering if this has anything to do with the fact that OgreNewt.World's NewtonWorld member variable in C++ is not wrapped to be a python object. (call getNewtonWorld() on OgreNewt.World gives an error) Maybe someone can wrap that in the coming release as it is very important that the programmer can set and get physics world boundary reliably.

Any help will be enormously appreciated.

andy

19-11-2007 13:56:30

How do you know if the world size it right or wrong ?

I've looked at the underlying code and I don't see how the Python wrapper can be impacting anything ??

Perhaps if you could give me some test code I can have a better look.

As for wrapping Newton directly (which is what you need to get a NewtonWorld) I originally didn't want to do it because of the Newton license limitations and I recall the library wasn't overly pretty :)

However I'll take another look to check

Andy

saladin

19-11-2007 23:51:36

How do you know if the world size it right or wrong ?

I've looked at the underlying code and I don't see how the Python wrapper can be impacting anything ??

Perhaps if you could give me some test code I can have a better look.

As for wrapping Newton directly (which is what you need to get a NewtonWorld) I originally didn't want to do it because of the Newton license limitations and I recall the library wasn't overly pretty :)

However I'll take another look to check

Andy


Hi, thanks for the quick reply.

Maybe I should go in to a bit more details, as I previously mentioned, I was implementing terrain clamping in my software. The terrain is a hilly mesh, which has a trimesh Newton geometry. All other objects are supposed to clamp to the terrain when they're being placed.

When I move an object, a ray is casted along the -Y axis to query for the terrain height directly beneath the object. So when I use the mouse the grab and move the object on the terrain, it follows along the curved profile of the hills and slopes.

At some point it was obvious that whenever I move an object out side of the (-100, -100, -100) (100,100,100) boundary, the ray stops to hit the terrain. And when I change the world size using setWorldSize() in pycrust, it behaves correctly. This made me believe that setting the world size in my code during initialisation didn't take effect.

Since I can't get the NewtonWorld object, there's no way I can find out if that's really the case. As to the NewtonWorld wrapping thing, I was just tossing wild guesses out there in the hope that it may help someone track the problem.

[EDIT] I will try to reproduce the problem in one of the ogreNewt demos by first resizing the world in code and then placing objects 'out of boundary' and let you know the result.

saladin

20-11-2007 03:10:54

Ok, I figured out what's wrong. When I reload scenes I used physicsWorld.destroyAllBodies(). And this obviously has the side-effect of reseting the world dimension. So I simply need to reset the world size afterwards.

So, my bad for jumping to conclusions. Happy py-ogring everyone. :lol: