예제 #1
0
loadPrcFileData("", """sync-video 0
"""
)
import direct.directbase.DirectStart
#** snippet support routines - not concerning the tutorial part
import snipstuff

#=========================================================================
# Scenographic stuff
#=========================================================================

base.cam.setPos(0,-30,10)
base.cam.lookAt((0,0,4))

splash=snipstuff.splashCard()
snipstuff.info.append("Panda Physics")
snipstuff.info.append("how setting up collisions to work with the panda3D physics engine")
snipstuff.info.append("r=object rain\n+-=increase/decrease dynamic friction\n*/=increase/decrease static friction\nwasd=move the avatar around\nSPACE=avatar jump")
snipstuff.info_show()

#=========================================================================
# Main
""" As you probably know, physics in games is a cool feature that give life to the show and today it is quite impossible not to face it while developing a modern game and panda3D make no exception. Though, you got to know that panda3d physics engine is not a complete physics engine but is there to solve simple tasks, especially related to particle management, even if could be applied to 3d models as well, so you may first understand what it got to offer and what are its limitations then see if suits for your game. We're not going to dig furter this issue, cos the panda3d manual already gotta dedicated section but rather we'll see how to setup collisions to interact with physics. We got a simple scene with a roaming smiley and a shower of frowneys and watermelons where each element in the scene will be able to collide each other, floor included and everything driven by the panda3d physics engine.
Note that we don't need to set masking in this setup cos each objet collide with each other, therefore every collider, beside the floor, gotta act as from and to object therefore the default masking setup is good as is.
"""
#=========================================================================

#** Collision system ignition - even if we're going to interact with the physics routines, the usual traverser is always in charge to drive collisions
base.cTrav=CollisionTraverser()
# look here: we enable the particle system - this is the evidence of what I was saying above, because the panda physics engine is conceived mainly to manage particles.
예제 #2
0
from direct.interval.IntervalGlobal import *

from pandac.PandaModules import loadPrcFileData
loadPrcFileData("", """sync-video 0
""")
import direct.directbase.DirectStart
#** snippet support routines - not concerning the tutorial part
import snipstuff

#=========================================================================
# Scenographic stuff
#=========================================================================

base.cam.setPos(40, -70, 35)

splash = snipstuff.splashCard()
snipstuff.info.append("2.5D collisions")
snipstuff.info.append("how to collide 2D and 3D objects")
snipstuff.info.append(
    "Try to reach the top of the windmill\n\nwasd=move the avatar around\nSPACE=avatar jump"
)
snipstuff.info_show()

#=========================================================================
# Main
""" As suggested above, we're going to use what we learned so far to make collide 2d and 3d objects. By the way there is nothing special to do from 3d-3d collisions cos the colliders and handlers used are exactly the same as you'll see.
"""
#=========================================================================

#** Collision system ignition
base.cTrav = CollisionTraverser()