日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python3的3D实战 -基于panda3d(4)

發布時間:2025/3/12 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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,是一種包含其他間隔的間隔類型。播放一個序列將導致每個包含的間隔依次執行。
下面代碼,熊貓在來回移動

from math import pi, sin, cosfrom 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 Point3class MyApp(ShowBase):def __init__(self):ShowBase.__init__(self)# Disable the camera trackball controls.self.disableMouse()# 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")# Create the four lerp intervals needed for the panda to# walk back and forth.posInterval1 = self.pandaActor.posInterval(13,Point3(0, -10, 0),startPos=Point3(0, 10, 0))posInterval2 = self.pandaActor.posInterval(13,Point3(0, 10, 0),startPos=Point3(0, -10, 0))hprInterval1 = self.pandaActor.hprInterval(3,Point3(180, 0, 0),startHpr=Point3(0, 0, 0))hprInterval2 = 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(posInterval1, hprInterval1,posInterval2, hprInterval2,name="pandaPace")self.pandaPace.loop()# 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()

總結

以上是生活随笔為你收集整理的python3的3D实战 -基于panda3d(4)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。