Change Encyclo button name and macros icon
[ryzomcore.git] / nel / src / 3d / tile_element.cpp
blob6f89abf610361843df218349d54985c35efa7cf8
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/tile_element.h"
20 #include "nel/misc/debug.h"
22 #ifdef DEBUG_NEW
23 #define new DEBUG_NEW
24 #endif
26 namespace NL3D
30 void CTileElement::setTileOrient(sint i, uint8 orient)
32 nlassert(i>=0 && i<=2);
33 nlassert(orient<=3);
34 sint where= NL_TILE_ELM_SIZE_ROTATE*i+NL_TILE_ELM_OFFSET_ROTATE;
35 Flags&= ~(NL_TILE_ELM_MASK_ROTATE<<where);
36 Flags|= orient<<where;
40 uint8 CTileElement::getTileOrient(sint i) const
42 nlassert(i>=0 && i<=2);
43 sint where= NL_TILE_ELM_SIZE_ROTATE*i+NL_TILE_ELM_OFFSET_ROTATE;
44 return uint8 ((Flags>>where) & NL_TILE_ELM_MASK_ROTATE);
48 void CTileElement::setTile256Info(bool is256x256, uint8 uvOff)
50 nlassert(uvOff<=3);
51 sint where= NL_TILE_ELM_OFFSET_UVINFO;
52 sint info= uvOff+(is256x256?4:0);
53 Flags&= ~(NL_TILE_ELM_MASK_UVINFO<<where);
54 Flags|= info<<where;
58 void CTileElement::getTile256Info(bool &is256x256, uint8 &uvOff) const
60 sint where= NL_TILE_ELM_OFFSET_UVINFO;
61 sint info= ((Flags>>where) & NL_TILE_ELM_MASK_UVINFO);
62 uvOff= info&3;
63 is256x256= (info&4)?true:false;
67 void CTileElement::setTileSubNoise(uint8 subNoise)
69 nlassert(subNoise<=15);
70 sint where= NL_TILE_ELM_OFFSET_SUBNOISE;
71 Flags&= ~(NL_TILE_ELM_MASK_SUBNOISE<<where);
72 Flags|= subNoise<<where;
76 void CTileElement::serial(NLMISC::IStream &f)
78 f.xmlSerial (Flags, "FLAGS");
79 f.xmlSerial (Tile[0], Tile[1], Tile[2], "TILES_ID");
83 void CTileElement::setVegetableState(TVegetableInfo state)
85 nlassert(state < VegetInfoLast);
86 const uint16 mask = NL_TILE_ELM_MASK_VEGETABLE << NL_TILE_ELM_OFFSET_VEGETABLE;
87 Flags = (Flags & ~mask) | ((uint16) state << NL_TILE_ELM_OFFSET_VEGETABLE);
90 } // NL3D