本文整理汇总了C++中AnimationPlayer::get_node方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationPlayer::get_node方法的具体用法?C++ AnimationPlayer::get_node怎么用?C++ AnimationPlayer::get_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnimationPlayer
的用法示例。
在下文中一共展示了AnimationPlayer::get_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _update_filters
bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &anode) {
if (updating || _filter_edit != anode)
return false;
NodePath player_path = anode->get_tree()->get_animation_player();
if (!anode->get_tree()->has_node(player_path)) {
EditorNode::get_singleton()->show_warning(TTR("No animation player set, so unable to retrieve track names."));
return false;
}
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(anode->get_tree()->get_node(player_path));
if (!player) {
EditorNode::get_singleton()->show_warning(TTR("Player path set is invalid, so unable to retrieve track names."));
return false;
}
Node *base = player->get_node(player->get_root());
if (!base) {
EditorNode::get_singleton()->show_warning(TTR("Animation player has no valid root node path, so unable to retrieve track names."));
return false;
}
updating = true;
Set<String> paths;
{
List<StringName> animations;
player->get_animation_list(&animations);
for (List<StringName>::Element *E = animations.front(); E; E = E->next()) {
Ref<Animation> anim = player->get_animation(E->get());
for (int i = 0; i < anim->get_track_count(); i++) {
paths.insert(anim->track_get_path(i));
}
}
}
filter_enabled->set_pressed(anode->is_filter_enabled());
filters->clear();
TreeItem *root = filters->create_item();
Map<String, TreeItem *> parenthood;
for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
NodePath path = E->get();
TreeItem *ti = NULL;
String accum;
for (int i = 0; i < path.get_name_count(); i++) {
String name = path.get_name(i);
if (accum != String()) {
accum += "/";
}
accum += name;
if (!parenthood.has(accum)) {
if (ti) {
ti = filters->create_item(ti);
} else {
ti = filters->create_item(root);
}
parenthood[accum] = ti;
ti->set_text(0, name);
ti->set_selectable(0, false);
ti->set_editable(0, false);
if (base->has_node(accum)) {
Node *node = base->get_node(accum);
if (has_icon(node->get_class(), "EditorIcons")) {
ti->set_icon(0, get_icon(node->get_class(), "EditorIcons"));
} else {
ti->set_icon(0, get_icon("Node", "EditorIcons"));
}
}
} else {
ti = parenthood[accum];
}
}
Node *node = NULL;
if (base->has_node(accum)) {
node = base->get_node(accum);
}
if (!node)
continue; //no node, cant edit
if (path.get_subname_count()) {
String concat = path.get_concatenated_subnames();
Skeleton *skeleton = Object::cast_to<Skeleton>(node);
if (skeleton && skeleton->find_bone(concat) != -1) {
//path in skeleton
String bone = concat;
int idx = skeleton->find_bone(bone);
List<String> bone_path;
//.........这里部分代码省略.........
示例2: _node_assign
void EditorPropertyRootMotion::_node_assign() {
NodePath current = get_edited_object()->get(get_edited_property());
AnimationTree *atree = Object::cast_to<AnimationTree>(get_edited_object());
if (!atree->has_node(atree->get_animation_player())) {
EditorNode::get_singleton()->show_warning(TTR("AnimationTree has no path set to an AnimationPlayer"));
return;
}
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(atree->get_node(atree->get_animation_player()));
if (!player) {
EditorNode::get_singleton()->show_warning(TTR("Path to AnimationPlayer is invalid"));
return;
}
Node *base = player->get_node(player->get_root());
if (!base) {
EditorNode::get_singleton()->show_warning(TTR("Animation player has no valid root node path, so unable to retrieve track names."));
return;
}
Set<String> paths;
{
List<StringName> animations;
player->get_animation_list(&animations);
for (List<StringName>::Element *E = animations.front(); E; E = E->next()) {
Ref<Animation> anim = player->get_animation(E->get());
for (int i = 0; i < anim->get_track_count(); i++) {
paths.insert(anim->track_get_path(i));
}
}
}
filters->clear();
TreeItem *root = filters->create_item();
Map<String, TreeItem *> parenthood;
for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
NodePath path = E->get();
TreeItem *ti = NULL;
String accum;
for (int i = 0; i < path.get_name_count(); i++) {
String name = path.get_name(i);
if (accum != String()) {
accum += "/";
}
accum += name;
if (!parenthood.has(accum)) {
if (ti) {
ti = filters->create_item(ti);
} else {
ti = filters->create_item(root);
}
parenthood[accum] = ti;
ti->set_text(0, name);
ti->set_selectable(0, false);
ti->set_editable(0, false);
if (base->has_node(accum)) {
Node *node = base->get_node(accum);
if (has_icon(node->get_class(), "EditorIcons")) {
ti->set_icon(0, get_icon(node->get_class(), "EditorIcons"));
} else {
ti->set_icon(0, get_icon("Node", "EditorIcons"));
}
}
} else {
ti = parenthood[accum];
}
}
Node *node = NULL;
if (base->has_node(accum)) {
node = base->get_node(accum);
}
if (!node)
continue; //no node, cant edit
if (path.get_subname_count()) {
String concat = path.get_concatenated_subnames();
Skeleton *skeleton = Object::cast_to<Skeleton>(node);
if (skeleton && skeleton->find_bone(concat) != -1) {
//path in skeleton
String bone = concat;
int idx = skeleton->find_bone(bone);
List<String> bone_path;
while (idx != -1) {
bone_path.push_front(skeleton->get_bone_name(idx));
idx = skeleton->get_bone_parent(idx);
}
accum += ":";
//.........这里部分代码省略.........