Ode ,hilly surface

Hello,I want to make some hilly surface in odeworld ,how can I do this?

You can use a blender or 3D Max, Maya. Then use the exporter in EGG, then convert the model to OdeTriMeshData. You can also use any supported Panda3D format.

And you should not post such questions in the subject “Scripting Issues”.

Thanks,but I would like to create exactly surface with bounce,friction etc.,or maybe to make some model surface,or at least see(code) how to make 2 or more different surfaces in odeworld.

Please explain again. The point is not clear.

I want to make surface 3d,in the docs (https://docs.panda3d.org/1.10/python/programming/physics/ode/collision-detection#surfaces)
it is explained how to make the surface 2d(example of some random boxes falling down and colliding with the floor).I want to make such floor ,but hilly.

Hmm, these are surface parameters. This is independent of the mesh type or body type.

More precisely, the expression is physical parameters.

Redid the code for 3D Mesh.

from direct.directbase import DirectStart
from panda3d.ode import OdeWorld, OdeSimpleSpace, OdeJointGroup
from panda3d.ode import OdeBody, OdeMass, OdeBoxGeom, OdePlaneGeom, OdeTriMeshData, OdeTriMeshGeom
from panda3d.core import BitMask32, CardMaker, Vec4, Quat
from random import randint, random

# Setup our physics world
world = OdeWorld()
world.setGravity(0, 0, -9.81)

# The surface table is needed for autoCollide
world.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002)

# Create a space and add a contactgroup to it to add the contact joints
space = OdeSimpleSpace()
contactgroup = OdeJointGroup()

# Load the box
box = loader.loadModel("box")
# Make sure its center is at 0, 0, 0 like OdeBoxGeom
box.setPos(-.5, -.5, -.5)
box.flattenLight() # Apply transform

# Add a random amount of boxes
boxes = []
for i in range(randint(15, 30)):
    # Setup the geometry
    boxNP = box.copyTo(render)
    boxNP.setPos(randint(-10, 10), randint(-10, 10), 10 + random())
    boxNP.setColor(random(), random(), random(), 1)
    boxNP.setHpr(randint(-45, 45), randint(-45, 45), randint(-45, 45))
    # Create the body and set the mass
    boxBody = OdeBody(world)
    M = OdeMass()
    M.setBox(50, 1, 1, 1)
    # Create a BoxGeom
    boxGeom = OdeBoxGeom(space, 1, 1, 1)
    boxes.append((boxNP, boxBody))

# Add a plane to collide with
object = loader.loadModel("grid")
groundTrimesh = OdeTriMeshData(object, False)
groundGeom = OdeTriMeshGeom(space, groundTrimesh)
space.setSurfaceType(groundGeom, 0)

# The task for our simulation
def simulationTask(task):
    space.autoCollide() # Setup the contact joints
    # Step the simulation and set the new positions
    for np, body in boxes:
        np.setPosQuat(render, body.getPosition(), Quat(body.getQuaternion()))
    contactgroup.empty() # Clear the contact joints
    return task.cont

# Wait a split second, then start the simulation
taskMgr.doMethodLater(0.5, simulationTask, "Physics Simulation")


Pay attention to how the material was asked.

space.setSurfaceType(groundGeom, 0)

grid.egg (32.9 KB)

1 Like

Thank you ,this is what i was looking for!!

About several surfaces, It is done like this.

# The surface table is needed for autoCollide
world.setSurfaceEntry(1, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002)
world.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002)


space.setSurfaceType(boxGeom, 0)
space.setSurfaceType(groundGeom, 1)