1 /** 2 Contains data used to animate everything in the engine. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.animation; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.resource; 25 /** 26 Contains data used to animate everything in the engine. 27 28 An Animation resource contains data used to animate everything in the engine. Animations are divided into tracks, and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track. 29 30 31 # This creates an animation that makes the node "Enemy" move to the right by 32 # 100 pixels in 0.5 seconds. 33 var animation = Animation.new() 34 var track_index = animation.add_track(Animation.TYPE_VALUE) 35 animation.track_set_path(track_index, "Enemy:position:x") 36 animation.track_insert_key(track_index, 0.0, 0) 37 animation.track_insert_key(track_index, 0.5, 100) 38 39 40 Animations are just data containers, and must be added to nodes such as an $(D AnimationPlayer) or $(D AnimationTreePlayer) to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check $(D tracktype) to see available types. 41 */ 42 @GodotBaseClass struct Animation 43 { 44 package(godot) enum string _GODOT_internal_name = "Animation"; 45 public: 46 @nogc nothrow: 47 union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; } 48 alias _GODOT_base this; 49 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 50 package(godot) __gshared bool _classBindingInitialized = false; 51 package(godot) static struct GDNativeClassBinding 52 { 53 __gshared: 54 @GodotName("add_track") GodotMethod!(long, long, long) addTrack; 55 @GodotName("animation_track_get_key_animation") GodotMethod!(String, long, long) animationTrackGetKeyAnimation; 56 @GodotName("animation_track_insert_key") GodotMethod!(long, long, double, String) animationTrackInsertKey; 57 @GodotName("animation_track_set_key_animation") GodotMethod!(void, long, long, String) animationTrackSetKeyAnimation; 58 @GodotName("audio_track_get_key_end_offset") GodotMethod!(double, long, long) audioTrackGetKeyEndOffset; 59 @GodotName("audio_track_get_key_start_offset") GodotMethod!(double, long, long) audioTrackGetKeyStartOffset; 60 @GodotName("audio_track_get_key_stream") GodotMethod!(Resource, long, long) audioTrackGetKeyStream; 61 @GodotName("audio_track_insert_key") GodotMethod!(long, long, double, Resource, double, double) audioTrackInsertKey; 62 @GodotName("audio_track_set_key_end_offset") GodotMethod!(void, long, long, double) audioTrackSetKeyEndOffset; 63 @GodotName("audio_track_set_key_start_offset") GodotMethod!(void, long, long, double) audioTrackSetKeyStartOffset; 64 @GodotName("audio_track_set_key_stream") GodotMethod!(void, long, long, Resource) audioTrackSetKeyStream; 65 @GodotName("bezier_track_get_key_in_handle") GodotMethod!(Vector2, long, long) bezierTrackGetKeyInHandle; 66 @GodotName("bezier_track_get_key_out_handle") GodotMethod!(Vector2, long, long) bezierTrackGetKeyOutHandle; 67 @GodotName("bezier_track_get_key_value") GodotMethod!(double, long, long) bezierTrackGetKeyValue; 68 @GodotName("bezier_track_insert_key") GodotMethod!(long, long, double, double, Vector2, Vector2) bezierTrackInsertKey; 69 @GodotName("bezier_track_interpolate") GodotMethod!(double, long, double) bezierTrackInterpolate; 70 @GodotName("bezier_track_set_key_in_handle") GodotMethod!(void, long, long, Vector2) bezierTrackSetKeyInHandle; 71 @GodotName("bezier_track_set_key_out_handle") GodotMethod!(void, long, long, Vector2) bezierTrackSetKeyOutHandle; 72 @GodotName("bezier_track_set_key_value") GodotMethod!(void, long, long, double) bezierTrackSetKeyValue; 73 @GodotName("clear") GodotMethod!(void) clear; 74 @GodotName("copy_track") GodotMethod!(void, long, Animation) copyTrack; 75 @GodotName("find_track") GodotMethod!(long, NodePath) findTrack; 76 @GodotName("get_length") GodotMethod!(double) getLength; 77 @GodotName("get_step") GodotMethod!(double) getStep; 78 @GodotName("get_track_count") GodotMethod!(long) getTrackCount; 79 @GodotName("has_loop") GodotMethod!(bool) hasLoop; 80 @GodotName("method_track_get_key_indices") GodotMethod!(PoolIntArray, long, double, double) methodTrackGetKeyIndices; 81 @GodotName("method_track_get_name") GodotMethod!(String, long, long) methodTrackGetName; 82 @GodotName("method_track_get_params") GodotMethod!(Array, long, long) methodTrackGetParams; 83 @GodotName("remove_track") GodotMethod!(void, long) removeTrack; 84 @GodotName("set_length") GodotMethod!(void, double) setLength; 85 @GodotName("set_loop") GodotMethod!(void, bool) setLoop; 86 @GodotName("set_step") GodotMethod!(void, double) setStep; 87 @GodotName("track_find_key") GodotMethod!(long, long, double, bool) trackFindKey; 88 @GodotName("track_get_interpolation_loop_wrap") GodotMethod!(bool, long) trackGetInterpolationLoopWrap; 89 @GodotName("track_get_interpolation_type") GodotMethod!(Animation.InterpolationType, long) trackGetInterpolationType; 90 @GodotName("track_get_key_count") GodotMethod!(long, long) trackGetKeyCount; 91 @GodotName("track_get_key_time") GodotMethod!(double, long, long) trackGetKeyTime; 92 @GodotName("track_get_key_transition") GodotMethod!(double, long, long) trackGetKeyTransition; 93 @GodotName("track_get_key_value") GodotMethod!(Variant, long, long) trackGetKeyValue; 94 @GodotName("track_get_path") GodotMethod!(NodePath, long) trackGetPath; 95 @GodotName("track_get_type") GodotMethod!(Animation.TrackType, long) trackGetType; 96 @GodotName("track_insert_key") GodotMethod!(void, long, double, Variant, double) trackInsertKey; 97 @GodotName("track_is_enabled") GodotMethod!(bool, long) trackIsEnabled; 98 @GodotName("track_is_imported") GodotMethod!(bool, long) trackIsImported; 99 @GodotName("track_move_down") GodotMethod!(void, long) trackMoveDown; 100 @GodotName("track_move_to") GodotMethod!(void, long, long) trackMoveTo; 101 @GodotName("track_move_up") GodotMethod!(void, long) trackMoveUp; 102 @GodotName("track_remove_key") GodotMethod!(void, long, long) trackRemoveKey; 103 @GodotName("track_remove_key_at_position") GodotMethod!(void, long, double) trackRemoveKeyAtPosition; 104 @GodotName("track_set_enabled") GodotMethod!(void, long, bool) trackSetEnabled; 105 @GodotName("track_set_imported") GodotMethod!(void, long, bool) trackSetImported; 106 @GodotName("track_set_interpolation_loop_wrap") GodotMethod!(void, long, bool) trackSetInterpolationLoopWrap; 107 @GodotName("track_set_interpolation_type") GodotMethod!(void, long, long) trackSetInterpolationType; 108 @GodotName("track_set_key_time") GodotMethod!(void, long, long, double) trackSetKeyTime; 109 @GodotName("track_set_key_transition") GodotMethod!(void, long, long, double) trackSetKeyTransition; 110 @GodotName("track_set_key_value") GodotMethod!(void, long, long, Variant) trackSetKeyValue; 111 @GodotName("track_set_path") GodotMethod!(void, long, NodePath) trackSetPath; 112 @GodotName("track_swap") GodotMethod!(void, long, long) trackSwap; 113 @GodotName("transform_track_insert_key") GodotMethod!(long, long, double, Vector3, Quat, Vector3) transformTrackInsertKey; 114 @GodotName("transform_track_interpolate") GodotMethod!(Array, long, double) transformTrackInterpolate; 115 @GodotName("value_track_get_key_indices") GodotMethod!(PoolIntArray, long, double, double) valueTrackGetKeyIndices; 116 @GodotName("value_track_get_update_mode") GodotMethod!(Animation.UpdateMode, long) valueTrackGetUpdateMode; 117 @GodotName("value_track_interpolate") GodotMethod!(Variant, long, double) valueTrackInterpolate; 118 @GodotName("value_track_set_update_mode") GodotMethod!(void, long, long) valueTrackSetUpdateMode; 119 } 120 /// 121 pragma(inline, true) bool opEquals(in Animation other) const 122 { return _godot_object.ptr is other._godot_object.ptr; } 123 /// 124 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 125 { _godot_object.ptr = n; return null; } 126 /// 127 pragma(inline, true) bool opEquals(typeof(null) n) const 128 { return _godot_object.ptr is n; } 129 /// 130 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 131 mixin baseCasts; 132 /// Construct a new instance of Animation. 133 /// Note: use `memnew!Animation` instead. 134 static Animation _new() 135 { 136 static godot_class_constructor constructor; 137 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Animation"); 138 if(constructor is null) return typeof(this).init; 139 return cast(Animation)(constructor()); 140 } 141 @disable new(size_t s); 142 /// 143 enum TrackType : int 144 { 145 /** 146 Value tracks set values in node properties, but only those which can be Interpolated. 147 */ 148 typeValue = 0, 149 /** 150 Transform tracks are used to change node local transforms or skeleton pose bones. Transitions are interpolated. 151 */ 152 typeTransform = 1, 153 /** 154 Method tracks call functions with given arguments per key. 155 */ 156 typeMethod = 2, 157 /** 158 Bezier tracks are used to interpolate a value using custom curves. They can also be used to animate sub-properties of vectors and colors (e.g. alpha value of a $(D Color)). 159 */ 160 typeBezier = 3, 161 /** 162 Audio tracks are used to play an audio stream with either type of $(D AudioStreamPlayer). The stream can be trimmed and previewed in the animation. 163 */ 164 typeAudio = 4, 165 /** 166 Animation tracks play animations in other $(D AnimationPlayer) nodes. 167 */ 168 typeAnimation = 5, 169 } 170 /// 171 enum UpdateMode : int 172 { 173 /** 174 Update between keyframes. 175 */ 176 updateContinuous = 0, 177 /** 178 Update at the keyframes and hold the value. 179 */ 180 updateDiscrete = 1, 181 /** 182 Update at the keyframes. 183 */ 184 updateTrigger = 2, 185 /** 186 Same as linear interpolation, but also interpolates from the current value (i.e. dynamically at runtime) if the first key isn't at 0 seconds. 187 */ 188 updateCapture = 3, 189 } 190 /// 191 enum InterpolationType : int 192 { 193 /** 194 No interpolation (nearest value). 195 */ 196 interpolationNearest = 0, 197 /** 198 Linear interpolation. 199 */ 200 interpolationLinear = 1, 201 /** 202 Cubic interpolation. 203 */ 204 interpolationCubic = 2, 205 } 206 /// 207 enum Constants : int 208 { 209 typeValue = 0, 210 interpolationNearest = 0, 211 updateContinuous = 0, 212 interpolationLinear = 1, 213 updateDiscrete = 1, 214 typeTransform = 1, 215 updateTrigger = 2, 216 interpolationCubic = 2, 217 typeMethod = 2, 218 typeBezier = 3, 219 updateCapture = 3, 220 typeAudio = 4, 221 typeAnimation = 5, 222 } 223 /** 224 Adds a track to the Animation. 225 */ 226 long addTrack(in long type, in long at_position = -1) 227 { 228 checkClassBinding!(typeof(this))(); 229 return ptrcall!(long)(GDNativeClassBinding.addTrack, _godot_object, type, at_position); 230 } 231 /** 232 Returns the animation name at the key identified by `key_idx`. The `track_idx` must be the index of an Animation Track. 233 */ 234 String animationTrackGetKeyAnimation(in long track_idx, in long key_idx) const 235 { 236 checkClassBinding!(typeof(this))(); 237 return ptrcall!(String)(GDNativeClassBinding.animationTrackGetKeyAnimation, _godot_object, track_idx, key_idx); 238 } 239 /** 240 Inserts a key with value `animation` at the given `time` (in seconds). The `track_idx` must be the index of an Animation Track. 241 */ 242 long animationTrackInsertKey(in long track_idx, in double time, in String animation) 243 { 244 checkClassBinding!(typeof(this))(); 245 return ptrcall!(long)(GDNativeClassBinding.animationTrackInsertKey, _godot_object, track_idx, time, animation); 246 } 247 /** 248 Sets the key identified by `key_idx` to value `animation`. The `track_idx` must be the index of an Animation Track. 249 */ 250 void animationTrackSetKeyAnimation(in long track_idx, in long key_idx, in String animation) 251 { 252 checkClassBinding!(typeof(this))(); 253 ptrcall!(void)(GDNativeClassBinding.animationTrackSetKeyAnimation, _godot_object, track_idx, key_idx, animation); 254 } 255 /** 256 Returns the end offset of the key identified by `key_idx`. The `track_idx` must be the index of an Audio Track. 257 End offset is the number of seconds cut off at the ending of the audio stream. 258 */ 259 double audioTrackGetKeyEndOffset(in long track_idx, in long key_idx) const 260 { 261 checkClassBinding!(typeof(this))(); 262 return ptrcall!(double)(GDNativeClassBinding.audioTrackGetKeyEndOffset, _godot_object, track_idx, key_idx); 263 } 264 /** 265 Returns the start offset of the key identified by `key_idx`. The `track_idx` must be the index of an Audio Track. 266 Start offset is the number of seconds cut off at the beginning of the audio stream. 267 */ 268 double audioTrackGetKeyStartOffset(in long track_idx, in long key_idx) const 269 { 270 checkClassBinding!(typeof(this))(); 271 return ptrcall!(double)(GDNativeClassBinding.audioTrackGetKeyStartOffset, _godot_object, track_idx, key_idx); 272 } 273 /** 274 Returns the audio stream of the key identified by `key_idx`. The `track_idx` must be the index of an Audio Track. 275 */ 276 Ref!Resource audioTrackGetKeyStream(in long track_idx, in long key_idx) const 277 { 278 checkClassBinding!(typeof(this))(); 279 return ptrcall!(Resource)(GDNativeClassBinding.audioTrackGetKeyStream, _godot_object, track_idx, key_idx); 280 } 281 /** 282 Inserts an Audio Track key at the given `time` in seconds. The `track_idx` must be the index of an Audio Track. 283 `stream` is the $(D AudioStream) resource to play. `start_offset` is the number of seconds cut off at the beginning of the audio stream, while `end_offset` is at the ending. 284 */ 285 long audioTrackInsertKey(in long track_idx, in double time, Resource stream, in double start_offset = 0, in double end_offset = 0) 286 { 287 checkClassBinding!(typeof(this))(); 288 return ptrcall!(long)(GDNativeClassBinding.audioTrackInsertKey, _godot_object, track_idx, time, stream, start_offset, end_offset); 289 } 290 /** 291 Sets the end offset of the key identified by `key_idx` to value `offset`. The `track_idx` must be the index of an Audio Track. 292 */ 293 void audioTrackSetKeyEndOffset(in long track_idx, in long key_idx, in double offset) 294 { 295 checkClassBinding!(typeof(this))(); 296 ptrcall!(void)(GDNativeClassBinding.audioTrackSetKeyEndOffset, _godot_object, track_idx, key_idx, offset); 297 } 298 /** 299 Sets the start offset of the key identified by `key_idx` to value `offset`. The `track_idx` must be the index of an Audio Track. 300 */ 301 void audioTrackSetKeyStartOffset(in long track_idx, in long key_idx, in double offset) 302 { 303 checkClassBinding!(typeof(this))(); 304 ptrcall!(void)(GDNativeClassBinding.audioTrackSetKeyStartOffset, _godot_object, track_idx, key_idx, offset); 305 } 306 /** 307 Sets the stream of the key identified by `key_idx` to value `stream`. The `track_idx` must be the index of an Audio Track. 308 */ 309 void audioTrackSetKeyStream(in long track_idx, in long key_idx, Resource stream) 310 { 311 checkClassBinding!(typeof(this))(); 312 ptrcall!(void)(GDNativeClassBinding.audioTrackSetKeyStream, _godot_object, track_idx, key_idx, stream); 313 } 314 /** 315 Returns the in handle of the key identified by `key_idx`. The `track_idx` must be the index of a Bezier Track. 316 */ 317 Vector2 bezierTrackGetKeyInHandle(in long track_idx, in long key_idx) const 318 { 319 checkClassBinding!(typeof(this))(); 320 return ptrcall!(Vector2)(GDNativeClassBinding.bezierTrackGetKeyInHandle, _godot_object, track_idx, key_idx); 321 } 322 /** 323 Returns the out handle of the key identified by `key_idx`. The `track_idx` must be the index of a Bezier Track. 324 */ 325 Vector2 bezierTrackGetKeyOutHandle(in long track_idx, in long key_idx) const 326 { 327 checkClassBinding!(typeof(this))(); 328 return ptrcall!(Vector2)(GDNativeClassBinding.bezierTrackGetKeyOutHandle, _godot_object, track_idx, key_idx); 329 } 330 /** 331 Returns the value of the key identified by `key_idx`. The `track_idx` must be the index of a Bezier Track. 332 */ 333 double bezierTrackGetKeyValue(in long track_idx, in long key_idx) const 334 { 335 checkClassBinding!(typeof(this))(); 336 return ptrcall!(double)(GDNativeClassBinding.bezierTrackGetKeyValue, _godot_object, track_idx, key_idx); 337 } 338 /** 339 Inserts a Bezier Track key at the given `time` in seconds. The `track_idx` must be the index of a Bezier Track. 340 `in_handle` is the left-side weight of the added Bezier curve point, `out_handle` is the right-side one, while `value` is the actual value at this point. 341 */ 342 long bezierTrackInsertKey(in long track_idx, in double time, in double value, in Vector2 in_handle = Vector2(0, 0), in Vector2 out_handle = Vector2(0, 0)) 343 { 344 checkClassBinding!(typeof(this))(); 345 return ptrcall!(long)(GDNativeClassBinding.bezierTrackInsertKey, _godot_object, track_idx, time, value, in_handle, out_handle); 346 } 347 /** 348 Returns the interpolated value at the given `time` (in seconds). The `track_idx` must be the index of a Bezier Track. 349 */ 350 double bezierTrackInterpolate(in long track_idx, in double time) const 351 { 352 checkClassBinding!(typeof(this))(); 353 return ptrcall!(double)(GDNativeClassBinding.bezierTrackInterpolate, _godot_object, track_idx, time); 354 } 355 /** 356 Sets the in handle of the key identified by `key_idx` to value `in_handle`. The `track_idx` must be the index of a Bezier Track. 357 */ 358 void bezierTrackSetKeyInHandle(in long track_idx, in long key_idx, in Vector2 in_handle) 359 { 360 checkClassBinding!(typeof(this))(); 361 ptrcall!(void)(GDNativeClassBinding.bezierTrackSetKeyInHandle, _godot_object, track_idx, key_idx, in_handle); 362 } 363 /** 364 Sets the out handle of the key identified by `key_idx` to value `out_handle`. The `track_idx` must be the index of a Bezier Track. 365 */ 366 void bezierTrackSetKeyOutHandle(in long track_idx, in long key_idx, in Vector2 out_handle) 367 { 368 checkClassBinding!(typeof(this))(); 369 ptrcall!(void)(GDNativeClassBinding.bezierTrackSetKeyOutHandle, _godot_object, track_idx, key_idx, out_handle); 370 } 371 /** 372 Sets the value of the key identified by `key_idx` to the given value. The `track_idx` must be the index of a Bezier Track. 373 */ 374 void bezierTrackSetKeyValue(in long track_idx, in long key_idx, in double value) 375 { 376 checkClassBinding!(typeof(this))(); 377 ptrcall!(void)(GDNativeClassBinding.bezierTrackSetKeyValue, _godot_object, track_idx, key_idx, value); 378 } 379 /** 380 Clear the animation (clear all tracks and reset all). 381 */ 382 void clear() 383 { 384 checkClassBinding!(typeof(this))(); 385 ptrcall!(void)(GDNativeClassBinding.clear, _godot_object); 386 } 387 /** 388 Adds a new track that is a copy of the given track from `to_animation`. 389 */ 390 void copyTrack(in long track_idx, Animation to_animation) 391 { 392 checkClassBinding!(typeof(this))(); 393 ptrcall!(void)(GDNativeClassBinding.copyTrack, _godot_object, track_idx, to_animation); 394 } 395 /** 396 Returns the index of the specified track. If the track is not found, return -1. 397 */ 398 long findTrack(NodePathArg0)(in NodePathArg0 path) const 399 { 400 checkClassBinding!(typeof(this))(); 401 return ptrcall!(long)(GDNativeClassBinding.findTrack, _godot_object, path); 402 } 403 /** 404 405 */ 406 double getLength() const 407 { 408 checkClassBinding!(typeof(this))(); 409 return ptrcall!(double)(GDNativeClassBinding.getLength, _godot_object); 410 } 411 /** 412 413 */ 414 double getStep() const 415 { 416 checkClassBinding!(typeof(this))(); 417 return ptrcall!(double)(GDNativeClassBinding.getStep, _godot_object); 418 } 419 /** 420 Returns the amount of tracks in the animation. 421 */ 422 long getTrackCount() const 423 { 424 checkClassBinding!(typeof(this))(); 425 return ptrcall!(long)(GDNativeClassBinding.getTrackCount, _godot_object); 426 } 427 /** 428 429 */ 430 bool hasLoop() const 431 { 432 checkClassBinding!(typeof(this))(); 433 return ptrcall!(bool)(GDNativeClassBinding.hasLoop, _godot_object); 434 } 435 /** 436 Returns all the key indices of a method track, given a position and delta time. 437 */ 438 PoolIntArray methodTrackGetKeyIndices(in long track_idx, in double time_sec, in double delta) const 439 { 440 checkClassBinding!(typeof(this))(); 441 return ptrcall!(PoolIntArray)(GDNativeClassBinding.methodTrackGetKeyIndices, _godot_object, track_idx, time_sec, delta); 442 } 443 /** 444 Returns the method name of a method track. 445 */ 446 String methodTrackGetName(in long track_idx, in long key_idx) const 447 { 448 checkClassBinding!(typeof(this))(); 449 return ptrcall!(String)(GDNativeClassBinding.methodTrackGetName, _godot_object, track_idx, key_idx); 450 } 451 /** 452 Returns the arguments values to be called on a method track for a given key in a given track. 453 */ 454 Array methodTrackGetParams(in long track_idx, in long key_idx) const 455 { 456 checkClassBinding!(typeof(this))(); 457 return ptrcall!(Array)(GDNativeClassBinding.methodTrackGetParams, _godot_object, track_idx, key_idx); 458 } 459 /** 460 Removes a track by specifying the track index. 461 */ 462 void removeTrack(in long track_idx) 463 { 464 checkClassBinding!(typeof(this))(); 465 ptrcall!(void)(GDNativeClassBinding.removeTrack, _godot_object, track_idx); 466 } 467 /** 468 469 */ 470 void setLength(in double time_sec) 471 { 472 checkClassBinding!(typeof(this))(); 473 ptrcall!(void)(GDNativeClassBinding.setLength, _godot_object, time_sec); 474 } 475 /** 476 477 */ 478 void setLoop(in bool enabled) 479 { 480 checkClassBinding!(typeof(this))(); 481 ptrcall!(void)(GDNativeClassBinding.setLoop, _godot_object, enabled); 482 } 483 /** 484 485 */ 486 void setStep(in double size_sec) 487 { 488 checkClassBinding!(typeof(this))(); 489 ptrcall!(void)(GDNativeClassBinding.setStep, _godot_object, size_sec); 490 } 491 /** 492 Finds the key index by time in a given track. Optionally, only find it if the exact time is given. 493 */ 494 long trackFindKey(in long track_idx, in double time, in bool exact = false) const 495 { 496 checkClassBinding!(typeof(this))(); 497 return ptrcall!(long)(GDNativeClassBinding.trackFindKey, _godot_object, track_idx, time, exact); 498 } 499 /** 500 Returns `true` if the track at `idx` wraps the interpolation loop. New tracks wrap the interpolation loop by default. 501 */ 502 bool trackGetInterpolationLoopWrap(in long track_idx) const 503 { 504 checkClassBinding!(typeof(this))(); 505 return ptrcall!(bool)(GDNativeClassBinding.trackGetInterpolationLoopWrap, _godot_object, track_idx); 506 } 507 /** 508 Returns the interpolation type of a given track. 509 */ 510 Animation.InterpolationType trackGetInterpolationType(in long track_idx) const 511 { 512 checkClassBinding!(typeof(this))(); 513 return ptrcall!(Animation.InterpolationType)(GDNativeClassBinding.trackGetInterpolationType, _godot_object, track_idx); 514 } 515 /** 516 Returns the amount of keys in a given track. 517 */ 518 long trackGetKeyCount(in long track_idx) const 519 { 520 checkClassBinding!(typeof(this))(); 521 return ptrcall!(long)(GDNativeClassBinding.trackGetKeyCount, _godot_object, track_idx); 522 } 523 /** 524 Returns the time at which the key is located. 525 */ 526 double trackGetKeyTime(in long track_idx, in long key_idx) const 527 { 528 checkClassBinding!(typeof(this))(); 529 return ptrcall!(double)(GDNativeClassBinding.trackGetKeyTime, _godot_object, track_idx, key_idx); 530 } 531 /** 532 Returns the transition curve (easing) for a specific key (see the built-in math function $(D @GDScript.ease)). 533 */ 534 double trackGetKeyTransition(in long track_idx, in long key_idx) const 535 { 536 checkClassBinding!(typeof(this))(); 537 return ptrcall!(double)(GDNativeClassBinding.trackGetKeyTransition, _godot_object, track_idx, key_idx); 538 } 539 /** 540 Returns the value of a given key in a given track. 541 */ 542 Variant trackGetKeyValue(in long track_idx, in long key_idx) const 543 { 544 checkClassBinding!(typeof(this))(); 545 return ptrcall!(Variant)(GDNativeClassBinding.trackGetKeyValue, _godot_object, track_idx, key_idx); 546 } 547 /** 548 Gets the path of a track. For more information on the path format, see $(D trackSetPath). 549 */ 550 NodePath trackGetPath(in long track_idx) const 551 { 552 checkClassBinding!(typeof(this))(); 553 return ptrcall!(NodePath)(GDNativeClassBinding.trackGetPath, _godot_object, track_idx); 554 } 555 /** 556 Gets the type of a track. 557 */ 558 Animation.TrackType trackGetType(in long track_idx) const 559 { 560 checkClassBinding!(typeof(this))(); 561 return ptrcall!(Animation.TrackType)(GDNativeClassBinding.trackGetType, _godot_object, track_idx); 562 } 563 /** 564 Insert a generic key in a given track. 565 */ 566 void trackInsertKey(VariantArg2)(in long track_idx, in double time, in VariantArg2 key, in double transition = 1) 567 { 568 checkClassBinding!(typeof(this))(); 569 ptrcall!(void)(GDNativeClassBinding.trackInsertKey, _godot_object, track_idx, time, key, transition); 570 } 571 /** 572 Returns `true` if the track at index `idx` is enabled. 573 */ 574 bool trackIsEnabled(in long track_idx) const 575 { 576 checkClassBinding!(typeof(this))(); 577 return ptrcall!(bool)(GDNativeClassBinding.trackIsEnabled, _godot_object, track_idx); 578 } 579 /** 580 Returns `true` if the given track is imported. Else, return `false`. 581 */ 582 bool trackIsImported(in long track_idx) const 583 { 584 checkClassBinding!(typeof(this))(); 585 return ptrcall!(bool)(GDNativeClassBinding.trackIsImported, _godot_object, track_idx); 586 } 587 /** 588 Moves a track down. 589 */ 590 void trackMoveDown(in long track_idx) 591 { 592 checkClassBinding!(typeof(this))(); 593 ptrcall!(void)(GDNativeClassBinding.trackMoveDown, _godot_object, track_idx); 594 } 595 /** 596 Changes the index position of track `idx` to the one defined in `to_idx`. 597 */ 598 void trackMoveTo(in long track_idx, in long to_idx) 599 { 600 checkClassBinding!(typeof(this))(); 601 ptrcall!(void)(GDNativeClassBinding.trackMoveTo, _godot_object, track_idx, to_idx); 602 } 603 /** 604 Moves a track up. 605 */ 606 void trackMoveUp(in long track_idx) 607 { 608 checkClassBinding!(typeof(this))(); 609 ptrcall!(void)(GDNativeClassBinding.trackMoveUp, _godot_object, track_idx); 610 } 611 /** 612 Removes a key by index in a given track. 613 */ 614 void trackRemoveKey(in long track_idx, in long key_idx) 615 { 616 checkClassBinding!(typeof(this))(); 617 ptrcall!(void)(GDNativeClassBinding.trackRemoveKey, _godot_object, track_idx, key_idx); 618 } 619 /** 620 Removes a key by position (seconds) in a given track. 621 */ 622 void trackRemoveKeyAtPosition(in long track_idx, in double position) 623 { 624 checkClassBinding!(typeof(this))(); 625 ptrcall!(void)(GDNativeClassBinding.trackRemoveKeyAtPosition, _godot_object, track_idx, position); 626 } 627 /** 628 Enables/disables the given track. Tracks are enabled by default. 629 */ 630 void trackSetEnabled(in long track_idx, in bool enabled) 631 { 632 checkClassBinding!(typeof(this))(); 633 ptrcall!(void)(GDNativeClassBinding.trackSetEnabled, _godot_object, track_idx, enabled); 634 } 635 /** 636 Sets the given track as imported or not. 637 */ 638 void trackSetImported(in long track_idx, in bool imported) 639 { 640 checkClassBinding!(typeof(this))(); 641 ptrcall!(void)(GDNativeClassBinding.trackSetImported, _godot_object, track_idx, imported); 642 } 643 /** 644 If `true`, the track at `idx` wraps the interpolation loop. 645 */ 646 void trackSetInterpolationLoopWrap(in long track_idx, in bool interpolation) 647 { 648 checkClassBinding!(typeof(this))(); 649 ptrcall!(void)(GDNativeClassBinding.trackSetInterpolationLoopWrap, _godot_object, track_idx, interpolation); 650 } 651 /** 652 Sets the interpolation type of a given track. 653 */ 654 void trackSetInterpolationType(in long track_idx, in long interpolation) 655 { 656 checkClassBinding!(typeof(this))(); 657 ptrcall!(void)(GDNativeClassBinding.trackSetInterpolationType, _godot_object, track_idx, interpolation); 658 } 659 /** 660 Sets the time of an existing key. 661 */ 662 void trackSetKeyTime(in long track_idx, in long key_idx, in double time) 663 { 664 checkClassBinding!(typeof(this))(); 665 ptrcall!(void)(GDNativeClassBinding.trackSetKeyTime, _godot_object, track_idx, key_idx, time); 666 } 667 /** 668 Sets the transition curve (easing) for a specific key (see the built-in math function $(D @GDScript.ease)). 669 */ 670 void trackSetKeyTransition(in long track_idx, in long key_idx, in double transition) 671 { 672 checkClassBinding!(typeof(this))(); 673 ptrcall!(void)(GDNativeClassBinding.trackSetKeyTransition, _godot_object, track_idx, key_idx, transition); 674 } 675 /** 676 Sets the value of an existing key. 677 */ 678 void trackSetKeyValue(VariantArg2)(in long track_idx, in long key, in VariantArg2 value) 679 { 680 checkClassBinding!(typeof(this))(); 681 ptrcall!(void)(GDNativeClassBinding.trackSetKeyValue, _godot_object, track_idx, key, value); 682 } 683 /** 684 Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by `":"`. 685 For example, `"character/skeleton:ankle"` or `"character/mesh:transform/local"`. 686 */ 687 void trackSetPath(NodePathArg1)(in long track_idx, in NodePathArg1 path) 688 { 689 checkClassBinding!(typeof(this))(); 690 ptrcall!(void)(GDNativeClassBinding.trackSetPath, _godot_object, track_idx, path); 691 } 692 /** 693 Swaps the track `idx`'s index position with the track `with_idx`. 694 */ 695 void trackSwap(in long track_idx, in long with_idx) 696 { 697 checkClassBinding!(typeof(this))(); 698 ptrcall!(void)(GDNativeClassBinding.trackSwap, _godot_object, track_idx, with_idx); 699 } 700 /** 701 Insert a transform key for a transform track. 702 */ 703 long transformTrackInsertKey(in long track_idx, in double time, in Vector3 location, in Quat rotation, in Vector3 scale) 704 { 705 checkClassBinding!(typeof(this))(); 706 return ptrcall!(long)(GDNativeClassBinding.transformTrackInsertKey, _godot_object, track_idx, time, location, rotation, scale); 707 } 708 /** 709 Returns the interpolated value of a transform track at a given time (in seconds). An array consisting of 3 elements: position ($(D Vector3)), rotation ($(D Quat)) and scale ($(D Vector3)). 710 */ 711 Array transformTrackInterpolate(in long track_idx, in double time_sec) const 712 { 713 checkClassBinding!(typeof(this))(); 714 return ptrcall!(Array)(GDNativeClassBinding.transformTrackInterpolate, _godot_object, track_idx, time_sec); 715 } 716 /** 717 Returns all the key indices of a value track, given a position and delta time. 718 */ 719 PoolIntArray valueTrackGetKeyIndices(in long track_idx, in double time_sec, in double delta) const 720 { 721 checkClassBinding!(typeof(this))(); 722 return ptrcall!(PoolIntArray)(GDNativeClassBinding.valueTrackGetKeyIndices, _godot_object, track_idx, time_sec, delta); 723 } 724 /** 725 Returns the update mode of a value track. 726 */ 727 Animation.UpdateMode valueTrackGetUpdateMode(in long track_idx) const 728 { 729 checkClassBinding!(typeof(this))(); 730 return ptrcall!(Animation.UpdateMode)(GDNativeClassBinding.valueTrackGetUpdateMode, _godot_object, track_idx); 731 } 732 /** 733 Returns the interpolated value at the given time (in seconds). The `track_idx` must be the index of a value track. 734 */ 735 Variant valueTrackInterpolate(in long track_idx, in double time_sec) const 736 { 737 checkClassBinding!(typeof(this))(); 738 return ptrcall!(Variant)(GDNativeClassBinding.valueTrackInterpolate, _godot_object, track_idx, time_sec); 739 } 740 /** 741 Sets the update mode (see $(D updatemode)) of a value track. 742 */ 743 void valueTrackSetUpdateMode(in long track_idx, in long mode) 744 { 745 checkClassBinding!(typeof(this))(); 746 ptrcall!(void)(GDNativeClassBinding.valueTrackSetUpdateMode, _godot_object, track_idx, mode); 747 } 748 /** 749 The total length of the animation (in seconds). 750 $(B Note:) Length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping. 751 */ 752 @property double length() 753 { 754 return getLength(); 755 } 756 /// ditto 757 @property void length(double v) 758 { 759 setLength(v); 760 } 761 /** 762 A flag indicating that the animation must loop. This is used for correct interpolation of animation cycles, and for hinting the player that it must restart the animation. 763 */ 764 @property bool loop() 765 { 766 return hasLoop(); 767 } 768 /// ditto 769 @property void loop(bool v) 770 { 771 setLoop(v); 772 } 773 /** 774 The animation step value. 775 */ 776 @property double step() 777 { 778 return getStep(); 779 } 780 /// ditto 781 @property void step(double v) 782 { 783 setStep(v); 784 } 785 }