On Github collectivecognition / hello.panda
Save to models/sphere.obj
Problem! Panda3D expects sphere.egg
http://andyp.pfastergames.com/2008/12/15/updated-obj2eggpy-convert-obj-to-egg/
ppython obj2egg.py models/sphere.obj
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
class Hello(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.setBackgroundColor(0.0, 0.0, 0.0)
base.disableMouse()
# Load a model and parent it to the renderer
sphere = loader.loadModel("models/sphere.egg")
sphere.setPos(0.0, 0.0, 0.0)
sphere.reparentTo(render)
hello = Hello()
hello.run()
Not very exciting!
# Position and aim the camera base.camLens.setNearFar(1.0, 50.0) base.camLens.setFov(45.0) self.camera.setPos(0.0, 5.0, 15.0) self.camera.lookAt(0.0, 0.0, 0.0)
Panda3D is 100% lit by default.
# Set up an ambient light
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(0.3, 0.3, 0.3, 1))
ambientLightNP = render.attachNewNode(ambientLight)
render.setLight(ambientLightNP)
# Add a point light
pointLight = PointLight("pointLight")
pointLight.setColor(VBase4(0.5, 0.5, 0.5, 1))
pointLightNode = render.attachNewNode(pointLight)
pointLightNode.setPos(5.0, 0.0, 5.0)
render.setLight(pointLightNode)
# Apply a texture to the sphere
textureStage = TextureStage("ts")
texture = loader.loadTexture("textures/grid.png")
sphere.setTexture(textureStage, texture)
sphere.setTexScale(textureStage, 2.0, 2.0)
import math from direct.task import Task from direct.interval.IntervalGlobal import * . . . # Spin the object def SpinTask(task): x, y, z = sphere.getHpr() sphere.setHpr(x + 1.0, y + 1.0, z + 1.0) return Task.cont self.taskMgr.add(SpinTask, "SpinTask")
openssl genrsa 1024 > ~/.ssh/panda3d.pem openssl req -new -x509 -nodes -sha1 -days 365 -key ~/.ssh/panda3d.pem >> ~/.ssh/panda3d.pem packp3d -c auto_start=1 -S ~/.ssh/panda3d.pem -o ../hello.p3d -d ./
<object width="640" height="480" type="application/x-panda3d" data="hello.p3d"> <object width="640" height="480" classid="CLSID:924B4927-D3BA-41EA-9F7E-8A89194AB3AC"> <param name="data" value="hello.p3d"> </object> </object>