Path: blob/master/scene/animation/animation_blend_space_1d.h
9917 views
/**************************************************************************/1/* animation_blend_space_1d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/animation/animation_tree.h"3334class AnimationNodeBlendSpace1D : public AnimationRootNode {35GDCLASS(AnimationNodeBlendSpace1D, AnimationRootNode);3637public:38enum BlendMode {39BLEND_MODE_INTERPOLATED,40BLEND_MODE_DISCRETE,41BLEND_MODE_DISCRETE_CARRY,42};4344protected:45enum {46MAX_BLEND_POINTS = 6447};4849struct BlendPoint {50StringName name;51Ref<AnimationRootNode> node;52float position = 0.0;53};5455BlendPoint blend_points[MAX_BLEND_POINTS];56int blend_points_used = 0;5758float max_space = 1.0;59float min_space = -1.0;6061float snap = 0.1;6263String value_label = "value";6465void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node);6667StringName blend_position = "blend_position";68StringName closest = "closest";6970BlendMode blend_mode = BLEND_MODE_INTERPOLATED;7172bool sync = false;7374void _validate_property(PropertyInfo &p_property) const;75static void _bind_methods();7677virtual void _tree_changed() override;78virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;79virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;8081public:82virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;83virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;8485virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;8687void add_blend_point(const Ref<AnimationRootNode> &p_node, float p_position, int p_at_index = -1);88void set_blend_point_position(int p_point, float p_position);89void set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node);9091float get_blend_point_position(int p_point) const;92Ref<AnimationRootNode> get_blend_point_node(int p_point) const;93void remove_blend_point(int p_point);94int get_blend_point_count() const;9596void set_min_space(float p_min);97float get_min_space() const;9899void set_max_space(float p_max);100float get_max_space() const;101102void set_snap(float p_snap);103float get_snap() const;104105void set_value_label(const String &p_label);106String get_value_label() const;107108void set_blend_mode(BlendMode p_blend_mode);109BlendMode get_blend_mode() const;110111void set_use_sync(bool p_sync);112bool is_using_sync() const;113114virtual NodeTimeInfo _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false) override;115String get_caption() const override;116117Ref<AnimationNode> get_child_by_name(const StringName &p_name) const override;118119AnimationNodeBlendSpace1D();120~AnimationNodeBlendSpace1D();121};122123VARIANT_ENUM_CAST(AnimationNodeBlendSpace1D::BlendMode)124125126