addPoly in OgreNewt

jaaku1111

28-01-2008 00:29:03

Hey guys,
I'm trying to create a triangle collision manually (for collisions with an ET terrain) anyway stripping out everything else, my basic test of adding a poly looks like this:

col = OgreNewt.TreeCollision(self.World)
col.start()
pols = [ogre.Vector3(0,1,0),ogre.Vector3(200,1,200),ogre.Vector3(0,1,200) ]
col.addPoly( pols[0] ,0 )
col.finish()



obviously the pols[0] isn't emulating the pointer to a vector3 array properly, anyone have an idea how I should pass it in?

Thanks!

bharling

28-01-2008 10:05:55

by the looks of things you're just giving it a single vector3 element. pols[0] is just the first element in the list. you need to do


col.addPoly( pols, 0 )


that should pass the list of 3 vectors instead, which is what i think you need to do :)

if that doesn't work try:


col.addPoly( *pols, 0 )

jaaku1111

28-01-2008 12:30:58

Thanks for the speedy reply!


well when I try sending the whole list I get this error:

File "survive.py", line 272, in createScene
col.addPoly( pols ,0)
Boost.Python.ArgumentError: Python argument types in
TreeCollision.addPoly(TreeCollision, list, int)
did not match C++ signature:
addPoly(class OgreNewt::CollisionPrimitives::TreeCollision {lvalue}, class O
gre::Vector3 * polys, unsigned int ID)


Seems it can't translate the list into an array pointer...

putting a * in front of polys gives me a syntax error (is there some lib or something that I'm not using I could look into that would fix this?)

SiWi

28-01-2008 14:26:16

why not:
for poly in pols:
col.addPoly(poly,0)

jaaku1111

28-01-2008 22:50:44

well each element in pols is a ogre.Vector3, so its not enough to describe the entire polygon (it needs at least 3) the pols[0] actually 'runs' but the poly comes out all funky (only one vert is actually from what I pass in, rest I guess is garbage?)

I've tried looking at some of the python ctype stuff (couldn't figure it out, although there might be a solution somewhere in there) the documentation is somewhat slim in that area. I've also done some pretty extensive searches, but come up with little for a python solution (I'm actually somewhat converting a c++ solution in another post)

I've tried lists and tuples, tried the pols[0]...

has anyone done this? (gotten ET terrain data into newton, or another physics engine) in python-ogre? if/when I ever figure this out, I'll make sure and post my solution.

andy

29-01-2008 06:26:15

Looks like I'll have to wrap it..

From a code generate perspective we can't (automatically) tell that it's a pointer to a single instance of a Ogre::Vector3 or as in this case is actually a pointer to Ogre::Vector3[3]..

I'll have a look at fixing it in the SVN and it will be in the next binary release

Andy

jaaku1111

29-01-2008 20:26:28

Awesome, thanks Andy.

In the mean time, i've come up with sort of an ugly work around, I create a manualobject, and then create an entity from that, and then pass that through the 'standard treecollision' function (avoiding the addPoly method) this allows me to get it working, however the manual object has a limit on the verts (256x256) so all you can do is 129x129. I'm looking at making multiple patches to cover a larger terrain (probably the best way to go anyway for speed)

After I clean this up I'll post it.



http://img413.imageshack.us/my.php?image=boxesonetmx6.gif

Here you can see the debug lines from OgreNewt, and some boxes that are falling into the ET map (I just applied a sin wave to give it some texture)

bharling

29-01-2008 23:32:03

You'd probably want to 'page' your terrain collision anyway somehow, I imagine having a treecollision for an entire large landscape in one object would not be practical from a memory usage perspective.

That said, have you tried the 'vertexBuffer method' of creating a mesh? I'm not sure, but I think that you don't have a limited number of verts as you do with manualObject.

good workaround tho :)

andy

30-01-2008 00:16:34

The fix to addPoly is in the SVN (untested) -- it now takes a list of Vector3's plus the ID as arguments.

The list needs to have at least 3 Vector3's in it (and only the first 3 are used)...

Andy