panda3d + pyOde

Hi folks… once again i am here.

I searched the forums and web but couldnt make a trimesh collision in panda.

I get the following error:

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    w = World()
  File "/World.py", line 85, in __init__
    self.physics.addTerrain(self.farm)
  File "/Physics.py", line 49, in addTerrain
    td = ode.TriMeshData()
  File "trimesh_dummy.pyx", line 33, in ode.TriMeshData.__init__
TypeError: exceptions must be strings, classes, or instances, not type

This is my code:

import ode
from pandac.PandaModules import *
from direct.task.Task import Task
from direct.interval.IntervalGlobal import *
import Util

class Physics:
    def __init__ (self):
        ## Inicializa física
        self.odeWorld = ode.World()
        self.odeWorld.setGravity((0,0,-9.81))

        self.odeSpace = ode.Space()
        self.odeSpace.enable()

        ## Objetos controlados pela física
        self.objectList = []

        ## Delta de tempo entre calculos
        fps = 50
        self.dt = 1.0 / fps 

        taskMgr.add(self.checkCollisions,"colChecker")

    def addEntity (self, ent):
        ent.nodePath.setPos(0,0,10)
        self.objectList.append(ent)
        ent.odeBody = ode.Body(self.odeWorld)
        M = ode.Mass()
        M.setSphere(2500, 5)
        ent.odeBody.setMass(M)
        ent.odeBody.setPosition((ent.nodePath.getX(),
                                 ent.nodePath.getY(),
                                 ent.nodePath.getZ()))
        
    def checkCollisions (self, task):
        for ent in self.objectList:
            ent.nodePath.setPos(ent.odeBody.getPosition()[0],
                                ent.odeBody.getPosition()[1],
                                ent.odeBody.getPosition()[2])

        self.odeWorld.step(self.dt)
        return Task.cont

    def addTerrain (self, ent):
        points,tris = Util.LerMesh(ent.nodePath)
        td = ode.TriMeshData()
        td.build(points,tris)
        ent.odeGeom = ode.GeomTriMesh(td,self.odeSpace)
        ent.odeGeom.setPosition(ent.nodePath.getPos())
        ent.odeGeom.setQuaternion(ent.nodePath.getQuat())
        ent.odeGeom.name = 'Terrain'

Any tips?

Did you build pyode yourself ?
Which version are you using ?

PyODE will not accept a panda nodepath as an argument. You need to use the ODE integrated with Panda if you want to do that. When you do that in the integrated ODE you pass the model to the GeomTrimesh in two steps:

nodeTrimesh = OdeTriMeshData(modelNodePath, True)
trimeshGeom = OdeTriMeshGeom(myOdeSpace, nodeTrimesh)

I don’t think it’s the problem. That nodepath is not passed to pyode, but to his util.lermesh.
The error is an error when raising an exception, in trimeshdata.init, indicating that trimesh support is not compiled in. There is a proof of that, in setup.py, TRIMESH_ENABLED is set to false.

Doh. I guess thats true. But using PyODE also seems a bit redundant with ODE already being integrated in 1.5.3 unless he’s using an older verson.

thanks a lot for the replys.

The problem is that i didnt build panda. I am using panda-1.5.3.deb for ubuntu feisty.

I am using Ode instead of panda integration because i was getting this error. so i was trying something different

i changed all the ode stuff to panda objects and it executed!!

although i am still having problems with trimesh collision… i did like this:

 54     def addTerrain (self, ent):
 55         ent.nodePath.flattenStrong()
 56         ent.modelTrimesh = OdeTriMeshData(ent.nodePath, True)
 57         ent.modelGeom = OdeTriMeshGeom(self.odeSpace, ent.modelTrimesh)

what more i need to do in order to have an effective trimesh collision?

i manage to make it work… i was not using autoCollide. thanks a lot :slight_smile: