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_sheet.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"
30 extern NL3D::UScene
*Scene
;
32 //*******************************************************************************
34 //*******************************************************************************
36 //-----------------------------------------------
38 //-----------------------------------------------
39 CAnimationFX::CAnimationFX(const std::string
&psName
/* = "" */, const float *userParams
/*=NULL*/)
43 if ((!psName
.empty()) || (userParams
!= NULL
))
45 Sheet
= new CAnimationFXSheet(psName
, userParams
);
49 //-----------------------------------------------
51 //-----------------------------------------------
52 void CAnimationFX::init(CAnimationFXSheet
*sheet
, NL3D::UAnimationSet
*as
)
55 // Dont need to call the build track
59 //-----------------------------------------------
61 //-----------------------------------------------
62 void CAnimationFX::buildTrack(NL3D::UAnimationSet
*as
)
64 nlassert(Sheet
!= NULL
);
66 if (Sheet
->TrajectoryAnim
.empty()) return;
67 std::string animName
= NLMISC::toLower(Sheet
->TrajectoryAnim
);
68 uint id
= as
->getAnimationIdByName(animName
);
69 NL3D::UAnimation
*anim
= NULL
;
70 if (id
!= NL3D::UAnimationSet::NotFound
)
72 anim
= as
->getAnimation(id
);
77 uint id
= as
->addAnimation(animName
.c_str(), animName
.c_str());
78 if (id
!= NL3D::UAnimationSet::NotFound
)
80 anim
= as
->getAnimation(id
);
85 PosTrack
= anim
->getTrackByName("pos");
89 //-----------------------------------------------
90 //createMatchingInstance
91 //-----------------------------------------------
92 NL3D::UParticleSystemInstance
CAnimationFX::createMatchingInstance() const
94 nlassert(Sheet
!= NULL
);
95 if (Sheet
->PSName
.empty()) return NULL
;
96 if (nlstricmp(Sheet
->PSName
, "none") == 0) return NULL
;
97 NL3D::UInstance inst
= Scene
->createInstance(Sheet
->PSName
);
100 NL3D::UParticleSystemInstance fx
;
104 nlwarning("Bad shape type for a fxsheet shape : must be a particle system");
105 Scene
->deleteInstance(inst
);
110 for(uint l
= 0; l
< 4; ++l
)
112 fx
->setUserParam(l
, Sheet
->UserParam
[l
]);
114 fx
->setUserColor(Sheet
->Color
);
119 }// createMatchingInstance //
121 //*******************************************************************************
123 //*******************************************************************************
125 //-----------------------------------------------
127 //-----------------------------------------------
128 void CAnimationFXSet::buildTrack(NL3D::UAnimationSet
*as
)
131 for(uint k
= 0; k
< FX
.size(); ++k
)
133 FX
[k
].buildTrack(as
);