Changeset View
Changeset View
Standalone View
Standalone View
source/blender/collada/GeometryExporter.cpp
| Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | void GeometryExporter::createPolylist(short material_index, | ||||
| // if mesh has uv coords writes <input> for TEXCOORD | // if mesh has uv coords writes <input> for TEXCOORD | ||||
| int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); | int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); | ||||
| int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1; | int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1; | ||||
| for (i = 0; i < num_layers; i++) { | for (i = 0; i < num_layers; i++) { | ||||
| if (!this->export_settings->active_uv_only || i == active_uv_index) { | if (!this->export_settings->active_uv_only || i == active_uv_index) { | ||||
| // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i); | // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i); | ||||
| COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD, | COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD, | ||||
| makeUrl(makeTexcoordSourceId(geom_id, i)), | makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings->active_uv_only)), | ||||
| 2, // offset always 2, this is only until we have optimized UV sets | 2, // this is only until we have optimized UV sets | ||||
| i // set number equals UV map index | (this->export_settings->active_uv_only) ? 0 : i // only_active_uv exported -> we have only one set | ||||
| ); | ); | ||||
| til.push_back(input3); | til.push_back(input3); | ||||
| } | } | ||||
| } | } | ||||
| if (has_color) { | if (has_color) { | ||||
| COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2); | COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2); | ||||
| til.push_back(input4); | til.push_back(input4); | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | for (int j = 0; j < mpoly->totloop; j++, mlc++) { | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||
| source.finish(); | source.finish(); | ||||
| } | } | ||||
| std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int layer_index) | std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int layer_index, bool only_active_layer) | ||||
| { | { | ||||
| char suffix[20]; | char suffix[20]; | ||||
| if (only_active_layer) { | |||||
| suffix[0] = '\0'; | |||||
| } | |||||
| else { | |||||
| sprintf(suffix, "-%d", layer_index); | sprintf(suffix, "-%d", layer_index); | ||||
| } | |||||
| return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix; | return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix; | ||||
| } | } | ||||
| //creates <source> for texcoords | //creates <source> for texcoords | ||||
| void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) | void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) | ||||
| { | { | ||||
| int totpoly = me->totpoly; | int totpoly = me->totpoly; | ||||
| int totuv = me->totloop; | int totuv = me->totloop; | ||||
| MPoly *mpolys = me->mpoly; | MPoly *mpolys = me->mpoly; | ||||
| int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); | int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); | ||||
| // write <source> for each layer | // write <source> for each layer | ||||
| // each <source> will get id like meshName + "map-channel-1" | // each <source> will get id like meshName + "map-channel-1" | ||||
| int map_index = 0; | |||||
| int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV); | int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV); | ||||
| for (int a = 0; a < num_layers; a++) { | for (int a = 0; a < num_layers; a++) { | ||||
| if (!this->export_settings->active_uv_only || a == active_uv_index) { | if (!this->export_settings->active_uv_only || a == active_uv_index) { | ||||
| MLoopUV *mloops = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a); | MLoopUV *mloops = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a); | ||||
| COLLADASW::FloatSourceF source(mSW); | COLLADASW::FloatSourceF source(mSW); | ||||
| std::string layer_id = makeTexcoordSourceId(geom_id, map_index++); | std::string layer_id = makeTexcoordSourceId(geom_id, a, this->export_settings->active_uv_only); | ||||
| source.setId(layer_id); | source.setId(layer_id); | ||||
| source.setArrayId(layer_id + ARRAY_ID_SUFFIX); | source.setArrayId(layer_id + ARRAY_ID_SUFFIX); | ||||
| source.setAccessorCount(totuv); | source.setAccessorCount(totuv); | ||||
| source.setAccessorStride(2); | source.setAccessorStride(2); | ||||
| COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); | COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); | ||||
| param.push_back("S"); | param.push_back("S"); | ||||
| param.push_back("T"); | param.push_back("T"); | ||||
| ▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines | |||||