1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "animation_fx.h"
24 #include "nel/georges/u_form_elm.h"
25 #include "nel/3d/u_animation_set.h"
26 #include "nel/3d/u_animation.h"
27 #include "nel/3d/u_track.h"
28 #include "nel/3d/u_instance.h"
29 #include "nel/3d/u_particle_system_instance.h"
30 #include "nel/3d/u_scene.h"
31 #include "client_sheets/animation_fx_set_sheet.h"
37 extern NL3D::UScene
*Scene
;
40 //-----------------------------------------------
42 //-----------------------------------------------
43 CAnimationFX::CAnimationFX(const std::string
&psName
/* = "" */, const float *userParams
/*=NULL*/)
47 if ((!psName
.empty()) || (userParams
!= NULL
))
49 Sheet
= new CAnimationFXSheet(psName
, userParams
);
53 //-----------------------------------------------
55 //-----------------------------------------------
56 void CAnimationFX::init(const CAnimationFXSheet
*sheet
, NL3D::UAnimationSet
*as
)
63 //-----------------------------------------------
65 //-----------------------------------------------
66 void CAnimationFX::buildTrack(NL3D::UAnimationSet
*as
)
68 nlassert(Sheet
!= NULL
);
70 if (Sheet
->TrajectoryAnim
.empty()) return;
71 std::string animName
= NLMISC::toLowerAscii(Sheet
->TrajectoryAnim
);
72 uint id
= as
->getAnimationIdByName(animName
);
73 NL3D::UAnimation
*anim
= NULL
;
74 if (id
!= NL3D::UAnimationSet::NotFound
)
76 anim
= as
->getAnimation(id
);
81 uint id
= as
->addAnimation(animName
.c_str(), animName
.c_str());
82 if (id
!= NL3D::UAnimationSet::NotFound
)
84 anim
= as
->getAnimation(id
);
89 PosTrack
= anim
->getTrackByName("pos");
93 //-----------------------------------------------
94 //createMatchingInstance
95 //-----------------------------------------------
96 NL3D::UParticleSystemInstance
CAnimationFX::createMatchingInstance(const float *customUserParams
/* = NULL */) const
98 NL3D::UParticleSystemInstance fx
;
99 nlassert(Sheet
!= NULL
);
100 if (Sheet
->PSName
.empty()) return NULL
;
101 NL3D::UInstance inst
= Scene
->createInstance(Sheet
->PSName
);
107 nlwarning("Bad shape type for a fxsheet shape : must be a particle system");
108 Scene
->deleteInstance(inst
);
113 if (customUserParams
!= NULL
)
115 for(uint l
= 0; l
< 4; ++l
)
117 fx
.setUserParam(l
, customUserParams
[l
]);
122 for(uint l
= 0; l
< 4; ++l
)
124 fx
.setUserParam(l
, Sheet
->UserParam
[l
]);
127 fx
.setUserColor(Sheet
->Color
);
131 }// createMatchingInstance //
133 // *******************************************************************************
135 // *******************************************************************************
137 //-----------------------------------------------
139 //-----------------------------------------------
140 void CAnimationFXSet::init(const CAnimationFXSetSheet
*sheet
, NL3D::UAnimationSet
*as
)
144 FX
.resize(sheet
->FX
.size());
145 for(uint k
= 0; k
< sheet
->FX
.size(); ++k
)
147 FX
[k
].init(&sheet
->FX
[k
], as
);