Merge branch 'ryzom/ark-features' into main/gingo-test
[ryzomcore.git] / nel / src / 3d / point_light_named.cpp
blobf4a6a9cac769a9ce6f25b8deb8fbda72aaccb4d8
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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/>.
17 #include "std3d.h"
19 #include "nel/3d/point_light_named.h"
21 #ifdef DEBUG_NEW
22 #define new DEBUG_NEW
23 #endif
25 namespace NL3D {
28 // ***************************************************************************
29 CPointLightNamed::CPointLightNamed()
31 // copy setup from current
32 _DefaultAmbient= getAmbient();
33 _DefaultDiffuse= getDiffuse();
34 _DefaultSpecular= getSpecular();
35 _UnAnimatedDiffuse= getDiffuse();
39 // ***************************************************************************
40 void CPointLightNamed::setLightFactor(NLMISC::CRGBA nFactor)
42 setLightFactor(nFactor, nFactor);
46 // ***************************************************************************
47 void CPointLightNamed::setLightFactor(NLMISC::CRGBA nAnimatedFactor, NLMISC::CRGBA nUnAnimatedFactor)
49 CRGBA col;
50 // setup current ambient.
51 col.modulateFromColor(_DefaultAmbient, nAnimatedFactor);
52 setAmbient(col);
53 // setup current diffuse.
54 col.modulateFromColor(_DefaultDiffuse, nAnimatedFactor);
55 setDiffuse(col);
56 // setup current specular.
57 col.modulateFromColor(_DefaultSpecular, nAnimatedFactor);
58 setSpecular(col);
60 // special UnAnimatedDiffuse
61 col.modulateFromColor(_DefaultDiffuse, nUnAnimatedFactor);
62 _UnAnimatedDiffuse= col;
66 // ***************************************************************************
67 void CPointLightNamed::serial(NLMISC::IStream &f)
69 sint ver = f.serialVersion(1);
71 // Serialize parent.
72 CPointLight::serial(f);
74 // Serialize my data
75 f.serial(AnimatedLight);
76 f.serial(_DefaultAmbient);
77 f.serial(_DefaultDiffuse);
78 f.serial(_DefaultSpecular);
80 if (ver>=1)
81 f.serial(LightGroup);
83 // read: and copy default _UnAnimatedDiffuse
84 if(f.isReading())
86 _UnAnimatedDiffuse= getDiffuse();
90 } // NL3D