Merge branch '164-crash-on-patching-and-possibly-right-after-login' into main/gingo...
[ryzomcore.git] / ryzom / client / src / decal_anim.cpp
blobc815961ad9c8c5c7cd69fe4b68daccdd6a954129
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
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/>.
20 #include "stdpch.h"
22 #include "decal_anim.h"
23 #include "decal.h"
24 #include "nel/gui/lua_ihm.h"
25 #include "nel/gui/lua_object.h"
27 #include "nel/misc/vector_2f.h"
28 #include "nel/misc/algo.h"
31 using namespace NLMISC;
33 // *****************************************************************************
34 CDecalAnim::CDecalAnim()
36 DurationInMs = 1000;
37 EndScaleFactor = 1.f;
38 EndAngleInDegrees = 0.f;
39 StartDiffuse = CRGBA::White;
40 EndDiffuse = CRGBA::Black;
41 StartEmissive = CRGBA::Black;
42 EndEmissive = CRGBA::Black;
45 // *****************************************************************************
46 void CDecalAnim::updateDecal(const NLMISC::CVector2f &pos, float animRatio, CDecal &dest, float refScale) const
48 dest.setTexture(Texture);
49 dest.setWorldMatrixForSpot(pos, refScale * blend(1.f, EndScaleFactor, animRatio), blend(0.f, EndAngleInDegrees, animRatio));
50 dest.setDiffuse(blend(StartDiffuse, EndDiffuse, animRatio));
51 dest.setEmissive(blend(StartEmissive, EndEmissive, animRatio));
57 // *****************************************************************************
58 void CDecalAnim::buildFromLuaTable(CLuaObject &table)
60 // retrieve a value from a lua table or affect a default value if not found
61 #define GET_LUA_VALUE(dest, Type, CastType, Default) \
62 (dest) = (table[#dest].is##Type()) ? (CastType) table[#dest].to##Type() : (Default);
63 GET_LUA_VALUE(DurationInMs, Number, uint, 1000)
64 GET_LUA_VALUE(EndScaleFactor, Number, float, 1.f)
65 GET_LUA_VALUE(EndAngleInDegrees, Number, float, 1.f)
66 GET_LUA_VALUE(Texture, String, std::string, "")
67 GET_LUA_VALUE(StartDiffuse, RGBA, CRGBA, CRGBA::White)
68 GET_LUA_VALUE(EndDiffuse, RGBA, CRGBA, CRGBA::White)
69 GET_LUA_VALUE(StartEmissive, RGBA, CRGBA, CRGBA::Black)
70 GET_LUA_VALUE(EndEmissive, RGBA, CRGBA, CRGBA::Black)