Panda3D

11 views
Skip to first unread message

hard wyrd

unread,
Mar 20, 2011, 9:45:43 AM3/20/11
to Open-ITLUG, ubunt...@googlegroups.com
If you haven't heard of Panda3D yet, I think now is the time to take a look :).

It's a solid framework for 3D game development specially if you're a code junkie. It's all in python, use the library freely since it's a Modified BSD License. No obligations. All from Disney and Carnegie-Mellon University.

Attached is a rendering on my machine using their sample code running on my Ubuntu Lucid 64bit box. A few lines has produced this full 3D render, environment, assets, actor, movements and all.



from math import pi, sin, cos
 
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.actor.Actor import Actor
from direct.interval.IntervalGlobal import Sequence
from panda3d.core import Point3
 
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
 
# Disable the camera trackball controls.
self.disableMouse()
 
# Load the environment model.
self.environ = self.loader.loadModel("models/environment")
# Reparent the model to render.
self.environ.reparentTo(self.render)
# Apply scale and position transforms on the model.
self.environ.setScale(0.25, 0.25, 0.25)
self.environ.setPos(-8, 42, 0)
 
# Add the spinCameraTask procedure to the task manager.
self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
 
# Load and transform the panda actor.
self.pandaActor = Actor("models/panda-model",
{"walk": "models/panda-walk4"})
self.pandaActor.setScale(0.005, 0.005, 0.005)
self.pandaActor.reparentTo(self.render)
# Loop its animation.
self.pandaActor.loop("walk")
 
# Create the four lerp intervals needed for the panda to
# walk back and forth.
pandaPosInterval1 = self.pandaActor.posInterval(13,
Point3(0, -10, 0),
startPos=Point3(0, 10, 0))
pandaPosInterval2 = self.pandaActor.posInterval(13,
Point3(0, 10, 0),
startPos=Point3(0, -10, 0))
pandaHprInterval1 = self.pandaActor.hprInterval(3,
Point3(180, 0, 0),
startHpr=Point3(0, 0, 0))
pandaHprInterval2 = self.pandaActor.hprInterval(3,
Point3(0, 0, 0),
startHpr=Point3(180, 0, 0))
 
# Create and play the sequence that coordinates the intervals.
self.pandaPace = Sequence(pandaPosInterval1,
pandaHprInterval1,
pandaPosInterval2,
pandaHprInterval2,
name="pandaPace")
self.pandaPace.loop()
 
# Define a procedure to move the camera.
def spinCameraTask(self, task):
angleDegrees = task.time * 6.0
angleRadians = angleDegrees * (pi / 180.0)
self.camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 3)
self.camera.setHpr(angleDegrees, 0, 0)
return Task.cont
 
app = MyApp()
app.run()


--
-------------------------------------------------------------
"Penguin, penguin, and more penguin !"

http://www.madforubuntu.com
http://baudizm.blogsome.com
panda2.png

botp

unread,
Mar 20, 2011, 8:50:15 PM3/20/11
to ubunt...@googlegroups.com, hard wyrd, Open-ITLUG
Reply all
Reply to author
Forward
0 new messages