python3的3D实战 -基于panda3d(4)
生活随笔
收集整理的這篇文章主要介紹了
python3的3D实战 -基于panda3d(4)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Actor類是用于動畫模型的。請注意,我們僅在靜態模型和Actor是動畫時才使用loadModel()。Actor類的兩個構造函數參數是包含模型的文件名稱和包含包含動畫的文件名稱的Python字典。
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from math import pi, sin, cosfrom direct.showbase.ShowBase import ShowBase from direct.task import Task from direct.actor.Actor import Actorclass MyApp(ShowBase):def __init__(self):ShowBase.__init__(self)# Load the environment model.self.scene = self.loader.loadModel("models/environment")# Reparent the model to render.self.scene.reparentTo(self.render)# Apply scale and position transforms on the model.self.scene.setScale(0.25, 0.25, 0.25)self.scene.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")# Define a procedure to move the camera.def spinCameraTask(self, task):angleDegrees = task.time * 6.0angleRadians = angleDegrees * (pi / 180.0)self.camera.setPos(20 * sin(angleRadians), -20 * cos(angleRadians), 3)self.camera.setHpr(angleDegrees, 0, 0)return Task.contapp = MyApp() app.run()
時間間隔
間隔是在指定的一段時間內將屬性從一個值更改為另一個值的任務。啟動間隔有效地啟動在指定時間段內修改屬性的后臺進程。
序列
序列,有時稱為metainterval,是一種包含其他間隔的間隔類型。播放一個序列將導致每個包含的間隔依次執行。
下面代碼,熊貓在來回移動
總結
以上是生活随笔為你收集整理的python3的3D实战 -基于panda3d(4)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: @requestbody和@reques
- 下一篇: Spring注解——使用@Compone