MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _parse_image

Method _parse_image

editor/import/3d/collada.cpp:282–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void 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
337void Collada::_parse_material(XMLParser &p_parser) {
338 if (!(state.import_flags & IMPORT_FLAG_SCENE)) {

Callers

nothing calls this directly

Calls 15

skip_sectionMethod · 0.80
strip_edgesMethod · 0.80
is_relative_pathMethod · 0.80
localize_pathMethod · 0.80
path_joinMethod · 0.80
get_base_dirMethod · 0.80
uri_file_decodeMethod · 0.80
get_node_dataMethod · 0.80
replace_firstMethod · 0.80
VersionClass · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected