1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "animation_fx.h"
21 #include "nel/georges/u_form_elm.h"
22 #include "nel/3d/u_animation_set.h"
23 #include "nel/3d/u_animation.h"
24 #include "nel/3d/u_track.h"
25 #include "nel/3d/u_instance.h"
26 #include "nel/3d/u_particle_system_instance.h"
27 #include "nel/3d/u_scene.h"
28 #include "client_sheets/animation_fx_set_sheet.h"
34 extern NL3D::UScene
*Scene
;
37 //-----------------------------------------------
39 //-----------------------------------------------
40 CAnimationFX::CAnimationFX(const std::string
&psName
/* = "" */, const float *userParams
/*=NULL*/)
44 if ((!psName
.empty()) || (userParams
!= NULL
))
46 Sheet
= new CAnimationFXSheet(psName
, userParams
);
50 //-----------------------------------------------
52 //-----------------------------------------------
53 void CAnimationFX::init(const CAnimationFXSheet
*sheet
, NL3D::UAnimationSet
*as
)
60 //-----------------------------------------------
62 //-----------------------------------------------
63 void CAnimationFX::buildTrack(NL3D::UAnimationSet
*as
)
65 nlassert(Sheet
!= NULL
);
67 if (Sheet
->TrajectoryAnim
.empty()) return;
68 std::string animName
= NLMISC::toLowerAscii(Sheet
->TrajectoryAnim
);
69 uint id
= as
->getAnimationIdByName(animName
);
70 NL3D::UAnimation
*anim
= NULL
;
71 if (id
!= NL3D::UAnimationSet::NotFound
)
73 anim
= as
->getAnimation(id
);
78 uint id
= as
->addAnimation(animName
.c_str(), animName
.c_str());
79 if (id
!= NL3D::UAnimationSet::NotFound
)
81 anim
= as
->getAnimation(id
);
86 PosTrack
= anim
->getTrackByName("pos");
90 //-----------------------------------------------
91 //createMatchingInstance
92 //-----------------------------------------------
93 NL3D::UParticleSystemInstance
CAnimationFX::createMatchingInstance(const float *customUserParams
/* = NULL */) const
95 NL3D::UParticleSystemInstance fx
;
96 nlassert(Sheet
!= NULL
);
97 if (Sheet
->PSName
.empty()) return NULL
;
98 NL3D::UInstance inst
= Scene
->createInstance(Sheet
->PSName
);
104 nlwarning("Bad shape type for a fxsheet shape : must be a particle system");
105 Scene
->deleteInstance(inst
);
110 if (customUserParams
!= NULL
)
112 for(uint l
= 0; l
< 4; ++l
)
114 fx
.setUserParam(l
, customUserParams
[l
]);
119 for(uint l
= 0; l
< 4; ++l
)
121 fx
.setUserParam(l
, Sheet
->UserParam
[l
]);
124 fx
.setUserColor(Sheet
->Color
);
128 }// createMatchingInstance //
130 // *******************************************************************************
132 // *******************************************************************************
134 //-----------------------------------------------
136 //-----------------------------------------------
137 void CAnimationFXSet::init(const CAnimationFXSetSheet
*sheet
, NL3D::UAnimationSet
*as
)
141 FX
.resize(sheet
->FX
.size());
142 for(uint k
= 0; k
< sheet
->FX
.size(); ++k
)
144 FX
[k
].init(&sheet
->FX
[k
], as
);