|
发表于 2015-5-1 16:35:04
|
显示全部楼层
例子:- from math import pi, sin, cos
-
- from direct.showbase.ShowBase import ShowBase
- from direct.task import Task
-
- class MyApp(ShowBase):
- def __init__(self):
- ShowBase.__init__(self)
-
- # 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")
-
- # 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()
复制代码
截图:
|
评分
-
参与人数 1 | 荣誉 +5 |
鱼币 +5 |
贡献 +3 |
收起
理由
|
戴宇轩
| + 5 |
+ 5 |
+ 3 |
感谢楼主无私奉献! |
查看全部评分
|