Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / sky_object.h
blob6dcf343f156aef3198eeb3f5fa479e27f4a2763f
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
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 #ifndef CL_SKY_OBJECT_H
18 #define CL_SKY_OBJECT_H
21 #include "nel/misc/bitmap.h"
23 #include "nel/3d/u_instance.h"
24 #include "nel/3d/u_particle_system_instance.h"
26 #include "client_sheets/sky_object_sheet.h"
28 #include "time_client.h"
30 namespace NL3D
32 class UAnimationSet;
33 class UPlayListManager;
34 class UPlayManager;
37 class CSkyObject
39 public:
40 ////////////////////////////////////////////////
41 // tells how a color is computed in the shape //
42 ////////////////////////////////////////////////
43 class CColorInfo
45 public:
46 NLMISC::CBitmap *Map; // color computed from a map depending on hour & weather (NULL if color is unseted)
47 TSkyColorMode Mode; // how the color is to be used
48 public:
49 CColorInfo() : Map(NULL) {}
50 /** Init color map from its name. Eventually load the bitmap if itsn't found in the map
51 * \param bitmapByName already build bitmap, sorted by their name
52 * \param buildBitmap list of used bitmap (to be completed if required bitmap id not in "bitmapByName")
54 void init(const CSkyObjectSheet::CColorInfoSheet &ci,
55 std::map<std::string, NLMISC::CBitmap *> &bitmapByName,
56 std::vector<NLMISC::CBitmap *> &buildBitmap);
57 // compute color depending on hour & weather & fog color
58 NLMISC::CRGBA computeColor(float dayPart, float weatherLevel, NLMISC::CRGBA fogColor);
60 ////////////////////////////////////////////////////////////////////////////////
61 // tells how a color gradient is computed in the shape (-> sky dome gradient) //
62 ////////////////////////////////////////////////////////////////////////////////
63 class CColorGradientInfo
65 public:
66 sint32 TargetTextureStage; // the texture stage to which the gradient must be applied.
67 /** each bitmap in the following list gives the gradient depending on light level. The V coordinate gives the gradient values, end U gives the light level
68 * each bitmap match a weather state. First bitmap maps to weather value = 0 and last bitmap maps to weather value = 1
69 * for intermediary weather values, the two nearest bitmap are blended to get the value of the gradient
72 std::vector<NLMISC::CBitmap *> WeatherToGradient;
73 NLMISC::CBitmap Slice0[2]; // 2 column for slice 0
74 NLMISC::CBitmap Slice1[2]; // 2 columns for slice 1
75 NLMISC::CBitmap Final;
76 public:
77 // ctor
78 CColorGradientInfo() : TargetTextureStage(0) {}
79 /** Init from a sheet.
80 * Init color gradient from its bitmap names. Eventually load the bitmap if itsn't found in the map
81 * \param bitmapByName already build bitmap, sorted by their name
82 * \param buildBitmap list of used bitmap (to be completed if required bitmaps are not in "bitmapByName")
84 void init(const CSkyObjectSheet::CColorGradientInfoSheet &cgi,
85 std::map<std::string, NLMISC::CBitmap *> &bitmapByName,
86 std::vector<NLMISC::CBitmap *> &buildBitmap);
87 void setup(NL3D::UInstance instance, float dayPart, float weatherLevel, NLMISC::CBitmap &gradientCache, NLMISC::CBitmap &gradientCacheBlurred);
90 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91 NL3D::UInstance Instance; // Instance of object to be displayed
92 NL3D::UParticleSystemInstance PS; // If the object is also a particle system, keep a pointer on it.
94 CColorInfo DiffuseColor; // map for diffuse color (or fx color), depending on light level and weather
95 CColorInfo ParticleEmitters; // map whose R channel control emitters activation
96 CColorInfo ConstantColor[SKY_MAX_NUM_STAGE]; // map for constant color at each stage
97 CColorGradientInfo ColorGradient;
98 TSkyRefColor RefColor; // tells which color info is used to test if object is visible (when alpha is 0, the object must be hidden)
99 // cache last colors
100 NLMISC::CRGBA LastDiffuseColor;
101 NLMISC::CRGBA LastParticleEmittersColor;
102 NLMISC::CRGBA LastConstantColor[SKY_MAX_NUM_STAGE];
103 // cache last gradient
104 NLMISC::CBitmap GradientCache;
105 NLMISC::CBitmap GradientCacheBlurred;
106 NLMISC::CUV TexPanner[SKY_MAX_NUM_STAGE];
107 NLMISC::CUV OffsetFactor[SKY_MAX_NUM_STAGE];
108 NLMISC::CBitmap *FXUserParams[SKY_MAX_NUM_FX_USER_PARAMS];
110 // texture scaling depending on weather and time
111 NLMISC::CBitmap *OffsetUBitmap[SKY_MAX_NUM_STAGE];
112 NLMISC::CBitmap *OffsetVBitmap[SKY_MAX_NUM_STAGE];
114 std::string Name;
115 bool Active;
117 bool VisibleInMainScene;
118 bool VisibleInEnvMap;
119 public:
120 // ctor
121 CSkyObject() : Instance(NULL),
122 PS(NULL),
123 Active(false),
124 VisibleInMainScene(true),
125 VisibleInEnvMap(true)
127 LastDiffuseColor.set(0, 0, 0, 0);
128 LastParticleEmittersColor.set(0, 0, 0, 0);
129 for(uint k = 0; k < SKY_MAX_NUM_STAGE; ++k)
131 LastConstantColor[k].set(0, 0, 0, 0);
132 OffsetUBitmap[k] = NULL;
133 OffsetVBitmap[k] = NULL;
134 TexPanner[k].set(0.f, 0.f);
135 OffsetFactor[k].set(1.f, 1.f);
137 for(uint k = 0; k < SKY_MAX_NUM_FX_USER_PARAMS; ++k)
139 FXUserParams[k] = NULL;
142 // dtor
143 ~CSkyObject();
144 /** Init sky object from a sheet (main or fallback version)
145 * \param sheet to init from
146 * \param instance Instance of the object in the scene
147 * \param bitmapByName already build bitmap, sorted by their name
148 * \param buildBitmap list of used bitmap (to be completed if required bitmap id not in "bitmapByName")
150 void init(const CSkyObjectSheet::CVersionSheet &sheet,
151 NL3D::UInstance instance,
152 std::map<std::string, NLMISC::CBitmap *> &bitmapByName,
153 std::vector<NLMISC::CBitmap *> &builtBitmaps,
154 bool visibleInMainScene,
155 bool visibleInEnvMap
157 /** setup the given instance to reflect the given hour & weather
158 * \param duskSetup true if the setup os for the dusk (dawn otherwise)
159 * \return true if the object is visible
161 bool setup(const CClientDate &date, const CClientDate &animationDate, float numHoursInDay, float weatherLevel, NLMISC::CRGBA fogColor, bool envMapScene);
165 #endif