Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / r2 / mesh_array.cpp
blob661f56937d1c20c8ff9b82e7279fbdea606f5dc4
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 #include "stdpch.h"
19 #include "mesh_array.h"
21 #include "../global.h"
22 #include "../misc.h"
24 #ifdef DEBUG_NEW
25 #define new DEBUG_NEW
26 #endif
28 using namespace NLMISC;
29 using namespace NL3D;
31 namespace R2
35 // *********************************************************************************************************
36 CMeshArray::CMeshArray()
38 _Active = true;
41 // *********************************************************************************************************
42 CMeshArray::~CMeshArray()
44 clear();
47 // *********************************************************************************************************
48 void CMeshArray::setShapeName(const std::string &shapeName)
50 //H_AUTO(R2_CMeshArray_setShapeName)
51 resize(0);
52 _ShapeName = shapeName;
55 // *********************************************************************************************************
56 void CMeshArray::resize(uint newSize)
58 //H_AUTO(R2_CMeshArray_resize)
59 if (newSize < _MeshInstances.size())
61 for(uint k = newSize; k < _MeshInstances.size(); ++k)
63 Scene->deleteInstance(_MeshInstances[k]);
65 _MeshInstances.resize(newSize);
67 else
69 uint oldSize = (uint)_MeshInstances.size();
70 _MeshInstances.resize(newSize);
71 for(uint k = oldSize; k < newSize; ++k)
73 _MeshInstances[k] = Scene->createInstance(_ShapeName);
74 if (_Active)
76 _MeshInstances[k].show();
78 else
80 _MeshInstances[k].hide();
86 // *********************************************************************************************************
87 UInstance &CMeshArray::getInstance(uint index)
89 //H_AUTO(R2_CMeshArray_getInstance)
90 nlassert(index < _MeshInstances.size());
91 return _MeshInstances[index];
94 // *********************************************************************************************************
95 const UInstance &CMeshArray::getInstance(uint index) const
97 //H_AUTO(R2_CMeshArray_getInstance)
98 nlassert(index < _MeshInstances.size());
99 return _MeshInstances[index];
102 // *********************************************************************************************************
103 void CMeshArray::setEmissive(NLMISC::CRGBA color)
105 //H_AUTO(R2_CMeshArray_setEmissive)
106 for(uint k = 0; k < _MeshInstances.size(); ++k)
108 ::setEmissive(_MeshInstances[k], color);
112 // *********************************************************************************************************
113 void CMeshArray::setActive(bool active)
115 //H_AUTO(R2_CMeshArray_setActive)
116 if (active == _Active) return;
117 for(uint k = 0; k < _MeshInstances.size(); ++k)
119 if (active)
121 _MeshInstances[k].show();
123 else
125 _MeshInstances[k].hide();
128 _Active = active;
132 } // R2