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)
|
print("Loading ", EXTERNAL_PATH + file)
|
||||||
var node = gltf.generate_scene(gltf_state)
|
var node = gltf.generate_scene(gltf_state)
|
||||||
var entity_count = 0;
|
|
||||||
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(trimesh):
|
|
||||||
o.create_trimesh_collision()
|
|
||||||
else:
|
|
||||||
o.create_convex_collision()
|
|
||||||
parent.add_child(node)
|
parent.add_child(node)
|
||||||
if(entity_count > 0):
|
|
||||||
print("Loaded ", entity_count, " entities.")
|
get_all_entities(node)
|
||||||
|
|
||||||
|
if not hasCollision:
|
||||||
|
return node
|
||||||
|
|
||||||
|
for o in get_all_children(node):
|
||||||
|
if o is MeshInstance3D:
|
||||||
|
if(trimesh):
|
||||||
|
o.create_trimesh_collision()
|
||||||
|
else:
|
||||||
|
o.create_convex_collision()
|
||||||
return node
|
return node
|
||||||
|
|
||||||
func get_all_entities(at_node):
|
func get_all_entities(at_node):
|
||||||
var entity_count = 0
|
var entity_count = 0
|
||||||
for o in get_all_children(at_node):
|
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)
|
print("Loading entity ", o.name)
|
||||||
if loadEntity(o):
|
if loadEntity(o):
|
||||||
entity_count += 1;
|
entity_count += 1;
|
||||||
@@ -73,8 +71,13 @@ func loadEntity(node):
|
|||||||
if(not config.has_section(node.name)):
|
if(not config.has_section(node.name)):
|
||||||
printerr("NO CONFIG FOUND FOR ENTITY : ", node.name)
|
printerr("NO CONFIG FOUND FOR ENTITY : ", node.name)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
var entity = load_gltf(config.get_value(node.name, "model"), node.get_parent()) as Node3D
|
|
||||||
if(entity == null):
|
if(entity == null):
|
||||||
printerr("ENTITY COULD NOT BE CREATED : ", node.name)
|
printerr("ENTITY COULD NOT BE CREATED : ", node.name)
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user