当前位置:网站首页>初步了解Panda3D音频和高级交互组件
初步了解Panda3D音频和高级交互组件
2022-07-27 20:23:00 【bcbobo21cn】
运行panda3d Tut-Music-Box.py示例;
如下图,点击按钮有一个打开关闭盒子的效果,还会播放不同音乐;

Panda将音频系统分为两类:声音效果,音乐;
Panda提供三种音频库:openAL,FMOD,Miles;
self.musicBoxSound = base.loadMusic('music/musicbox.mp3'),载入音频文件;
self.lidSfx = base.loadSfx('music/openclose.mp3'),载入音效;
用pview查看一下模型,如下图;
单独把界面部分的代码看一下;
import direct.directbase.DirectStart
from panda3d.core import NodePath,TextNode
from panda3d.core import Vec3,Vec4
from direct.gui.OnscreenText import OnscreenText
from direct.showbase.DirectObject import DirectObject
from direct.interval.SoundInterval import SoundInterval
from direct.gui.DirectSlider import DirectSlider
from direct.gui.DirectButton import DirectButton
from direct.interval.MetaInterval import Sequence,Parallel
from direct.interval.LerpInterval import LerpFunc
import sys
class World(DirectObject):
def __init__(self):
self.slider = DirectSlider(pos = Vec3(0,0,.7), value = .50,
command = None)
self.button = DirectButton(pos = Vec3(.7,0,.7), text = "Open Box",
scale = .1, pad = (.5, .5),
rolloverSound = None, clickSound = None,
command = None)
w = World()
run()运行如下;按钮和滑动条是用DirectXXX类做的;这是系统提供的高级交互组件的一部分;
单独看一下模型相关的代码,
import direct.directbase.DirectStart
from panda3d.core import NodePath,TextNode
from panda3d.core import Vec3,Vec4
from direct.gui.OnscreenText import OnscreenText
from direct.showbase.DirectObject import DirectObject
from direct.interval.SoundInterval import SoundInterval
from direct.gui.DirectSlider import DirectSlider
from direct.gui.DirectButton import DirectButton
from direct.interval.MetaInterval import Sequence,Parallel
from direct.interval.LerpInterval import LerpFunc
import sys
class World(DirectObject):
def __init__(self):
self.musicBox=loader.loadModel('models/MusicBox')
self.musicBox.setPos(0, 60, -10)
self.musicBox.reparentTo(render)
#Finding pieces of the model
self.Lid = self.musicBox.find('**/lid')
self.Panda = self.musicBox.find('**/turningthing')
self.HingeNode = self.musicBox.find('**/box').attachNewNode('nHingeNode')
self.HingeNode.setPos(.8659,6.5,5.4)
#WRT - ie with respect to. Reparents the object without changing
#its position, size, or orientation
self.Lid.wrtReparentTo(self.HingeNode)
self.HingeNode.setHpr(0,90,0)
w = World()
run()运行如下,只看到一个盒子;
从代码来看;就是加载模型,然后找模型的不同部分,设置为这几个节点,self.Lid,self.Panda,self.HingeNode ;
还不知道盒子打开关闭的效果是如何做的,下回继续;
边栏推荐
- 【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
- 迪赛智慧数——其他图表(平行坐标图):家庭未来资产配置意愿
- VIM editor tutorial
- catch all in one draft! Introduction to 10 data visualization software
- Convnext:a convnet for the 2020s - model Brief
- MySQL的B+Tree索引到底是咋回事?聚簇索引到底是如何长高的?
- 2022年软件开发的趋势
- Excel VBA finds out the maximum and minimum values of a column of time, and repeatedly pastes multiple values according to the actual situation
- 八大排序之冒泡、快排、堆排、基数排序
- 360入选中国安全产业全景图63个领域 ISC2022共话安全服务方向
猜你喜欢
随机推荐
Basic SQL DQL
2022 / 4 / 11 exam summary
51 MCU internal peripherals: real time clock (SPI)
Possible causes of index failure
Helm chart explanation and common commands: helm template / package / plugin
你想被开除吗?来看看程序员「离职小技巧」吧
2022/3/22 examination summary
JVM composition and memory model
2022/3/10 考试总结
Brief explanation of noi 2018
Data warehouse project is never a technical project
Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
Jupyter notebook solves the problem that printing information cannot be viewed after closing the browser
联合省选2022复习计划
XML 外部实体 (XXE) 漏洞及其修复方法
Basic SQL DML
360入选中国安全产业全景图63个领域 ISC2022共话安全服务方向
[idea] fluency optimization
浅析云原生应用安全组织架构
Kubevera deploys applications through cli









