diff options
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/editor_import_collada.cpp | 191 | ||||
-rw-r--r-- | editor/import/editor_import_collada.h | 2 | ||||
-rw-r--r-- | editor/import/editor_import_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/import/editor_import_plugin.h | 2 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 3 | ||||
-rw-r--r-- | editor/import/resource_importer_csv_translation.cpp | 26 | ||||
-rw-r--r-- | editor/import/resource_importer_csv_translation.h | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.cpp | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.h | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 252 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_texture.cpp | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_texture.h | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_wav.cpp | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_wav.h | 2 |
15 files changed, 80 insertions, 414 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index a75147a3a9..86482dad5a 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -41,6 +41,7 @@ #include "scene/animation/animation_player.h" #include "scene/resources/animation.h" #include "scene/resources/packed_scene.h" + #include <iostream> struct ColladaImport { @@ -320,7 +321,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { } else { //mesh since nothing else node = memnew(MeshInstance); - node->cast_to<MeshInstance>()->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); } } break; case Collada::Node::TYPE_SKELETON: { @@ -1238,173 +1239,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me Array mr; -//////////////////////////// -// THEN THE MORPH TARGETS // -//////////////////////////// -#if 0 - if (p_morph_data) { - - //add morphie target - ERR_FAIL_COND_V( !p_morph_data->targets.has("MORPH_TARGET"), ERR_INVALID_DATA ); - String mt = p_morph_data->targets["MORPH_TARGET"]; - ERR_FAIL_COND_V( !p_morph_data->sources.has(mt), ERR_INVALID_DATA); - int morph_targets = p_morph_data->sources[mt].sarray.size(); - mr.resize(morph_targets); - - for(int j=0;j<morph_targets;j++) { - - Array mrt; - mrt.resize(VS::ARRAY_MAX); - - String target = p_morph_data->sources[mt].sarray[j]; - ERR_FAIL_COND_V( !collada.state.mesh_data_map.has(target), ERR_INVALID_DATA ); - String name = collada.state.mesh_data_map[target].name; - Collada::MeshData &md = collada.state.mesh_data_map[target]; - - // collada in itself supports morphing everything. However, the spec is unclear and no examples or exporters that - // morph anything but "POSITIONS" seem to exit. Because of this, normals and binormals/tangents have to be regenerated here, - // which may result in inaccurate (but most of the time good enough) results. - - PoolVector<Vector3> vertices; - vertices.resize(vlen); - - ERR_FAIL_COND_V( md.vertices.size() != 1, ERR_INVALID_DATA); - String vertex_src_id=md.vertices.front()->key(); - ERR_FAIL_COND_V(!md.vertices[vertex_src_id].sources.has("POSITION"),ERR_INVALID_DATA); - String position_src_id = md.vertices[vertex_src_id].sources["POSITION"]; - - ERR_FAIL_COND_V(!md.sources.has(position_src_id),ERR_INVALID_DATA); - - const Collada::MeshData::Source *m=&md.sources[position_src_id]; - - ERR_FAIL_COND_V( m->array.size() != vertex_src->array.size(), ERR_INVALID_DATA); - int stride=m->stride; - if (stride==0) - stride=3; - - - //read vertices from morph target - PoolVector<Vector3>::Write vertw = vertices.write(); - - for(int m_i=0;m_i<m->array.size()/stride;m_i++) { - - int pos = m_i*stride; - Vector3 vtx( m->array[pos+0], m->array[pos+1], m->array[pos+2] ); - -#ifndef NO_UP_AXIS_SWAP - if (collada.state.up_axis==Vector3::AXIS_Z) { - - SWAP( vtx.z, vtx.y ); - vtx.z = -vtx.z; - - } -#endif - - Collada::Vertex vertex; - vertex.vertex=vtx; - vertex.fix_unit_scale(collada); - vtx=vertex.vertex; - - vtx = p_local_xform.xform(vtx); - - - if (vertex_map.has(m_i)) { //vertex may no longer be here, don't bother converting - - - for (Set<int> ::Element *E=vertex_map[m_i].front() ; E; E=E->next() ) { - - vertw[E->get()]=vtx; - } - } - } - - - //vertices are in place, now generate everything else - vertw = PoolVector<Vector3>::Write(); - PoolVector<Vector3> normals; - PoolVector<float> tangents; - print_line("vertex source id: "+vertex_src_id); - if(md.vertices[vertex_src_id].sources.has("NORMAL")){ - //has normals - normals.resize(vlen); - //std::cout << "has normals" << std::endl; - String normal_src_id = md.vertices[vertex_src_id].sources["NORMAL"]; - //std::cout << "normals source: "<< normal_src_id.utf8().get_data() <<std::endl; - ERR_FAIL_COND_V(!md.sources.has(normal_src_id),ERR_INVALID_DATA); - - const Collada::MeshData::Source *m=&md.sources[normal_src_id]; - - ERR_FAIL_COND_V( m->array.size() != vertex_src->array.size(), ERR_INVALID_DATA); - int stride=m->stride; - if (stride==0) - stride=3; - - - //read normals from morph target - PoolVector<Vector3>::Write vertw = normals.write(); - - for(int m_i=0;m_i<m->array.size()/stride;m_i++) { - - int pos = m_i*stride; - Vector3 vtx( m->array[pos+0], m->array[pos+1], m->array[pos+2] ); - -#ifndef NO_UP_AXIS_SWAP - if (collada.state.up_axis==Vector3::AXIS_Z) { - - SWAP( vtx.z, vtx.y ); - vtx.z = -vtx.z; - - } -#endif - - Collada::Vertex vertex; - vertex.vertex=vtx; - vertex.fix_unit_scale(collada); - vtx=vertex.vertex; - - vtx = p_local_xform.xform(vtx); - - - if (vertex_map.has(m_i)) { //vertex may no longer be here, don't bother converting - - - for (Set<int> ::Element *E=vertex_map[m_i].front() ; E; E=E->next() ) { - - vertw[E->get()]=vtx; - } - } - } - - print_line("using built-in normals"); - }else{ - print_line("generating normals"); - _generate_normals(index_array,vertices,normals);//no normals - } - if (final_tangent_array.size() && final_uv_array.size()) { - - _generate_tangents_and_binormals(index_array,vertices,final_uv_array,normals,tangents); - - } - - mrt[Mesh::ARRAY_VERTEX]=vertices; - - mrt[Mesh::ARRAY_NORMAL]=normals; - if (tangents.size()) - mrt[Mesh::ARRAY_TANGENT]=tangents; - if (final_uv_array.size()) - mrt[Mesh::ARRAY_TEX_UV]=final_uv_array; - if (final_uv2_array.size()) - mrt[Mesh::ARRAY_TEX_UV2]=final_uv2_array; - if (final_color_array.size()) - mrt[Mesh::ARRAY_COLOR]=final_color_array; - - mr[j]=mrt; - - } - - } + //////////////////////////// + // THEN THE MORPH TARGETS // + //////////////////////////// -#endif for (int mi = 0; mi < p_morph_meshes.size(); mi++) { //print_line("want surface "+itos(mi)+" has "+itos(p_morph_meshes[mi]->get_surface_count())); @@ -1448,9 +1286,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) { Spatial *node = node_map[p_node->id].node; Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); - if (node->cast_to<Path>()) { + if (Object::cast_to<Path>(node)) { - Path *path = node->cast_to<Path>(); + Path *path = Object::cast_to<Path>(node); String curve = ng->source; @@ -1523,11 +1361,11 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) { } } - if (node->cast_to<MeshInstance>()) { + if (Object::cast_to<MeshInstance>(node)) { Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); - MeshInstance *mi = node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(node); ERR_FAIL_COND_V(!mi, ERR_BUG); @@ -1561,7 +1399,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) { } ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA); NodeMap nmsk = node_map[skname]; - Skeleton *sk = nmsk.node->cast_to<Skeleton>(); + Skeleton *sk = Object::cast_to<Skeleton>(nmsk.node); ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA); ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA); Map<String, int> &bone_remap_map = skeleton_bone_map[sk]; @@ -1584,14 +1422,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) { apply_xform = Transform(); } - Collada::SkinControllerData::Source *joint_src = NULL; - ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"), ERR_INVALID_DATA); String joint_id = skin->weights.sources["JOINT"].source; ERR_FAIL_COND_V(!skin->sources.has(joint_id), ERR_INVALID_DATA); - joint_src = &skin->sources[joint_id]; + Collada::SkinControllerData::Source *joint_src = &skin->sources[joint_id]; bone_remap.resize(joint_src->sarray.size()); @@ -2094,7 +1930,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones if (nm.bone >= 0) { //make bone transform relative to rest (in case of skeleton) - Skeleton *sk = nm.node->cast_to<Skeleton>(); + Skeleton *sk = Object::cast_to<Skeleton>(nm.node); if (sk) { xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; @@ -2317,7 +2153,6 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path if (state.animations.size() == 0) return Ref<Animation>(); Ref<Animation> anim = state.animations[0]; - anim = state.animations[0]; print_line("Anim Load OK"); String base = p_path.get_basename().to_lower(); if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) { diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 2c60916d52..865a72739f 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index 4ebbcb1610..8af4ab63c7 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index b60813db61..08d6de5531 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 1c42bcef8a..2f03e72851 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1216,7 +1216,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (bct.has("index")) { Ref<Texture> t = _get_texture(state, bct["index"]); material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); - material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED); + material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN); if (!mr.has("metallicFactor")) { @@ -1243,6 +1243,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { Dictionary bct = d["occlusionTexture"]; if (bct.has("index")) { material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"])); + material->set_ao_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED); material->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true); } } diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 9214b8f45e..4bbf5ba316 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -73,19 +73,26 @@ String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const { void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const { r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0)); } Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { bool compress = p_options["compress"]; + + String delimiter; + switch ((int)p_options["delimiter"]) { + case 0: delimiter = ","; break; + case 1: delimiter = ";"; break; + case 2: delimiter = "\t"; break; + } + FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ); ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); - Vector<String> line = f->get_csv_line(); - if (line.size() <= 1) { - return ERR_PARSE_ERROR; - } + Vector<String> line = f->get_csv_line(delimiter); + ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR); Vector<String> locales; Vector<Ref<Translation> > translations; @@ -93,9 +100,8 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const for (int i = 1; i < line.size(); i++) { String locale = line[i]; - if (!TranslationServer::is_locale_valid(locale)) { - return ERR_PARSE_ERROR; - } + ERR_EXPLAIN("Error importing CSV translation: '" + locale + "' is not a valid locale"); + ERR_FAIL_COND_V(!TranslationServer::is_locale_valid(locale), ERR_PARSE_ERROR); locales.push_back(locale); Ref<Translation> translation; @@ -104,7 +110,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const translations.push_back(translation); } - line = f->get_csv_line(); + line = f->get_csv_line(delimiter); while (line.size() == locales.size() + 1) { @@ -116,7 +122,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const } } - line = f->get_csv_line(); + line = f->get_csv_line(delimiter); } for (int i = 0; i < translations.size(); i++) { diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index 748c6264df..8919f4ed33 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 8f86e64cf2..6a936649c3 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index c8285ce6c9..247d58e148 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 798f57f8c3..dd98494504 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -171,41 +171,10 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array memdelete(p_node); return NULL; } -#if 0 - if (p_node->cast_to<MeshInstance>()) { - - MeshInstance *mi = p_node->cast_to<MeshInstance>(); - - bool bb = false; - - if ((_teststr(name, "bb"))) { - bb = true; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(), "bb"))) { - bb = true; - } - if (bb) { - mi->set_flag(GeometryInstance::FLAG_BILLBOARD, true); - if (mi->get_mesh().is_valid()) { + if (Object::cast_to<MeshInstance>(p_node)) { - Ref<ArrayMesh> m = mi->get_mesh(); - for (int i = 0; i < m->get_surface_count(); i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - //fm->set_flag(Material::FLAG_UNSHADED,true); - //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - //fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - } - } - } -#endif - if (p_node->cast_to<MeshInstance>()) { - - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); Ref<ArrayMesh> m = mi->get_mesh(); @@ -232,9 +201,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array } } - if (p_node->cast_to<AnimationPlayer>()) { + if (Object::cast_to<AnimationPlayer>(p_node)) { //remove animations referencing non-importable nodes - AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node); List<StringName> anims; ap->get_animation_list(&anims); @@ -256,133 +225,24 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array } } } -#if 0 - if (p_node->cast_to<MeshInstance>()) { - - MeshInstance *mi = p_node->cast_to<MeshInstance>(); - - String str; - - if ((_teststr(name, "imp"))) { - str = name; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(), "imp"))) { - str = mi->get_mesh()->get_name(); - } - - if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) { - MeshInstance *mi = p_node->cast_to<MeshInstance>(); - MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>(); - String d = str.substr(str.find("imp") + 3, str.length()); - if (d != "") { - if ((d[0] < '0' || d[0] > '9')) - d = d.substr(1, d.length()); - if (d.length() && d[0] >= '0' && d[0] <= '9') { - float dist = d.to_double(); - mi->set_flag(GeometryInstance::FLAG_BILLBOARD, true); - mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y, true); - //mi->set_draw_range_begin(dist); - //mi->set_draw_range_end(100000); - - //mip->set_draw_range_begin(0); - //mip->set_draw_range_end(dist); - - if (mi->get_mesh().is_valid()) { - - Ref<ArrayMesh> m = mi->get_mesh(); - for (int i = 0; i < m->get_surface_count(); i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - //fm->set_flag(Material::FLAG_UNSHADED,true); - //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - //fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - } - } - } - } - } - -#endif -#if 0 - if (p_flags&SCENE_FLAG_CREATE_LODS && p_node->cast_to<MeshInstance>()) { - - MeshInstance *mi = p_node->cast_to<MeshInstance>(); - - String str; - - if ((_teststr(name,"lod"))) { - str=name; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"lod"))) { - str=mi->get_mesh()->get_name(); - - } - - - if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) { - MeshInstance *mi = p_node->cast_to<MeshInstance>(); - MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>(); - String d=str.substr(str.find("lod")+3,str.length()); - if (d!="") { - if ((d[0]<'0' || d[0]>'9')) - d=d.substr(1,d.length()); - if (d.length() && d[0]>='0' && d[0]<='9') { - float dist = d.to_double(); - /// mi->set_draw_range_begin(dist); - // mi->set_draw_range_end(100000); - - // mip->set_draw_range_begin(0); - // mip->set_draw_range_end(dist); - - /*if (mi->get_mesh().is_valid()) { - - Ref<ArrayMesh> m = mi->get_mesh(); - for(int i=0;i<m->get_surface_count();i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - fm->set_flag(Material::FLAG_UNSHADED,true); - fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true); - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - }*/ - } - } - } - } - - - if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && p_node->cast_to<MeshInstance>()) { - MeshInstance *mi = p_node->cast_to<MeshInstance>(); - - String str=name; - int layer = str.substr(str.find("lm")+3,str.length()).to_int(); - //mi->set_baked_light_texture_id(layer); - } -#endif if (_teststr(name, "colonly")) { if (isroot) return p_node; - if (p_node->cast_to<MeshInstance>()) { - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + if (MeshInstance *mi = Object::cast_to<MeshInstance>(p_node)) { Node *col = mi->create_trimesh_collision_node(); ERR_FAIL_COND_V(!col, NULL); col->set_name(_fixstr(name, "colonly")); - col->cast_to<Spatial>()->set_transform(mi->get_transform()); + Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); p_node->replace_by(col); memdelete(p_node); p_node = col; - StaticBody *sb = col->cast_to<StaticBody>(); - CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>(); + StaticBody *sb = Object::cast_to<StaticBody>(col); + CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0)); colshape->set_name("shape"); colshape->set_owner(p_node->get_owner()); } else if (p_node->has_meta("empty_draw_type")) { @@ -390,7 +250,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array print_line(empty_draw_type); StaticBody *sb = memnew(StaticBody); sb->set_name(_fixstr(name, "colonly")); - sb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); + Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform()); p_node->replace_by(sb); memdelete(p_node); CollisionShape *colshape = memnew(CollisionShape); @@ -404,7 +264,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array rayShape->set_length(1); colshape->set_shape(rayShape); colshape->set_name("RayShape"); - sb->cast_to<Spatial>()->rotate_x(Math_PI / 2); + Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2); } else if (empty_draw_type == "IMAGE") { PlaneShape *planeShape = memnew(PlaneShape); colshape->set_shape(planeShape); @@ -419,13 +279,13 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array colshape->set_owner(sb->get_owner()); } - } else if (_teststr(name, "rigid") && p_node->cast_to<MeshInstance>()) { + } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) { if (isroot) return p_node; // get mesh instance and bounding box - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); Rect3 aabb = mi->get_aabb(); // create a new rigid body collision node @@ -436,12 +296,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array // remove node name postfix col->set_name(_fixstr(name, "rigid")); // get mesh instance xform matrix to the rigid body collision node - col->cast_to<Spatial>()->set_transform(mi->get_transform()); + Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); // save original node by duplicating it into a new instance and correcting the name Node *mesh = p_node->duplicate(); mesh->set_name(_fixstr(name, "rigid")); // reset the xform matrix of the duplicated node so it can inherit parent node xform - mesh->cast_to<Spatial>()->set_transform(Transform(Basis())); + Object::cast_to<Spatial>(mesh)->set_transform(Transform(Basis())); // reparent the new mesh node to the rigid body collision node p_node->add_child(mesh); mesh->set_owner(p_node->get_owner()); @@ -451,7 +311,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array p_node = col; // create an alias for the rigid body collision node - RigidBody *rb = col->cast_to<RigidBody>(); + RigidBody *rb = Object::cast_to<RigidBody>(col); // create a new Box collision shape and set the right extents Ref<BoxShape> shape = memnew(BoxShape); shape->set_extents(aabb.get_size() * 0.5); @@ -462,9 +322,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array rb->add_child(colshape); colshape->set_owner(p_node->get_owner()); - } else if (_teststr(name, "col") && p_node->cast_to<MeshInstance>()) { + } else if (_teststr(name, "col") && Object::cast_to<MeshInstance>(p_node)) { - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); mi->set_name(_fixstr(name, "col")); Node *col = mi->create_trimesh_collision_node(); @@ -473,19 +333,19 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array col->set_name("col"); p_node->add_child(col); - StaticBody *sb = col->cast_to<StaticBody>(); - CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>(); + StaticBody *sb = Object::cast_to<StaticBody>(col); + CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0)); colshape->set_name("shape"); col->add_child(colshape); colshape->set_owner(p_node->get_owner()); sb->set_owner(p_node->get_owner()); - } else if (_teststr(name, "navmesh") && p_node->cast_to<MeshInstance>()) { + } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); ERR_FAIL_COND_V(mesh.is_null(), NULL); @@ -495,7 +355,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array Ref<NavigationMesh> nmesh = memnew(NavigationMesh); nmesh->create_from_mesh(mesh); nmi->set_navigation_mesh(nmesh); - nmi->cast_to<Spatial>()->set_transform(mi->get_transform()); + Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform()); p_node->replace_by(nmi); memdelete(p_node); p_node = nmi; @@ -505,7 +365,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array return p_node; Node *owner = p_node->get_owner(); - Spatial *s = p_node->cast_to<Spatial>(); + Spatial *s = Object::cast_to<Spatial>(p_node); VehicleBody *bv = memnew(VehicleBody); String n = _fixstr(p_node->get_name(), "vehicle"); bv->set_name(n); @@ -525,7 +385,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array return p_node; Node *owner = p_node->get_owner(); - Spatial *s = p_node->cast_to<Spatial>(); + Spatial *s = Object::cast_to<Spatial>(p_node); VehicleWheel *bv = memnew(VehicleWheel); String n = _fixstr(p_node->get_name(), "wheel"); bv->set_name(n); @@ -538,13 +398,13 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array s->set_transform(Transform()); p_node = bv; - - } else if (_teststr(name, "room") && p_node->cast_to<MeshInstance>()) { +#if 0 + } else if (_teststr(name, "room") && Object::cast_to<MeshInstance>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); BSP_Tree bsptree(faces); @@ -567,7 +427,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array if (isroot) return p_node; - Spatial *dummy = p_node->cast_to<Spatial>(); + Spatial *dummy = Object::cast_to<Spatial>(p_node); ERR_FAIL_COND_V(!dummy, NULL); Room *room = memnew(Room); @@ -580,12 +440,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array //room->compute_room_from_subtree(); - } else if (_teststr(name, "portal") && p_node->cast_to<MeshInstance>()) { + } else if (_teststr(name, "portal") && Object::cast_to<MeshInstance>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); ERR_FAIL_COND_V(faces.size() == 0, NULL); @@ -658,12 +518,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array p_node->replace_by(portal); memdelete(p_node); p_node = portal; - - } else if (p_node->cast_to<MeshInstance>()) { +#endif + } else if (Object::cast_to<MeshInstance>(p_node)) { //last attempt, maybe collision insde the mesh data - MeshInstance *mi = p_node->cast_to<MeshInstance>(); + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); if (!mesh.is_null()) { @@ -682,38 +542,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array if (!shape.is_null()) collision_map[mesh] = shape; } - - if (!shape.is_null()) { -#if 0 - StaticBody* static_body = memnew( StaticBody ); - ERR_FAIL_COND_V(!static_body,NULL); - static_body->set_name( String(mesh->get_name()) + "_col" ); - shape->set_name(static_body->get_name()); - static_body->add_shape(shape); - - mi->add_child(static_body); - if (mi->get_owner()) - static_body->set_owner( mi->get_owner() ); -#endif - } - } - - for (int i = 0; i < mesh->get_surface_count(); i++) { - - Ref<SpatialMaterial> fm = mesh->surface_get_material(i); - if (fm.is_valid()) { - String name = fm->get_name(); - /* if (_teststr(name,"alpha")) { - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - name=_fixstr(name,"alpha"); - } - - if (_teststr(name,"vcol")) { - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY,true); - name=_fixstr(name,"vcol"); - }*/ - fm->set_name(name); - } } } } @@ -728,7 +556,7 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo Node *n = scene->get_node(String("AnimationPlayer")); ERR_FAIL_COND(!n); - AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); + AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n); ERR_FAIL_COND(!anim); if (!anim->has_animation("default")) @@ -847,7 +675,7 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { return; Node *n = scene->get_node(String("AnimationPlayer")); ERR_FAIL_COND(!n); - AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); + AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n); ERR_FAIL_COND(!anim); Vector<String> strings = p_text.split("\n"); @@ -954,7 +782,7 @@ void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_er return; Node *n = scene->get_node(String("AnimationPlayer")); ERR_FAIL_COND(!n); - AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); + AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n); ERR_FAIL_COND(!anim); List<StringName> anim_names; @@ -1196,10 +1024,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p String root_type = p_options["nodes/root_type"]; if (scene->get_class() != root_type) { - Object *base = ClassDB::instance(root_type); - Node *base_node = NULL; - if (base) - base_node = base->cast_to<Node>(); + Node *base_node = base_node = Object::cast_to<Node>(ClassDB::instance(root_type)); if (base_node) { @@ -1287,7 +1112,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p Ref<EditorScenePostImport> post_import_script; if (post_import_script_path != "") { - post_import_script_path = post_import_script_path; // FIXME: is there a good reason for this? Ref<Script> scr = ResourceLoader::load(post_import_script_path); if (!scr.is_valid()) { EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index f404582d7e..bf8d88ce0a 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 060e683077..6de523736b 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index 31bd0f29b0..b374a9bc04 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 07f1f4dd9f..25185149b1 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index 6b4f86e641..f58392e820 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ |