| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : W3DView *
- * *
- * $Archive:: /VSS_Sync/W3DView/EmitterInstanceList.cpp $Modtime:: $*
- * *
- * $Revision:: 7 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "StdAfx.H"
- #include "EmitterInstanceList.H"
- #include "Utils.H"
- /////////////////////////////////////////////////////////////////////
- //
- // ~EmitterInstanceListClass
- //
- /////////////////////////////////////////////////////////////////////
- EmitterInstanceListClass::~EmitterInstanceListClass (void)
- {
- Free_List ();
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Free_List
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Free_List (void)
- {
- //
- // Release our hold on each of the emitter pointers
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- MEMBER_RELEASE (m_List[index]);
- }
- m_List.Delete_All ();
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Add_Emitter
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter)
- {
- ASSERT (emitter != NULL);
- if (emitter != NULL) {
- //
- // If this is the first emitter in the list, then initialize
- // the definition to it's state
- //
- if (m_List.Count () == 0) {
- ParticleEmitterDefClass *def = emitter->Build_Definition ();
- if (def != NULL) {
- ParticleEmitterDefClass::operator= (*def);
- SAFE_DELETE (def);
- }
- }
-
- //
- // Add this emitter to the list and put a hold on its reference
- //
- SAFE_ADD_REF (emitter);
- m_List.Add (emitter);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Velocity
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Velocity (const Vector3 &value)
- {
- ParticleEmitterDefClass::Set_Velocity (value);
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Set_Base_Velocity (value);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Acceleration
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Acceleration (const Vector3 &value)
- {
- ParticleEmitterDefClass::Set_Acceleration (value);
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Set_Acceleration (value);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Burst_Size
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Burst_Size (unsigned int count)
- {
- ParticleEmitterDefClass::Set_Burst_Size (count);
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Set_Burst_Size (count);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Outward_Vel
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Outward_Vel (float value)
- {
- ParticleEmitterDefClass::Set_Outward_Vel (value);
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Set_Outwards_Velocity (value);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Vel_Inherit
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Vel_Inherit (float value)
- {
- ParticleEmitterDefClass::Set_Vel_Inherit (value);
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Set_Velocity_Inheritance_Factor (value);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Velocity_Random
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Velocity_Random (Vector3Randomizer *randomizer)
- {
- ParticleEmitterDefClass::Set_Velocity_Random (randomizer);
- if (randomizer != NULL) {
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Set_Velocity_Randomizer (randomizer->Clone ());
- }
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Color_Keyframes
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Color_Keyframes (ParticlePropertyStruct<Vector3> &keyframes)
- {
- //
- // Make sure tha any value that is supposed to go to zero, really
- // does even if its got a randomizer.
- //
- if ( (keyframes.Rand.X != 0) ||
- (keyframes.Rand.Y != 0) ||
- (keyframes.Rand.Z != 0))
- {
- for (UINT index = 0; index < keyframes.NumKeyFrames; index ++) {
- if ((keyframes.Values[index].X <= 0.000001F) &&
- (keyframes.Values[index].Y <= 0.000001F) &&
- (keyframes.Values[index].Z <= 0.000001F)) {
- keyframes.Values[index].X = -keyframes.Rand.X;
- keyframes.Values[index].Y = -keyframes.Rand.Y;
- keyframes.Values[index].Z = -keyframes.Rand.Z;
- }
- }
- }
- ParticleEmitterDefClass::Set_Color_Keyframes (keyframes);
-
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Reset_Colors (keyframes);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Opacity_Keyframes
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Opacity_Keyframes (ParticlePropertyStruct<float> &keyframes)
- {
- //
- // Make sure tha any value that is supposed to go to zero, really
- // does even if its got a randomizer.
- //
- if (keyframes.Rand != 0)
- {
- for (UINT index = 0; index < keyframes.NumKeyFrames; index ++) {
- if (keyframes.Values[index] <= 0.000001F) {
- keyframes.Values[index] = -keyframes.Rand;
- }
- }
- }
- ParticleEmitterDefClass::Set_Opacity_Keyframes (keyframes);
-
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Reset_Opacity (keyframes);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Size_Keyframes
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Size_Keyframes (ParticlePropertyStruct<float> &keyframes)
- {
- //
- // Make sure tha any value that is supposed to go to zero, really
- // does even if its got a randomizer.
- //
- if (keyframes.Rand != 0)
- {
- for (UINT index = 0; index < keyframes.NumKeyFrames; index ++) {
- if (keyframes.Values[index] <= 0.000001F) {
- keyframes.Values[index] = -keyframes.Rand;
- }
- }
- }
- ParticleEmitterDefClass::Set_Size_Keyframes (keyframes);
-
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Reset_Size (keyframes);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Rotation_Keyframes
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Rotation_Keyframes (ParticlePropertyStruct<float> &keyframes, float orient_rnd)
- {
- ParticleEmitterDefClass::Set_Rotation_Keyframes (keyframes, orient_rnd);
-
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Reset_Rotations (keyframes, orient_rnd);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Frame_Keyframes
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Frame_Keyframes (ParticlePropertyStruct<float> &keyframes)
- {
- ParticleEmitterDefClass::Set_Frame_Keyframes (keyframes);
-
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Reset_Frames (keyframes);
- }
- return ;
- }
- /////////////////////////////////////////////////////////////////////
- //
- // Set_Blur_Time_Keyframes
- //
- /////////////////////////////////////////////////////////////////////
- void
- EmitterInstanceListClass::Set_Blur_Time_Keyframes (ParticlePropertyStruct<float> &keyframes)
- {
- ParticleEmitterDefClass::Set_Blur_Time_Keyframes (keyframes);
-
- //
- // Pass this setting onto the emitters immediately
- //
- for (int index = 0; index < m_List.Count (); index ++) {
- m_List[index]->Reset_Blur_Times (keyframes);
- }
- return ;
- }
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // Get_Color_Keyframes
- //
- void
- EmitterInstanceListClass::Get_Color_Keyframes (ParticlePropertyStruct<Vector3> &keyframes) const
- {
- ParticleEmitterDefClass::Get_Color_Keyframes (keyframes);
- //
- // Normalize the data
- //
- for (UINT index = 0; index < keyframes.NumKeyFrames; index ++) {
- if (keyframes.Values[index].X <= 0.000001F) {
- keyframes.Values[index].X = 0;
- }
- if (keyframes.Values[index].Y <= 0.000001F) {
- keyframes.Values[index].Y = 0;
- }
- if (keyframes.Values[index].Z <= 0.000001F) {
- keyframes.Values[index].Z = 0;
- }
- }
- return ;
- }
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // Get_Opacity_Keyframes
- //
- void
- EmitterInstanceListClass::Get_Opacity_Keyframes (ParticlePropertyStruct<float> &keyframes) const
- {
- ParticleEmitterDefClass::Get_Opacity_Keyframes (keyframes);
- //
- // Normalize the data
- //
- for (UINT index = 0; index < keyframes.NumKeyFrames; index ++) {
- if (keyframes.Values[index] <= 0.000001F) {
- keyframes.Values[index] = 0;
- }
- }
- return ;
- }
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // Get_Size_Keyframes
- //
- void
- EmitterInstanceListClass::Get_Size_Keyframes (ParticlePropertyStruct<float> &keyframes) const
- {
- ParticleEmitterDefClass::Get_Size_Keyframes (keyframes);
- //
- // Normalize the data
- //
- for (UINT index = 0; index < keyframes.NumKeyFrames; index ++) {
- if (keyframes.Values[index] <= 0.000001F) {
- keyframes.Values[index] = 0;
- }
- }
- return ;
- }
|