本文整理汇总了C++中NodePath函数的典型用法代码示例。如果您正苦于以下问题:C++ NodePath函数的具体用法?C++ NodePath怎么用?C++ NodePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NodePath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NodePath
int EditorData::add_edited_scene(int p_at_pos) {
if (p_at_pos < 0)
p_at_pos = edited_scene.size();
EditedScene es;
es.root = NULL;
es.history_current = -1;
es.version = 0;
es.live_edit_root = NodePath(String("/root"));
if (p_at_pos == edited_scene.size())
edited_scene.push_back(es);
else
edited_scene.insert(p_at_pos, es);
if (current_edited_scene < 0)
current_edited_scene = 0;
return p_at_pos;
}
示例2: switch
void AnimationTreePlayer::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_TREE: {
if (!processing) {
//make sure that a previous process state was not saved
//only process if "processing" is set
set_fixed_process(false);
set_process(false);
}
} break;
case NOTIFICATION_READY: {
dirty_caches=true;
if (master!=NodePath()) {
_update_sources();
}
} break;
case NOTIFICATION_PROCESS: {
if (animation_process_mode==ANIMATION_PROCESS_FIXED)
break;
if (processing)
_process_animation( get_process_delta_time() );
} break;
case NOTIFICATION_FIXED_PROCESS: {
if (animation_process_mode==ANIMATION_PROCESS_IDLE)
break;
if (processing)
_process_animation(get_fixed_process_delta_time());
} break;
}
}
示例3: m_interface
LevelInterface::LevelInterface(WindowFramework* window):
m_interface(NodePath("LevelInterface")),
m_lifes(new TextNode("lifes"))
{
m_interface.reparent_to(window->get_render_2d());
hide();
//
PT(Texture) tex;
tex = TexturePool::load_texture( "resources/gui/lifes.png");
CardMaker cm("cardMaker");
cm.set_frame_fullscreen_quad();
PT(PandaNode) readyCard = cm.generate();
NodePath lifes(readyCard);
lifes.set_texture( tex );
lifes.reparent_to(m_interface);
lifes.set_scale(0.1, 0.1, 0.05);
lifes.set_pos(0.9, 0.8, 0.9);
//
m_lifes->set_text_color(0.f, 0.f, 1.f, 1.f);
m_lifes->set_text("0");
NodePath lifeText = m_interface.attach_new_node(m_lifes);
lifeText.set_scale(0.1);
lifeText.set_pos(0.91, 0.9, 0.875);
}
示例4: from
void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path,Vector<StringName> new_base_path,Node * p_node, List<Pair<NodePath,NodePath> > *p_renames) {
base_path.push_back(p_node->get_name());
if (new_base_path.size())
new_base_path.push_back(p_node->get_name());
NodePath from( base_path,true );
NodePath to;
if (new_base_path.size())
to=NodePath( new_base_path,true );
Pair<NodePath,NodePath> npp;
npp.first=from;
npp.second=to;
p_renames->push_back(npp);
for(int i=0;i<p_node->get_child_count();i++) {
_fill_path_renames(base_path,new_base_path,p_node->get_child(i),p_renames);
}
}
示例5: godot_node_path_new
void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from) {
NodePath *dest = (NodePath *)r_dest;
const String *from = (const String *)p_from;
memnew_placement(dest, NodePath(*from));
}
示例6: get_token
//.........这里部分代码省略.........
if (buffer.size()!=len) {
r_err_str="Couldn't allocate image buffer of size: "+itos(len);
}
{
DVector<uint8_t>::Write w=buffer.write();
for(int i=0;i<len;i++) {
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_COMMA) {
r_err_str="Expected ','";
return ERR_PARSE_ERROR;
}
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_NUMBER) {
r_err_str="Expected number";
return ERR_PARSE_ERROR;
}
w[i]=int(token.value);
}
}
Image img(width,height,mipmaps,format,buffer);
value=img;
return OK;
} else if (id=="NodePath") {
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_OPEN) {
r_err_str="Expected '('";
return ERR_PARSE_ERROR;
}
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_STRING) {
r_err_str="Expected string as argument for NodePath()";
return ERR_PARSE_ERROR;
}
value=NodePath(String(token.value));
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_CLOSE) {
r_err_str="Expected ')'";
return ERR_PARSE_ERROR;
}
} else if (id=="RID") {
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_OPEN) {
r_err_str="Expected '('";
return ERR_PARSE_ERROR;
}
示例7: godot_node_path_new
void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from) {
NodePath *np = (NodePath *)p_np;
String *from = (String *)p_from;
memnew_placement_custom(np, NodePath, NodePath(*from));
}
示例8: CLerpNodePathInterval
void World6::rotate_planets()
{
m_dayPeriodSun = new CLerpNodePathInterval("dayPeriodSunInterval",
20,
CLerpInterval::BT_no_blend,
true,
false,
m_sun,
NodePath());
m_dayPeriodSun->set_start_hpr(LVecBase3f( 0, 0, 0));
m_dayPeriodSun->set_end_hpr (LVecBase3f(360, 0, 0));
m_orbitPeriodMercury =
new CLerpNodePathInterval("orbitPeriodMercuryInterval",
0.241 * m_yearscale,
CLerpInterval::BT_no_blend,
true,
false,
m_orbitRootMercury,
NodePath());
m_orbitPeriodMercury->set_start_hpr(LVecBase3f( 0, 0, 0));
m_orbitPeriodMercury->set_end_hpr (LVecBase3f(360, 0, 0));
m_dayPeriodMercury = new CLerpNodePathInterval("dayPeriodMercuryInterval",
59 * m_dayscale,
CLerpInterval::BT_no_blend,
true,
false,
m_mercury,
NodePath());
m_dayPeriodMercury->set_start_hpr(LVecBase3f( 0, 0, 0));
m_dayPeriodMercury->set_end_hpr (LVecBase3f(360, 0, 0));
m_orbitPeriodVenus = new CLerpNodePathInterval("orbitPeriodVenusInterval",
0.615 * m_yearscale,
CLerpInterval::BT_no_blend,
true,
false,
m_orbitRootVenus,
NodePath());
m_orbitPeriodVenus->set_start_hpr(LVecBase3f( 0, 0, 0));
m_orbitPeriodVenus->set_end_hpr (LVecBase3f(360, 0, 0));
m_dayPeriodVenus = new CLerpNodePathInterval("dayPeriodVenusInterval",
243 * m_dayscale,
CLerpInterval::BT_no_blend,
true,
false,
m_venus,
NodePath());
m_dayPeriodVenus->set_start_hpr(LVecBase3f( 0, 0, 0));
m_dayPeriodVenus->set_end_hpr (LVecBase3f(360, 0, 0));
// Here the earth interval has been changed to rotate like the rest of the
// planets and send a message before it starts turning again. To send a
// message, the call is simply messenger.send("message"). The "newYear"
// message is picked up by the accept("newYear"...) statement earlier, and
// calls the incYear function as a result
m_orbitPeriodEarth = new CLerpNodePathInterval("orbitPeriodEarthInterval",
m_yearscale,
CLerpInterval::BT_no_blend,
true,
false,
m_orbitRootEarth,
NodePath());
m_orbitPeriodEarth->set_start_hpr(LVecBase3f( 0, 0, 0));
m_orbitPeriodEarth->set_end_hpr (LVecBase3f(360, 0, 0));
m_orbitPeriodEarth->set_done_event("newYear");
m_dayPeriodEarth = new CLerpNodePathInterval("dayPeriodEarthInterval",
m_dayscale,
CLerpInterval::BT_no_blend,
true,
false,
m_earth,
NodePath());
m_dayPeriodEarth->set_start_hpr(LVecBase3f( 0, 0, 0));
m_dayPeriodEarth->set_end_hpr (LVecBase3f(360, 0, 0));
m_orbitPeriodMoon = new CLerpNodePathInterval("orbitPeriodMoonInterval",
0.0749 * m_yearscale,
CLerpInterval::BT_no_blend,
true,
false,
m_orbitRootMoon,
NodePath());
m_orbitPeriodMoon->set_start_hpr(LVecBase3f( 0, 0, 0));
m_orbitPeriodMoon->set_end_hpr (LVecBase3f(360, 0, 0));
m_dayPeriodMoon = new CLerpNodePathInterval("dayPeriodMoonInterval",
0.0749 * m_dayscale,
CLerpInterval::BT_no_blend,
true,
false,
m_moon,
NodePath());
m_dayPeriodMoon->set_start_hpr(LVecBase3f( 0, 0, 0));
m_dayPeriodMoon->set_end_hpr (LVecBase3f(360, 0, 0));
m_orbitPeriodMars = new CLerpNodePathInterval("orbitPeriodMarsInterval",
//.........这里部分代码省略.........
示例9: ERR_FAIL_INDEX_V
NodePath Polygon2D::get_bone_path(int p_index) const {
ERR_FAIL_INDEX_V(p_index, bone_weights.size(), NodePath());
return bone_weights[p_index].path;
}
示例10: global_leg_ik_enabled_changed
void LegIKController::_ready() {
global_leg_ik_enabled_changed();
global_leg_ik_feet_reposition_rate_changed();
global_leg_ik_body_reposition_rate_changed();
//Ignore player collision hull
ray_exclusion_array = Set<RID>();
CollisionObject *collision_object = static_cast<CollisionObject *>(get_node(NodePath("..")));
if (collision_object)
ray_exclusion_array.insert(collision_object->get_rid());
skeleton = static_cast<Skeleton *>(get_node(skeleton_path));
if (skeleton != NULL) {
root_bone = skeleton->find_bone(root_bone_name);
pelvis = skeleton->find_bone(pelvis_name);
left_leg = skeleton->find_bone(left_leg_name);
left_knee = skeleton->find_bone(left_knee_name);
left_ankle = skeleton->find_bone(left_ankle_name);
left_toe = skeleton->find_bone(left_toe_name);
right_leg = skeleton->find_bone(right_leg_name);
right_knee = skeleton->find_bone(right_knee_name);
right_ankle = skeleton->find_bone(right_ankle_name);
right_toe = skeleton->find_bone(right_toe_name);
if (root_bone != -1 && pelvis != -1 &&
left_leg != -1 && left_knee != -1 && left_ankle != -1 &&
right_leg != -1 && right_knee != -1 && right_ankle != -1 &&
left_toe != -1 && right_toe != -1) {
left_thigh_length = skeleton->get_bone_global_pose(left_leg).origin.distance_to(skeleton->get_bone_global_pose(left_knee).origin);
left_calf_length = skeleton->get_bone_global_pose(left_knee).origin.distance_to(skeleton->get_bone_global_pose(left_ankle).origin);
left_leg_full_length = left_thigh_length + left_calf_length;
right_thigh_length = skeleton->get_bone_global_pose(right_leg).origin.distance_to(skeleton->get_bone_global_pose(right_knee).origin);
right_calf_length = skeleton->get_bone_global_pose(right_knee).origin.distance_to(skeleton->get_bone_global_pose(right_ankle).origin);
right_leg_full_length = right_thigh_length + right_calf_length;
prev_target_height = skeleton->get_bone_global_pose(root_bone).origin.y;
Transform left_foot_local_transform = skeleton->get_bone_global_pose(left_ankle);
Transform right_foot_local_transform = skeleton->get_bone_global_pose(right_ankle);
Transform left_foot_transform = skeleton->get_global_transform() * left_foot_local_transform;
Transform right_foot_transform = skeleton->get_global_transform() * right_foot_local_transform;
targeted_left_ground = left_foot_transform.origin;
targeted_right_ground = right_foot_transform.origin;
prev_left_ground = left_foot_local_transform.origin;
prev_right_ground = right_foot_local_transform.origin;
ik_valid = true;
}
else {
ik_valid = false;
}
}
}
示例11: NodePath
LegIKController::LegIKController() {
skeleton_path = NodePath();
bool ik_on = false;
bool ik_valid = false;
root_global_transform = Transform();
ray_exclusion_array = Set<RID>();
root_bone_name = "root";
pelvis_name = "lower_body";
left_leg_name = "leg.L";
left_knee_name = "knee.L";
left_ankle_name = "ankle.L";
left_toe_name = "toe.L";
right_leg_name = "leg.R";
right_knee_name = "knee.R";
right_ankle_name = "ankle.R";
right_toe_name = "toe.R";
root_bone = -1;
pelvis = -1;
left_leg = -1;
left_knee = -1;
left_ankle = -1;
left_toe = -1;
right_leg = -1;
right_knee = -1;
right_ankle = -1;
right_toe = -1;
left_thigh_length = 0.0f;
right_thigh_length = 0.0f;
left_calf_length = 0.0f;
right_calf_length = 0.0f;
left_leg_full_length = 0.0f;
right_leg_full_length = 0.0f;
animation_offset = 0.01f;
ankle_height_L = 0.0f;
ankle_height_R = 0.0f;
root_offset = 0.0f;
target_height = 0.0f;
prev_target_height = 0.0f;
target_height_velocity = 0.0f;
left_foot_down = false;
right_foot_down = false;
root = NULL;
skeleton = NULL;
dss = NULL;
targeted_left_ground = Vector3();
targeted_right_ground = Vector3();
ik_feet_reposition_rate = 15.0f;
ik_body_reposition_rate = 1.0f;
prev_left_ground = Vector3();
prev_right_ground = Vector3();
}
示例12: get_stylebox
void AnimationTreeEditor::_popup_edit_dialog() {
updating_edit=true;
for(int i=0;i<2;i++)
edit_scroll[i]->hide();
for(int i=0;i<4;i++) {
edit_line[i]->hide();
edit_label[i]->hide();
}
edit_option->hide();
edit_button->hide();;
filter_button->hide();
edit_check->hide();;
Point2 pos = anim_tree->node_get_pos(edited_node)-Point2(h_scroll->get_val(),v_scroll->get_val());
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
Size2 size = get_node_size(edited_node);
Point2 popup_pos( pos.x+style->get_margin(MARGIN_LEFT), pos.y+size.y-style->get_margin(MARGIN_BOTTOM));
popup_pos+=get_global_pos();
if (renaming_edit) {
edit_label[0]->set_text("New name:");
edit_label[0]->set_pos(Point2(5,5));
edit_label[0]->show();
edit_line[0]->set_begin(Point2(15,25));
edit_line[0]->set_text(edited_node);
edit_line[0]->show();
edit_dialog->set_size(Size2(150,50));
} else {
AnimationTreePlayer::NodeType type=anim_tree->node_get_type(edited_node);
switch(type) {
case AnimationTreePlayer::NODE_ANIMATION:
if (anim_tree->get_master_player()!=NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>()) {
AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>();
master_anim_popup->clear();
List<StringName> sn;
ap->get_animation_list(&sn);
sn.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E=sn.front();E;E=E->next()) {
master_anim_popup->add_item(E->get());
}
master_anim_popup->set_pos(popup_pos);
master_anim_popup->popup();
} else {
property_editor->edit(this,"",Variant::OBJECT,anim_tree->animation_node_get_animation(edited_node),PROPERTY_HINT_RESOURCE_TYPE,"Animation");
property_editor->set_pos(popup_pos);
property_editor->popup();
updating_edit=false;
}
return;
case AnimationTreePlayer::NODE_TIMESCALE:
edit_label[0]->set_text("Scale:");
edit_label[0]->set_pos(Point2(5,5));
edit_label[0]->show();
edit_line[0]->set_begin(Point2(15,25));
edit_line[0]->set_text(rtos(anim_tree->timescale_node_get_scale(edited_node)));
edit_line[0]->show();
edit_dialog->set_size(Size2(150,50));
break;
case AnimationTreePlayer::NODE_ONESHOT:
edit_label[0]->set_text("Fade In (s):");
edit_label[0]->set_pos(Point2(5,5));
edit_label[0]->show();
edit_line[0]->set_begin(Point2(15,25));
edit_line[0]->set_text(rtos(anim_tree->oneshot_node_get_fadein_time(edited_node)));
edit_line[0]->show();
edit_label[1]->set_text("Fade Out (s):");
edit_label[1]->set_pos(Point2(5,55));
edit_label[1]->show();
edit_line[1]->set_begin(Point2(15,75));
edit_line[1]->set_text(rtos(anim_tree->oneshot_node_get_fadeout_time(edited_node)));
edit_line[1]->show();
edit_option->clear();
edit_option->add_item("Blend",0);
edit_option->add_item("Mix",1);
edit_option->set_begin(Point2(15,105));
edit_option->select( anim_tree->oneshot_node_get_mix_mode(edited_node));
edit_option->show();
edit_check->set_text("Auto Restart:");
edit_check->set_begin(Point2(15,125));
edit_check->set_pressed(anim_tree->oneshot_node_has_autorestart(edited_node));
edit_check->show();
edit_label[2]->set_text("Restart (s):");
//.........这里部分代码省略.........
示例13: switch
//.........这里部分代码省略.........
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
return (MonoObject *)PoolByteArray_to_mono_array(p_var->operator PoolByteArray());
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
return (MonoObject *)PoolIntArray_to_mono_array(p_var->operator PoolIntArray());
if (array_type->eklass == REAL_T_MONOCLASS)
return (MonoObject *)PoolRealArray_to_mono_array(p_var->operator PoolRealArray());
if (array_type->eklass == CACHED_CLASS_RAW(String))
return (MonoObject *)PoolStringArray_to_mono_array(p_var->operator PoolStringArray());
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
return (MonoObject *)PoolVector2Array_to_mono_array(p_var->operator PoolVector2Array());
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
return (MonoObject *)PoolVector3Array_to_mono_array(p_var->operator PoolVector3Array());
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray());
ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed array of unmarshallable element type.");
ERR_FAIL_V(NULL);
} break;
case MONO_TYPE_CLASS: {
GDMonoClass *type_class = p_type.type_class;
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
return GDMonoUtils::unmanaged_get_managed(p_var->operator Object *());
}
if (CACHED_CLASS(NodePath) == type_class) {
return GDMonoUtils::create_managed_from(p_var->operator NodePath());
}
if (CACHED_CLASS(RID) == type_class) {
return GDMonoUtils::create_managed_from(p_var->operator RID());
}
} break;
case MONO_TYPE_OBJECT: {
// Variant
switch (p_var->get_type()) {
case Variant::BOOL: {
MonoBoolean val = p_var->operator bool();
return BOX_BOOLEAN(val);
}
case Variant::INT: {
int val = p_var->operator signed int();
return BOX_INT32(val);
}
case Variant::REAL: {
#ifdef REAL_T_IS_DOUBLE
double val = p_var->operator double();
return BOX_DOUBLE(val);
#else
float val = p_var->operator float();
return BOX_FLOAT(val);
#endif
}
case Variant::STRING:
return (MonoObject *)mono_string_from_godot(p_var->operator String());
case Variant::VECTOR2:
RETURN_BOXED_STRUCT(Vector2, p_var);
case Variant::RECT2:
示例14: ERR_FAIL_COND_V
//.........这里部分代码省略.........
continue;
if (PE->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && PE->get().usage&PROPERTY_USAGE_BUNDLE)) {
String name = PE->get().name;
Variant value = res->get(name);
if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) )
continue;
if (PE->get().type==Variant::OBJECT && value.is_zero() && !(PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL))
continue;
String vars;
VariantWriter::write_to_string(value,vars,_write_resources,this);
f->store_string(_valprop(name)+" = "+vars+"\n");
}
}
f->store_string("\n");
}
if (packed_scene.is_valid()) {
//if this is a scene, save nodes and connections!
Ref<SceneState> state = packed_scene->get_state();
for(int i=0;i<state->get_node_count();i++) {
StringName type = state->get_node_type(i);
StringName name = state->get_node_name(i);
NodePath path = state->get_node_path(i,true);
NodePath owner = state->get_node_owner_path(i);
Ref<PackedScene> instance = state->get_node_instance(i);
String instance_placeholder = state->get_node_instance_placeholder(i);
Vector<StringName> groups = state->get_node_groups(i);
String header="[node";
header+=" name=\""+String(name)+"\"";
if (type!=StringName()) {
header+=" type=\""+String(type)+"\"";
}
if (path!=NodePath()) {
header+=" parent=\""+String(path.simplified())+"\"";
}
if (owner!=NodePath() && owner!=NodePath(".")) {
header+=" owner=\""+String(owner.simplified())+"\"";
}
if (groups.size()) {
String sgroups=" groups=[ ";
for(int j=0;j<groups.size();j++) {
if (j>0)
sgroups+=", ";
sgroups+="\""+groups[j].operator String().c_escape()+"\"";
}
sgroups+=" ]";
header+=sgroups;
}
f->store_string(header);
示例15: _find_paths_for_filter
void AnimationTreeEditor::_edit_filters() {
filter_dialog->popup_centered_ratio();
filter->clear();
Set<String> npb;
_find_paths_for_filter(edited_node,npb);
TreeItem *root = filter->create_item();
filter->set_hide_root(true);
Map<String,TreeItem*> pm;
Node *base = anim_tree->get_node( anim_tree->get_base_path() );
for(Set<String>::Element *E=npb.front();E;E=E->next()) {
TreeItem *parent=root;
String descr=E->get();
if (base) {
NodePath np = E->get();
if (np.get_property()!=StringName()) {
Node *n = base->get_node(np);
Skeleton *s = n->cast_to<Skeleton>();
if (s) {
String skelbase = E->get().substr(0,E->get().find(":"));
int bidx = s->find_bone(np.get_property());
if (bidx!=-1) {
int bparent = s->get_bone_parent(bidx);
//
if (bparent!=-1) {
String bpn = skelbase+":"+s->get_bone_name(bparent);
if (pm.has(bpn)) {
parent=pm[bpn];
descr=np.get_property();
}
} else {
if (pm.has(skelbase)) {
parent=pm[skelbase];
}
}
}
}
}
}
TreeItem *it = filter->create_item(parent);
it->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
it->set_text(0,descr);
it->set_metadata(0,NodePath(E->get()));
it->set_editable(0,true);
if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ONESHOT) {
it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node,E->get()));
} else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) {
it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node,E->get()));
}
pm[E->get()]=it;
}
}