本文整理汇总了C++中Spatial::get_parent_spatial方法的典型用法代码示例。如果您正苦于以下问题:C++ Spatial::get_parent_spatial方法的具体用法?C++ Spatial::get_parent_spatial怎么用?C++ Spatial::get_parent_spatial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spatial
的用法示例。
在下文中一共展示了Spatial::get_parent_spatial方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _notification
void NavigationMeshInstance::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
Spatial *c = this;
while (c) {
navigation = c->cast_to<Navigation>();
if (navigation) {
if (enabled && navmesh.is_valid()) {
nav_id = navigation->navmesh_create(navmesh, get_relative_transform(navigation), this);
}
break;
}
c = c->get_parent_spatial();
}
if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) {
MeshInstance *dm = memnew(MeshInstance);
dm->set_mesh(navmesh->get_debug_mesh());
if (is_enabled()) {
dm->set_material_override(get_tree()->get_debug_navigation_material());
} else {
dm->set_material_override(get_tree()->get_debug_navigation_disabled_material());
}
add_child(dm);
debug_view = dm;
}
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
if (navigation && nav_id != -1) {
navigation->navmesh_set_transform(nav_id, get_relative_transform(navigation));
}
} break;
case NOTIFICATION_EXIT_TREE: {
if (navigation) {
if (nav_id != -1) {
navigation->navmesh_remove(nav_id);
nav_id = -1;
}
}
if (debug_view) {
debug_view->queue_delete();
debug_view = NULL;
}
navigation = NULL;
} break;
}
}
示例2: _notification
void VisualInstance::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_WORLD: {
// CHECK ROOM
Spatial * parent = get_parent_spatial();
Room *room=NULL;
bool is_geom = cast_to<GeometryInstance>();
while(parent) {
room = parent->cast_to<Room>();
if (room)
break;
if (is_geom && parent->cast_to<BakedLightSampler>()) {
VS::get_singleton()->instance_geometry_set_baked_light_sampler(get_instance(),parent->cast_to<BakedLightSampler>()->get_instance());
break;
}
parent=parent->get_parent_spatial();
}
if (room) {
VisualServer::get_singleton()->instance_set_room(instance,room->get_instance());
}
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
/*
Skeleton *skeleton=get_parent()?get_parent()->cast_to<Skeleton>():NULL;
if (skeleton)
VisualServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
*/
VisualServer::get_singleton()->instance_set_scenario( instance, get_world()->get_scenario() );
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
Transform gt = get_global_transform();
VisualServer::get_singleton()->instance_set_transform(instance,gt);
} break;
case NOTIFICATION_EXIT_WORLD: {
VisualServer::get_singleton()->instance_set_scenario( instance, RID() );
VisualServer::get_singleton()->instance_set_room(instance,RID());
VisualServer::get_singleton()->instance_attach_skeleton( instance, RID() );
VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
} break;
}
}
示例3: _notification
void VisualInstance::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_WORLD: {
// CHECK ROOM
Spatial * parent = get_parent_spatial();
Room *room=NULL;
while(parent) {
room = parent->cast_to<Room>();
if (room)
break;
else
parent=parent->get_parent_spatial();
}
if (room) {
VisualServer::get_singleton()->instance_set_room(instance,room->get_instance());
}
// CHECK SKELETON
Skeleton *skeleton=get_parent()?get_parent()->cast_to<Skeleton>():NULL;
if (skeleton)
VisualServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
VisualServer::get_singleton()->instance_set_scenario( instance, get_world()->get_scenario() );
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
Transform gt = get_global_transform();
VisualServer::get_singleton()->instance_set_transform(instance,gt);
} break;
case NOTIFICATION_EXIT_WORLD: {
VisualServer::get_singleton()->instance_set_scenario( instance, RID() );
VisualServer::get_singleton()->instance_set_room(instance,RID());
VisualServer::get_singleton()->instance_attach_skeleton( instance, RID() );
} break;
}
}
示例4: _cell_button_pressed
void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) {
TreeItem *item=p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!item);
NodePath np = item->get_metadata(0);
Node *n=get_node(np);
ERR_FAIL_COND(!n);
if (p_id==BUTTON_SUBSCENE) {
//open scene request
Rect2 item_rect = tree->get_item_rect(item,0);
item_rect.pos.y-=tree->get_scroll().y;
item_rect.pos+=tree->get_global_pos();
if (n==get_scene_node()) {
inheritance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y));
inheritance_menu->set_size(Vector2(item_rect.size.x,0));
inheritance_menu->popup();
instance_node=n->get_instance_ID();
} else {
instance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y));
instance_menu->set_size(Vector2(item_rect.size.x,0));
if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(n))
instance_menu->set_item_checked(0,true);
else
instance_menu->set_item_checked(0,false);
if (n->get_owner()==get_scene_node()) {
instance_menu->set_item_checked(1,n->get_scene_instance_load_placeholder());
instance_menu->set_item_disabled(1,false);
} else {
instance_menu->set_item_checked(1,false);
instance_menu->set_item_disabled(1,true);
}
instance_menu->popup();
instance_node=n->get_instance_ID();
}
//emit_signal("open",n->get_filename());
} else if (p_id==BUTTON_SCRIPT) {
RefPtr script=n->get_script();
if (!script.is_null())
emit_signal("open_script",script);
} else if (p_id==BUTTON_VISIBILITY) {
if (n->is_type("Spatial")) {
Spatial *ci = n->cast_to<Spatial>();
if (!ci->is_visible() && ci->get_parent_spatial() && !ci->get_parent_spatial()->is_visible()) {
error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first."));
error->popup_centered_minsize();
return;
}
bool v = !bool(n->call("is_hidden"));
undo_redo->create_action(TTR("Toggle Spatial Visible"));
undo_redo->add_do_method(n,"_set_visible_",!v);
undo_redo->add_undo_method(n,"_set_visible_",v);
undo_redo->commit_action();
} else if (n->is_type("CanvasItem")) {
CanvasItem *ci = n->cast_to<CanvasItem>();
if (!ci->is_visible() && ci->get_parent_item() && !ci->get_parent_item()->is_visible()) {
error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first."));
error->popup_centered_minsize();
return;
}
bool v = !bool(n->call("is_hidden"));
undo_redo->create_action(TTR("Toggle CanvasItem Visible"));
undo_redo->add_do_method(n,v?"hide":"show");
undo_redo->add_undo_method(n,v?"show":"hide");
undo_redo->commit_action();
}
} else if (p_id==BUTTON_LOCK) {
if (n->is_type("CanvasItem")) {
n->set_meta("_edit_lock_", Variant());
_update_tree();
emit_signal("node_changed");
}
} else if (p_id==BUTTON_GROUP) {
if (n->is_type("CanvasItem")) {
n->set_meta("_edit_group_", Variant());
_update_tree();
emit_signal("node_changed");
}
} else if (p_id==BUTTON_WARNING) {
String config_err = n->get_configuration_warning();
if (config_err==String())
return;
config_err=config_err.word_wrap(80);
//.........这里部分代码省略.........