| 280 | } |
| 281 | |
| 282 | void Collada::_parse_image(XMLParser &p_parser) { |
| 283 | String id = p_parser.get_named_attribute_value("id"); |
| 284 | |
| 285 | if (!(state.import_flags & IMPORT_FLAG_SCENE)) { |
| 286 | if (!p_parser.is_empty()) { |
| 287 | p_parser.skip_section(); |
| 288 | } |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | Image image; |
| 293 | |
| 294 | if (state.version < State::Version(1, 4, 0)) { |
| 295 | /* <1.4 */ |
| 296 | String path = p_parser.get_named_attribute_value("source").strip_edges(); |
| 297 | if (!path.contains("://") && path.is_relative_path()) { |
| 298 | // path is relative to file being loaded, so convert to a resource path |
| 299 | image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path.uri_file_decode())); |
| 300 | } |
| 301 | } else { |
| 302 | while (p_parser.read() == OK) { |
| 303 | if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { |
| 304 | String name = p_parser.get_node_name(); |
| 305 | |
| 306 | if (name == "init_from") { |
| 307 | p_parser.read(); |
| 308 | String path = p_parser.get_node_data().strip_edges().uri_file_decode(); |
| 309 | |
| 310 | if (!path.contains("://") && path.is_relative_path()) { |
| 311 | // path is relative to file being loaded, so convert to a resource path |
| 312 | path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path)); |
| 313 | |
| 314 | } else if (path.find("file:///") == 0) { |
| 315 | path = path.replace_first("file:///", ""); |
| 316 | path = ProjectSettings::get_singleton()->localize_path(path); |
| 317 | } |
| 318 | |
| 319 | image.path = path; |
| 320 | |
| 321 | } else if (name == "data") { |
| 322 | ERR_PRINT("COLLADA Embedded image data not supported!"); |
| 323 | |
| 324 | } else if (name == "extra" && !p_parser.is_empty()) { |
| 325 | p_parser.skip_section(); |
| 326 | } |
| 327 | |
| 328 | } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "image") { |
| 329 | break; //end of <asset> |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | state.image_map[id] = image; |
| 335 | } |
| 336 | |
| 337 | void Collada::_parse_material(XMLParser &p_parser) { |
| 338 | if (!(state.import_flags & IMPORT_FLAG_SCENE)) { |
nothing calls this directly
no test coverage detected