当前位置:网站首页>初步了解Panda3d粒子系统
初步了解Panda3d粒子系统
2022-07-25 05:04:00 【bcbobo21cn】
运行panda3d示例Tut-Particle-Panel.py;出现一个基本粒子系统如下;

同时出现粒子系统面板如下;
粒子系统的编程原理应该是通过指定粒子的发射位置、数量、粒子尺寸、颜色等参数,然后引擎就把它做出来;
调整一下面板参数,基本没发现效果;
研究了一下,它的粒子系统配置是*.ptf文件;载入不同的ptf文件,看一下效果;
等等;
打开一个ptf文件看一下; 是纯文本,可手动编辑;一个示例如下;
self.reset()
self.setPos(0.000, 0.000, 0.000)
self.setHpr(0.000, 0.000, 0.000)
self.setScale(1.000, 1.000, 1.000)
p0 = Particles.Particles('particles-1')
# Particles parameters
p0.setFactory("PointParticleFactory")
p0.setRenderer("PointParticleRenderer")
p0.setEmitter("DiscEmitter")
p0.setPoolSize(10000)
p0.setBirthRate(0.0200)
p0.setLitterSize(300)
p0.setLitterSpread(100)
p0.setSystemLifespan(0.0000)
p0.setLocalVelocityFlag(1)
p0.setSystemGrowsOlderFlag(0)
# Factory parameters
p0.factory.setLifespanBase(0.5000)
p0.factory.setLifespanSpread(0.2500)
p0.factory.setMassBase(2.0000)
p0.factory.setMassSpread(0.0100)
p0.factory.setTerminalVelocityBase(400.0000)
p0.factory.setTerminalVelocitySpread(0.0000)
# Point factory parameters
# Renderer parameters
p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
p0.renderer.setUserAlpha(0.45)
# Point parameters
p0.renderer.setPointSize(3.00)
p0.renderer.setStartColor(Vec4(0.25, 0.90, 1.00, 1.00))
p0.renderer.setEndColor(Vec4(1.00, 1.00, 1.00, 1.00))
p0.renderer.setBlendType(PointParticleRenderer.PPONECOLOR)
p0.renderer.setBlendMethod(BaseParticleRenderer.PPNOBLEND)
# Emitter parameters
p0.emitter.setEmissionType(BaseParticleEmitter.ETCUSTOM)
p0.emitter.setAmplitude(1.0000)
p0.emitter.setAmplitudeSpread(0.0000)
p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 4.0000))
p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
# Disc parameters
p0.emitter.setRadius(0.0500)
p0.emitter.setOuterAngle(356.1859)
p0.emitter.setInnerAngle(0.0000)
p0.emitter.setOuterMagnitude(2.0000)
p0.emitter.setInnerMagnitude(1.0000)
p0.emitter.setCubicLerping(0)
self.addParticles(p0)
f0 = ForceGroup.ForceGroup('gravity')
# Force parameters
force0 = LinearVectorForce(Vec3(0.0000, 0.0000, -1.0000), 25.0000, 1)
force0.setActive(1)
f0.addForce(force0)
force1 = LinearJitterForce(3.0000, 1)
force1.setActive(1)
f0.addForce(force1)
self.addForceGroup(f0)显示粒子系统面板的python代码如下;
import sys
import direct.directbase.DirectStart
base.startTk()
from direct.tkpanels.ParticlePanel import ParticlePanel
pp = ParticlePanel() # Create the panel
base.disableMouse() # Disable camera control to place it
camera.setY(-10) # Place the camera
base.setBackgroundColor(0, 0, 0) # Most particle systems show up better on black backgrounds
run() 粒子系统一般是叠加在模型上做一些效果,例如模拟建筑着火之类;
BaseParticleRenderer是粒子系统的基类;
粒子系统的类别包括:几何粒子,线段粒子,点粒子,烟火粒子,精灵;
classBaseParticleRenderer
Bases:
Bases: ReferenceCount
Pure virtual particle renderer base class
这个类是纯虚类;编程时要用派生的具体类;
边栏推荐
- GDT,LDT,GDTR,LDTR
- STM32 Development Notes 121: Kalman filter I understand
- China trifluoroethanol industry research and investment forecast report (2022 Edition)
- Logu p3398 hamsters find sugar solution
- Most of the time, it's probability
- How to judge whether it is attacked by DDoS
- [globally unique ID] how to handle the ID primary key after dividing the database and table?
- [sht30 temperature and humidity display based on STM32F103]
- Natural state is the best
- If you don't know these 20 classic redis interview questions, don't go to the interview!
猜你喜欢

OA and fansoft Bi cross system users, departments and posts synchronous summary

ES6 -- Methods and extensions of array objects, traversal of arrays, and extension methods of strings

Leetcode55. Jumping game

Summary of UPR optimization suggestions of unity

Token value replacement of burpsuite blasting

If you don't know these 20 classic redis interview questions, don't go to the interview!
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

Unity LOD

Pychart configuration pyqt5

Permanent magnet synchronous motor 36 question (1) -- what is the difference between salient pole motor and salient pole motor?
随机推荐
Today is important
2、 Mysql database foundation
How to merge cells in a table by markdown
956. Highest billboard pressure DP
"Niuke | daily question" inverse Polish expression
Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life
Androd releases jitpack open source project (gradle7.2)
Deep understanding of pod
Actual combat | record an attack and defense drill management
Anaconda installs jupyter
ESWC 2018 | R-GCN:基于图卷积网络的关系数据建模
harbor安装
小红书携手HMS Core,畅玩高清视界,种草美好生活
Very clear organization
如何判断是否遭到DDOS攻击
Tiny-emitter.js: a small event subscription and Publishing Library
Now the operator wants to check the answer details of all user questions from Zhejiang University. Please take out the corresponding data
How to test data in the process of data warehouse migration?
Bypass XSS filters in Web Applications
教你如何定位不合理的SQL?并优化之