Initial commit
This commit is contained in:
39
modules/world/terrain_object.cpp
Normal file
39
modules/world/terrain_object.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <scene/3d/mesh_instance.h>
|
||||
#include "terrain_object.h"
|
||||
|
||||
List<TerrainObject> TerrainObject::get_objects(const PackedScene *sc, const NodePath &path)
|
||||
{
|
||||
int i, j;
|
||||
List<TerrainObject> obj_list;
|
||||
if (sc) {
|
||||
Node *tmp = sc->instance();
|
||||
Node *obj = tmp->get_node_or_null(path);
|
||||
if (!obj)
|
||||
printf("no objects :(\n");
|
||||
if (obj) {
|
||||
printf("objects: %d\n", obj->get_child_count());
|
||||
for (i = 0; i < obj->get_child_count(); i++) {
|
||||
Node *scobj = obj->get_child(i);
|
||||
if (!scobj)
|
||||
continue;
|
||||
TerrainObject tobj;
|
||||
printf("lods: %d\n", scobj->get_child_count());
|
||||
for (j = 0; j < scobj->get_child_count(); j++) {
|
||||
Node *p = scobj->get_child(j);
|
||||
MeshInstance *mi = Object::cast_to<MeshInstance>(p);
|
||||
if (mi) {
|
||||
Ref<Mesh> data = mi->get_mesh();
|
||||
if (data.ptr()) {
|
||||
tobj.add_mesh(data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (tobj.lods.size() > 0)
|
||||
obj_list.push_back(tobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj_list;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user