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/>.
18 #include "sky_object_sheet.h"
20 using namespace NLMISC
;
22 /////////////////////////////////
23 // CSkyObjectSheet::CColorInfo //
24 /////////////////////////////////
26 // *****************************************************************************************************
27 void CSkyObjectSheet::CColorInfoSheet::build(const NLGEORGES::UFormElm
&item
, const std::string
&prefix
)
29 item
.getValueByName(MapName
, (prefix
+ "MapName").c_str());
31 item
.getValueByName(mode
, (prefix
+ "ColorMode").c_str());
32 Mode
= (TSkyColorMode
) mode
;
35 // *****************************************************************************************************
36 void CSkyObjectSheet::CColorInfoSheet::serial(NLMISC::IStream
&f
)
42 /////////////////////////////////////////
43 // CSkyObjectSheet::CColorGradientInfo //
44 /////////////////////////////////////////
46 // *****************************************************************************************************
47 void CSkyObjectSheet::CColorGradientInfoSheet::build(const NLGEORGES::UFormElm
&item
, const std::string
&prefix
)
49 item
.getValueByName(TargetTextureStage
, (prefix
+ "TargetTextureStage").c_str());
50 const NLGEORGES::UFormElm
*elm
= NULL
;
51 if(item
.getNodeByName (&elm
, prefix
+ "WeatherToGradient") && elm
)
54 nlverify (elm
->getArraySize (numBitmaps
));
55 WeatherToGradient
.resize(numBitmaps
);
56 // For each sky object
57 for(uint k
= 0; k
< numBitmaps
; ++k
)
59 elm
->getArrayValue(WeatherToGradient
[k
], k
);
64 // *****************************************************************************************************
65 void CSkyObjectSheet::CColorGradientInfoSheet::serial(NLMISC::IStream
&f
)
67 f
.serial(TargetTextureStage
);
68 f
.serialCont(WeatherToGradient
);
71 ///////////////////////////////
72 // CSkyObjectSheet::CVersion //
73 ///////////////////////////////
75 // *****************************************************************************************************
76 void CSkyObjectSheet::CVersionSheet::build(const NLGEORGES::UFormElm
&item
, const std::string
&prefix
)
78 item
.getValueByName(ShapeName
, (prefix
+ "ShapeName").c_str());
79 item
.getValueByName(TransparencyPriority
, (prefix
+ "TransparencyPriority").c_str());
80 DiffuseColor
.build(item
, prefix
+ "DiffuseColor.");
81 ParticleEmitters
.build(item
, prefix
+ "ParticleEmitters.");
82 for(uint k
= 0; k
< SKY_MAX_NUM_STAGE
; ++k
)
84 // build constant color infos
85 ConstantColor
[k
].build(item
, prefix
+ toString("ConstantColor%d.", (int) k
));
87 item
.getValueByName(TexPanner
[k
].U
, (prefix
+ toString("PannerU%d", k
)).c_str());
88 item
.getValueByName(TexPanner
[k
].V
, (prefix
+ toString("PannerV%d", k
)).c_str());
90 item
.getValueByName(OffsetFactor
[k
].U
, (prefix
+ toString("OffsetFactorU%d", k
)).c_str());
91 item
.getValueByName(OffsetFactor
[k
].V
, (prefix
+ toString("OffsetFactorV%d", k
)).c_str());
92 // texture scaling depending on weather & hour
93 item
.getValueByName(OffsetUBitmap
[k
], (prefix
+ toString("OffsetUBitmap%d", k
)).c_str());
94 item
.getValueByName(OffsetVBitmap
[k
], (prefix
+ toString("OffsetVBitmap%d", k
)).c_str());
97 item
.getValueByName(refColor
, (prefix
+ "RefColor").c_str());
98 RefColor
= (TSkyRefColor
) refColor
;
99 ColorGradient
.build(item
, prefix
+ "ColorGradient.");
100 for(uint k
= 0; k
< SKY_MAX_NUM_STAGE
; ++k
)
102 item
.getValueByName(FXUserParamBitmap
[k
], (prefix
+ toString("UserParam%d", (int) k
)).c_str());
106 // *****************************************************************************************************
107 void CSkyObjectSheet::CVersionSheet::serial(NLMISC::IStream
&f
)
110 f
.serial(TransparencyPriority
);
111 f
.serial(DiffuseColor
);
112 f
.serial(ParticleEmitters
);
113 for(uint k
= 0; k
< SKY_MAX_NUM_STAGE
; ++k
)
115 f
.serial(ConstantColor
[k
]);
116 f
.serial(TexPanner
[k
]);
117 f
.serial(OffsetFactor
[k
]);
118 f
.serial(FXUserParamBitmap
[k
]);
119 f
.serial(OffsetUBitmap
[k
]);
120 f
.serial(OffsetVBitmap
[k
]);
122 f
.serialEnum(RefColor
);
123 f
.serial(ColorGradient
);
126 /////////////////////
127 // CSkyObjectSheet //
128 /////////////////////
130 // *****************************************************************************************************
131 CSkyObjectSheet::CSkyObjectSheet()
133 VisibleInMainScene
= true;
134 VisibleInEnvMap
= true;
137 // *****************************************************************************************************
138 void CSkyObjectSheet::build(const NLGEORGES::UFormElm
&item
, const std::string
&prefix
)
140 Std
.build(item
, prefix
+ "StdVersion.");
141 FallbackPass
[0].build(item
, prefix
+ "FallbackPass0.");
142 FallbackPass
[1].build(item
, prefix
+ "FallbackPass1.");
143 item
.getValueByName(VisibleInMainScene
, (prefix
+ "VisibleInMainScene").c_str());
144 item
.getValueByName(VisibleInEnvMap
, (prefix
+ "VisibleInEnvMap").c_str());
147 // *****************************************************************************************************
148 void CSkyObjectSheet::serial(NLMISC::IStream
&f
)
151 f
.serial(FallbackPass
[0]);
152 f
.serial(FallbackPass
[1]);
153 f
.serial(VisibleInMainScene
);
154 f
.serial(VisibleInEnvMap
);