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/>.
22 #include "nel/3d/u_instance_material.h"
23 #include "sky_material_setup.h"
31 H_AUTO_DECL(RZ_SkyMaterialSetup
)
33 //===================================================================================
34 void CSkyMaterialSetup::buildFromInstance(NL3D::UInstance instance
, uint stage
)
36 H_AUTO_USE(RZ_SkyMaterialSetup
)
45 // take each texture at the given stage that is a texture file
46 for(uint k
= 0; k
< instance
.getNumMaterials(); ++k
)
48 UInstanceMaterial im
= instance
.getMaterial(k
);
50 if (im
.getLastTextureStage() >= (sint
) stage
) currStage
= stage
;
52 if (im
.isTextureFile(currStage
))
55 ti
.TexName
= im
.getTextureFileName(currStage
);
61 //===================================================================================
62 void CSkyMaterialSetup::applyToInstance(NL3D::UInstance instance
, uint stage
, bool skipFirstMaterial
/*= false*/)
64 H_AUTO_USE(RZ_SkyMaterialSetup
)
66 if (instance
.empty()) return;
67 for(uint k
= 0; k
< Setup
.size(); ++k
)
69 if (skipFirstMaterial
&& Setup
[k
].MatNum
== 0) continue;
70 if (Setup
[k
].MatNum
< instance
.getNumMaterials())
72 NL3D::UInstanceMaterial im
= instance
.getMaterial(Setup
[k
].MatNum
);
74 if (im
.getLastTextureStage() >= (sint
) stage
) currStage
= stage
;
76 if (!im
.isTextureFile(currStage
)) continue;
77 if (NLMISC::nlstricmp(Setup
[k
].TexName
, im
.getTextureFileName(currStage
)) != 0) // must change name ?
79 im
.setTextureFileName(Setup
[k
].TexName
, currStage
);