Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the ODE physics engine


The Open Dynamics Engine (ODE) in short, is a very powerful and feature-rich implementation of a rigid body physics system. It has been successfully integrated into various commercial simulation and game projects like World of Goo and Nail'd, for example. Panda3D comes with this proven piece of physics technology included out of the box. This leaves it to us to enable and use ODE in our code, so let's get started!

Getting ready

To get set for this recipe, please follow Setting up the game structure first. You can find this recipe in Chapter 1.

How to do it...

The ODE physics engine is used like the following in a Panda3D application:

  1. Open Application.py and add this code:

    from direct.showbase.ShowBase import ShowBase
    from panda3d.core import *
    from panda3d.ode import *
    import random
    
    class Application(ShowBase):
        def __init__(self):
            ShowBase.__init__(self)
            self.smiley = loader.loadModel("smiley")
            self.smileyCount = 0
            self.cam.setPos...