//------------------------------
	ChunkLength MeshBase::calculateFacesMaterialsLength(CountType trianglesCount, const COLLADAFW::MaterialBindingArray& materialBindings)
	{
		// the size is determined by:
		// 1) the number of materials and their name length
		// 2) the triangles count

		if ( trianglesCount == 0)
		{
			return 0;
		}

		if ( materialBindings.empty() )
		{
			return 0;
			// TODO: This works only if either all faces have a material assigned or none
		}

		ChunkLength length = 0;
		// each triangle appears exactly once in a facenum array
		length += trianglesCount * sizeof(IndexType);

		ChunkLength materialsCount = (ChunkLength)materialBindings.getCount();

		//fix size for each material
		// empty chunk length of faces material
		// material name length
		// nFaces length
		length += (EMPTY_CHUNK_LENGTH + sizeof(CountType) + Writer::getMaterialNameLength() ) * materialsCount;

		return length;
	}
	//--------------------------------------------------------------------
	void Nebula3Writer::getMaterialBinding(NodeData& nodeData,const COLLADAFW::MaterialBindingArray& materialArray )
	{
		for (size_t j=0;j< materialArray.getCount();j++)
		{
			const MaterialBinding& material = materialArray[j];	
			const COLLADAFW::MaterialId materialId = material.getMaterialId();
			nodeData.materialDatas.Add(materialId,MaterialData());
			MaterialData& materialData = nodeData.materialDatas[materialId];
			materialData.materialId = materialId;
			materialData.materialUniqueId = material.getReferencedMaterial();
			const COLLADAFW::TextureCoordinateBindingArray& textureInfos = material.getTextureCoordinateBindingArray();
			for (size_t k=0;k< textureInfos.getCount();k++)
			{
				const TextureCoordinateBinding& textureInfo = textureInfos[k];
				const COLLADAFW::TextureMapId textureMapId = textureInfo.getTextureMapId();
				materialData.textureDatas.Add(textureMapId,MaterialData::TextureCoordData());
				MaterialData::TextureCoordData& textureData = materialData.textureDatas[textureMapId];
				textureData.texturemapId = textureMapId;
				textureData.uvSetIndex = textureInfo.getSetIndex();
				textureData.Semantic = textureInfo.getSemantic().c_str();
			}///end for
		}///end for
	}