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/>.
19 #include "mesh_array.h"
21 #include "../global.h"
28 using namespace NLMISC
;
35 // *********************************************************************************************************
36 CMeshArray::CMeshArray()
41 // *********************************************************************************************************
42 CMeshArray::~CMeshArray()
47 // *********************************************************************************************************
48 void CMeshArray::setShapeName(const std::string
&shapeName
)
50 //H_AUTO(R2_CMeshArray_setShapeName)
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
);
69 uint oldSize
= (uint
)_MeshInstances
.size();
70 _MeshInstances
.resize(newSize
);
71 for(uint k
= oldSize
; k
< newSize
; ++k
)
73 _MeshInstances
[k
] = Scene
->createInstance(_ShapeName
);
76 _MeshInstances
[k
].show();
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
)
121 _MeshInstances
[k
].show();
125 _MeshInstances
[k
].hide();