Merge branch 'main/rendor-staging' into fixes
[ryzomcore.git] / nel / src / ligo / ligo_material.cpp
blob2c46e69774fc3faff15d5ef7f57e1568618fbf23
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 "stdligo.h"
18 #include "nel/ligo/ligo_material.h"
20 // Ligo include
21 #include "nel/ligo/ligo_error.h"
23 //using namespace NL3D;
25 #ifdef DEBUG_NEW
26 #define new DEBUG_NEW
27 #endif
29 namespace NLLIGO
32 // ***************************************************************************
34 bool CMaterial::build (const CZoneTemplate &tplt, const CLigoConfig &config, CLigoError &errors)
36 // Clear errors
37 errors.clear ();
39 // Edge vector
40 const std::vector<CZoneEdge> &edges = tplt.getEdges ();
42 // This template should have 4 edges
43 if (edges.size() != 4)
45 errors.MainError = CLigoError::MustHave4Edges;
46 return false;
49 // The 1st edge must be symetrical
50 if (!edges[0].isSymetrical (config, errors))
51 return false;
53 // Error code
54 bool ok = true;
56 // The others must be the same edges
57 uint edge;
58 for (edge=1; edge<edges.size(); edge++)
60 // The same edge ?
61 if (!edges[0].isTheSame (edges[edge], config, errors))
63 // Error
64 ok = false;
68 // Build ?
69 if (ok)
71 // Ok, build the material
72 _ZoneEdge = edges[0];
75 // Return error code
76 return ok;
79 // ***************************************************************************
81 void CMaterial::serial (NLMISC::IStream &s)
83 // Serial the main node
84 s.xmlPush ("LIGO_MATERIAL");
86 // Serial the header
87 s.serialCheck (NELID("TMOL"));
89 // Serial the version
90 /*sint ver =*/ s.serialVersion (0);
92 // Serial the zoneedge
93 s.xmlSerial (_ZoneEdge, "ZONE_EDGE");
95 // Close the main node
96 s.xmlPop ();
99 // ***************************************************************************