Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed, 00019 * Nathan Letwory 00020 * 00021 * ***** END GPL LICENSE BLOCK ***** 00022 */ 00023 00029 #include <string> 00030 #include <sstream> 00031 00032 #include "COLLADASWInstanceMaterial.h" 00033 00034 #include "BKE_customdata.h" 00035 #include "BKE_material.h" 00036 00037 #include "DNA_mesh_types.h" 00038 00039 #include "InstanceWriter.h" 00040 00041 #include "collada_internal.h" 00042 #include "collada_utils.h" 00043 00044 void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob) 00045 { 00046 for(int a = 0; a < ob->totcol; a++) { 00047 Material *ma = give_current_material(ob, a+1); 00048 00049 COLLADASW::InstanceMaterialList& iml = bind_material.getInstanceMaterialList(); 00050 00051 if (ma) { 00052 std::string matid(get_material_id(ma)); 00053 matid = translate_id(matid); 00054 std::ostringstream ostr; 00055 ostr << translate_id(id_name(ma)) << a+1; 00056 COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); 00057 00058 // create <bind_vertex_input> for each uv map 00059 Mesh *me = (Mesh*)ob->data; 00060 int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE); 00061 00062 for (int b = 0; b < totlayer; b++) { 00063 char *name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, b); 00064 im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", b)); 00065 } 00066 00067 iml.push_back(im); 00068 } 00069 } 00070 }