Compare commits
3 Commits
a7118b3d77
...
5cfc0839f7
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cfc0839f7 | |||
| 2e4c378991 | |||
| 40d73f2590 |
@@ -35,27 +35,25 @@ func load_gltf(file, parent = self, hasCollision = false, trimesh = false):
|
||||
|
||||
print("Loading ", EXTERNAL_PATH + file)
|
||||
var node = gltf.generate_scene(gltf_state)
|
||||
var entity_count = 0;
|
||||
parent.add_child(node)
|
||||
|
||||
get_all_entities(node)
|
||||
|
||||
if not hasCollision:
|
||||
return node
|
||||
|
||||
for o in get_all_children(node):
|
||||
if o.name.begins_with("entity_") && not o.name.ends_with("_geometry"):
|
||||
print("Loading entity ", o.name)
|
||||
if loadEntity(o):
|
||||
entity_count += 1;
|
||||
elif o is MeshInstance3D:
|
||||
if hasCollision:
|
||||
if o is MeshInstance3D:
|
||||
if(trimesh):
|
||||
o.create_trimesh_collision()
|
||||
else:
|
||||
o.create_convex_collision()
|
||||
parent.add_child(node)
|
||||
if(entity_count > 0):
|
||||
print("Loaded ", entity_count, " entities.")
|
||||
return node
|
||||
|
||||
func get_all_entities(at_node):
|
||||
var entity_count = 0
|
||||
for o in get_all_children(at_node):
|
||||
if o.name.begins_with("entity_") && not o.name.ends_with("_geometry"):
|
||||
if o.name.begins_with("entity_"):
|
||||
print("Loading entity ", o.name)
|
||||
if loadEntity(o):
|
||||
entity_count += 1;
|
||||
@@ -74,7 +72,12 @@ func loadEntity(node):
|
||||
printerr("NO CONFIG FOUND FOR ENTITY : ", node.name)
|
||||
return false
|
||||
|
||||
var entity = load_gltf(config.get_value(node.name, "model"), node.get_parent()) as Node3D
|
||||
var model = config.get_value(node.name, "model")
|
||||
var has_collision = config.get_value(node.name, "has_collision")
|
||||
var has_trimesh_col = config.get_value(node.name, "has_trimesh_col")
|
||||
|
||||
var entity = load_gltf(model, node.get_parent(), has_collision, has_trimesh_col) as Node3D
|
||||
|
||||
if(entity == null):
|
||||
printerr("ENTITY COULD NOT BE CREATED : ", node.name)
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user