Skylicht Engine
Loading...
Searching...
No Matches
CSubGroup.h
1/*
2!@
3MIT License
4
5Copyright (c) 2020 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "CGroup.h"
28
29namespace Skylicht
30{
31 namespace Particle
32 {
47 class COMPONENT_API CSubGroup :
48 public CGroup,
49 public IParticleCallback
50 {
51 protected:
54
57
64
73
74 public:
75 CSubGroup(CGroup* group);
76
77 virtual ~CSubGroup();
78
81
83 virtual void OnParticleBorn(CParticle& p);
84
86 virtual void OnParticleDead(CParticle& p);
87
89 virtual void OnSwapParticleData(CParticle& p1, CParticle& p2);
90
92 virtual void OnGroupDestroy();
93
95 virtual void updateLaunchEmitter();
96
98 virtual void bornParticle();
99
102
105
107 inline void setFollowParentTransform(bool b)
108 {
110 m_parentSystem->setEnable(b);
111 }
112
114 inline void setEmitterWorldOrientation(bool b)
115 {
117 }
118
120 void syncParentParams(bool life, bool color);
121
123 inline CGroup* getParentGroup()
124 {
125 return m_parentGroup;
126 }
127
128 DECLARE_GETTYPENAME(CSubGroup)
129
131
133 };
134 }
135}
Definition CObjectSerializable.h:36
Individual particle data structure.
Definition CParticle.h:65
A particle group that spawns particles from the positions of particles in a parent group.
Definition CSubGroup.h:50
virtual void OnSwapParticleData(CParticle &p1, CParticle &p2)
Callback when parent particle data is swapped in the array.
core::vector3df m_direction
Spawn direction (derived from parent velocity).
Definition CSubGroup.h:61
virtual void OnGroupDestroy()
Callback when the parent group is destroyed.
core::vector3df m_position
Spawn position (derived from parent particle).
Definition CSubGroup.h:59
core::quaternion m_rotate
Spawn rotation (derived from parent orientation).
Definition CSubGroup.h:63
bool m_followParentTransform
Whether particles should follow the parent's current position every frame.
Definition CSubGroup.h:66
void syncParentParams(bool life, bool color)
Configures synchronization of life and color from parent.
ISystem * m_parentSystem
System that syncs this group's particles to parent particles.
Definition CSubGroup.h:56
void initParticles()
Initializes internal born data for all emitters based on current parent particles.
virtual CObjectSerializable * createSerializable()
Creates a serializable object for property editing or saving.
virtual core::vector3df getTransformVector(const core::vector3df &vec)
Transforms vector from parent local space to world space.
void setEmitterWorldOrientation(bool b)
Sets emitter orientation mode.
Definition CSubGroup.h:114
CGroup * m_parentGroup
Pointer to the parent particle group.
Definition CSubGroup.h:53
virtual void updateLaunchEmitter()
Internal: updates launch emitters based on parent particles.
CGroup * getParentGroup()
Gets the parent group.
Definition CSubGroup.h:123
virtual void bornParticle()
Internal: spawns new particles at parent positions.
bool m_syncColor
Whether to sync child color with parent.
Definition CSubGroup.h:72
bool m_emitterWorldOrientation
Whether emitter orientation should be in world space or relative to parent.
Definition CSubGroup.h:68
virtual core::vector3df getTransformPosition(const core::vector3df &pos)
Transforms position from parent local space to world space.
void setFollowParentTransform(bool b)
Enables/disables following the parent's movement.
Definition CSubGroup.h:107
virtual void OnParticleBorn(CParticle &p)
Callback when a parent particle is born.
virtual void loadSerializable(CObjectSerializable *object)
Loads properties from a serializable object.
bool m_syncLife
Whether to sync child age/life with parent.
Definition CSubGroup.h:70
virtual void OnParticleDead(CParticle &p)
Callback when a parent particle dies.
Base interface for particle systems that update particle data.
Definition ISystem.h:41
Quaternion class for representing rotations.
Definition quaternion.h:27
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445