-
Notifications
You must be signed in to change notification settings - Fork 6
/
particleGroup.go
73 lines (60 loc) · 1.6 KB
/
particleGroup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package effects
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/walesey/go-engine/renderer"
)
type ParticleGroup struct {
Node *renderer.Node
camera *renderer.Camera
particles []*ParticleSystem
}
func (pg *ParticleGroup) Disable(disable bool) {
for _, particle := range pg.particles {
particle.DisableSpawning = disable
}
}
func (pg *ParticleGroup) Update(dt float64) {
for _, particle := range pg.particles {
if pg.camera != nil {
particle.SetCameraLocation(pg.camera.Translation)
}
particle.Update(dt)
}
}
func (pg *ParticleGroup) SetTranslation(translation mgl32.Vec3) {
for _, particle := range pg.particles {
particle.Location = translation
}
}
func (pg *ParticleGroup) Draw(renderer renderer.Renderer, transform mgl32.Mat4) {
pg.Node.Draw(renderer, transform)
}
func (pg *ParticleGroup) Destroy(renderer renderer.Renderer) {
pg.Node.Destroy(renderer)
}
func (pg *ParticleGroup) Center() mgl32.Vec3 {
return pg.Node.Center()
}
func (pg *ParticleGroup) SetParent(parent *renderer.Node) {
pg.Node.SetParent(parent)
}
func (pg *ParticleGroup) Optimize(geometry *renderer.Geometry, transform mgl32.Mat4) {
pg.Node.Optimize(geometry, transform)
}
func (pg *ParticleGroup) BoundingRadius() float32 {
return pg.Node.BoundingRadius()
}
func (pg *ParticleGroup) OrthoOrder() int {
return pg.Node.OrthoOrder()
}
func NewParticleGroup(camera *renderer.Camera, particles ...*ParticleSystem) *ParticleGroup {
node := renderer.NewNode()
for _, particle := range particles {
node.Add(particle)
}
return &ParticleGroup{
Node: node,
camera: camera,
particles: particles,
}
}