/
CreatureMeshComponent.h
executable file
·771 lines (586 loc) · 33.4 KB
/
CreatureMeshComponent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
/******************************************************************************
* Creature Runtimes License
*
* Copyright (c) 2015, Kestrel Moon Studios
* All rights reserved.
*
* Preamble: This Agreement governs the relationship between Licensee and Kestrel Moon Studios(Hereinafter: Licensor).
* This Agreement sets the terms, rights, restrictions and obligations on using [Creature Runtimes] (hereinafter: The Software) created and owned by Licensor,
* as detailed herein:
* License Grant: Licensor hereby grants Licensee a Sublicensable, Non-assignable & non-transferable, Commercial, Royalty free,
* Including the rights to create but not distribute derivative works, Non-exclusive license, all with accordance with the terms set forth and
* other legal restrictions set forth in 3rd party software used while running Software.
* Limited: Licensee may use Software for the purpose of:
* Running Software on Licensee抯 Website[s] and Server[s];
* Allowing 3rd Parties to run Software on Licensee抯 Website[s] and Server[s];
* Publishing Software抯 output to Licensee and 3rd Parties;
* Distribute verbatim copies of Software抯 output (including compiled binaries);
* Modify Software to suit Licensee抯 needs and specifications.
* Binary Restricted: Licensee may sublicense Software as a part of a larger work containing more than Software,
* distributed solely in Object or Binary form under a personal, non-sublicensable, limited license. Such redistribution shall be limited to unlimited codebases.
* Non Assignable & Non-Transferable: Licensee may not assign or transfer his rights and duties under this license.
* Commercial, Royalty Free: Licensee may use Software for any purpose, including paid-services, without any royalties
* Including the Right to Create Derivative Works: Licensee may create derivative works based on Software,
* including amending Software抯 source code, modifying it, integrating it into a larger work or removing portions of Software,
* as long as no distribution of the derivative works is made
*
* THE RUNTIMES IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE RUNTIMES OR THE USE OR OTHER DEALINGS IN THE
* RUNTIMES.
*****************************************************************************/
// This is the Mesh Component version of the Creature Runtime.
#pragma once
#include <vector>
#include "CustomProceduralMeshComponent.h"
#include "PrimitiveSceneProxy.h"
#include "Components/MeshComponent.h"
#include "CreatureAnimationAsset.h"
#include "CreatureMetaAsset.h"
#include "CreatureParticlesAsset.h"
#include "CreatureCore.h"
#include "Async/Future.h"
#include "CreatureMeshComponent.generated.h"
USTRUCT(BlueprintType)
struct FCreatureMeshCollectionToken
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName animation_name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
int32 collection_data_index;
};
USTRUCT(BlueprintType)
struct FCreatureMeshCollectionClip
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName collection_name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
TArray<FCreatureMeshCollectionToken> sequence_clips;
int32 active_index;
bool operator == (const FCreatureMeshCollectionClip& other) const{
return collection_name == other.collection_name;
}
};
USTRUCT(BlueprintType)
struct FCreatureMeshCollection
{
GENERATED_USTRUCT_BODY()
FCreatureMeshCollection() :
animation_speed(1.0f),
collection_material(nullptr),
source_asset(nullptr)
{
}
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName creature_filename;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float animation_speed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
UMaterialInterface * collection_material;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
class UCreatureAnimationAsset *source_asset;
CreatureCore creature_core;
TArray<FProceduralMeshTriangle> ProceduralMeshTris;
//////////////////////////////////////////////////////////////////////////
//Changed By God of Pen
//////////////////////////////////////////////////////////////////////////
bool operator == (const FCreatureMeshCollection& other) const{
return creature_filename == other.creature_filename;
}
};
USTRUCT(BlueprintType)
struct FCreatureBoneOverride {
GENERATED_USTRUCT_BODY()
/** Name of your bone */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName bone_name;
/** Starting position of the bone in world space */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FVector start_pos;
/** Ending position of the bone in world space */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FVector end_pos;
};
USTRUCT(BlueprintType)
struct FCreatureBoneIK {
GENERATED_USTRUCT_BODY()
FCreatureBoneIK()
: target_pos(ForceInitToZero), positive_angle(false), children_ready(false)
{
}
/** First bone name of the IK system */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName first_bone_name;
/** Second bone name of the IK system */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName second_bone_name;
/** Target position of the IK system in world space */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FVector target_pos;
/** Determines whether you are solving for a positive or negative angle IK System */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature",
meta = (MakeStructureDefaultValue = "false"))
bool positive_angle;
TArray<meshBone *> first_bone_children, second_bone_children;
bool children_ready;
};
// Frame/Time Event callback structs
USTRUCT(BlueprintType)
struct FCreatureFrameCallback {
GENERATED_USTRUCT_BODY()
FCreatureFrameCallback()
: frame(0), triggered(false)
{}
void resetCallback()
{
triggered = false;
}
bool tryTrigger(float frameIn)
{
if (triggered)
{
return false;
}
if ((int32)roundf(frameIn) >= frame)
{
triggered = true;
return true;
}
return false;
}
/** Name of callback event*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName name;
/** Name of animation clip to associate this callback with*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName animClipName;
/** Frame to trigger event*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
int32 frame;
bool triggered;
};
USTRUCT(BlueprintType)
struct FCreatureRepeatFrameCallback {
GENERATED_USTRUCT_BODY()
FCreatureRepeatFrameCallback()
: repeatFrames(0), offsetFrame(0), currentFrame(0), triggeredFrame(0), startFrame(0)
{}
void resetCallback(float frameIn)
{
currentFrame = (int32)roundf(frameIn);
startFrame = currentFrame + offsetFrame;
triggeredFrame = currentFrame - 1;
}
bool tryTrigger(float frameIn)
{
currentFrame = (int32)roundf(frameIn);
if (currentFrame - startFrame >= repeatFrames)
{
if (triggeredFrame != currentFrame)
{
startFrame = currentFrame;
triggeredFrame = currentFrame;
return true;
}
return false;
}
return false;
}
/** Name of callback event*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName name;
/** Name of animation clip to associate this callback with*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName animClipName;
/** How many frames pass before the event triggers and repeats itself */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
int32 repeatFrames;
/** When does the repeat event start offset by the specificed number of frames */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
int32 offsetFrame;
int32 currentFrame, triggeredFrame, startFrame;
};
// Blueprint event delegates event declarations
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCreatureMeshAnimationStartEvent, float, frame);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCreatureMeshAnimationEndEvent, float, frame);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCreatureFrameCallbackEvent, FName, name);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCreatureRepeatFrameCallbackEvent, FName, name);
/**
* Tick function that processes the results of the creature core update
**/
USTRUCT(BlueprintType)
struct FCreatureCoreResultTickFunction : public FTickFunction
{
GENERATED_USTRUCT_BODY()
class UCreatureMeshComponent* Target;
/**
* Abstract function to execute the tick.
* @param DeltaTime - frame time to advance, in seconds.
* @param TickType - kind of tick for this frame.
* @param CurrentThread - thread we are executing on, useful to pass along as new tasks are created.
* @param MyCompletionGraphEvent - completion event for this task. Useful for holding the completetion of this task until certain child tasks are complete.
*/
virtual void ExecuteTick(float DeltaTime, enum ELevelTick TickType, ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) override;
/** Abstract function to describe this tick. Used to print messages about illegal cycles in the dependency graph. */
virtual FString DiagnosticMessage() override;
};
template<>
struct TStructOpsTypeTraits<FCreatureCoreResultTickFunction> : public TStructOpsTypeTraitsBase2<FCreatureCoreResultTickFunction>
{
enum
{
WithCopy = false
};
};
/** Component that allows you to specify custom triangle mesh geometry */
//////////////////////////////////////////////////////////////////////////
//Changed by god of pen
//////////////////////////////////////////////////////////////////////////
UCLASS(editinlinenew, meta = (BlueprintSpawnableComponent), ClassGroup=Rendering)
class CREATUREPLUGIN_API UCreatureMeshComponent : public UCustomProceduralMeshComponent //, public IInterface_CollisionDataProvider
{
GENERATED_UCLASS_BODY()
public:
/** Deprecated: Path/Filename to the Creature JSON. Will accept .zip archives, make sure the file is with a .zip extension. Use creature_animation_asset if you can since this is not asset based and might cause extra complications during game packaging. Eventually this attribute will be phased out. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName creature_filename;
/** Points to a Creature Animation Asset containing the JSON filename of the character. Use this instead of creature_filename if you want to use an asset based system. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
UCreatureAnimationAsset * creature_animation_asset;
/** Points to a Creature Meta Asset containing the JSON of the mdata file exported out from Creature. This file contains extra data like animation data for region ordering for example. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
UCreatureMetaAsset * creature_meta_asset;
/** Points to a Creature Particles Asset containing exported Particles authored with the Flow System in Creature*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
UCreatureParticlesAsset * creature_particles_asset;
/** Playback speed of the animation, 2.0 is the default */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float animation_speed;
/** Size of the returned bone data xform, for colliders */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float bone_data_size;
/** Size of the bounding box, used for culling during rendering */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float creature_bounds_scale;
/** Offset of the bounding box, used for culling during rendering */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FVector creature_bounds_offset;
/** Displays the bounding box */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool creature_debug_draw;
/** Displays the bones */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool creature_bones_draw;
/** Size of the returned bone data xform, for colliders */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float bone_data_length_factor;
/** How much each region is offset by z, useful if you are encountering z fighting rendering artifacts */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float region_overlap_z_delta;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool smooth_transitions;
/** Starting animation clip */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
FName start_animation_name;
/** Current frame of the animation during playback */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
float animation_frame;
/** Decides whether this component can use point caching or not */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
bool can_use_point_cache;
/** A collection of Creature JSONs to load when the game starts, you should fill in this information if you want to playback a collection of Creature JSONs as a single animation clip */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
TArray<FCreatureMeshCollection> collectionData;
/** Use this in conjunction with the collectionData property. This defines how the collection of JSONs are played back and in what order they are displayed. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
TArray<FCreatureMeshCollectionClip> collectionClips;
/** This enables/disables collection clip playback */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool enable_collection_playback;
/** A blending factor when you override the position of the bones. A value from 0 to 1.0*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float bones_override_blend_factor;
/** A boolean flag that completely disables tick execution on this component */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool completely_disable;
/** A value that fixes the time to advance per component tick. Fixed timestep is active if fixed_timestep > 0, otherwise the default delta time of the component tick is used. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
float fixed_timestep;
// Decides whether to run parallel processing per whole character. Note this
// is not neccessarily safe to do if you are going to delete this character dynamically.
// It is safe to enable for characters that have more or less constant lifetimes and not deleted.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool run_task_multicore;
/** Activates/Deactivates anchor points in the character if it was setup in the Creature Animation Editor */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components|Creature")
bool use_anchor_points;
/** Event that is triggered when the animation starts */
UPROPERTY(BlueprintAssignable, Category = "Components|Creature")
FCreatureMeshAnimationStartEvent CreatureAnimationStartEvent;
/** Event that is triggered when the animation ends */
UPROPERTY(BlueprintAssignable, Category = "Components|Creature")
FCreatureMeshAnimationEndEvent CreatureAnimationEndEvent;
/** Event that is triggered when custom specific frame callbacks are assigned*/
UPROPERTY(BlueprintAssignable, Category = "Components|Creature")
FCreatureFrameCallbackEvent CreatureFrameCallbackEvent;
/** Event that is repeatedly triggered when custom repeated frame callbacks are assigned */
UPROPERTY(BlueprintAssignable, Category = "Components|Creature")
FCreatureRepeatFrameCallbackEvent CreatureRepeatFrameCallbackEvent;
// Blueprint version of setting the active animation name
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage="Please replace with _Name version of this function to improve performance"))
void SetBluePrintActiveAnimation(FString name_in);
// Blueprint version of setting the active animation name
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintActiveAnimation_Name(FName name_in);
// Blueprint version of setting the blended active animation name
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void SetBluePrintBlendActiveAnimation(FString name_in, float factor);
// Blueprint version of setting the blended active animation name
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintBlendActiveAnimation_Name(FName name_in, float factor);
// Blueprint version of returning the curernt active animation name
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
FName GetBluePrintActiveAnimationName();
// Blueprint version of setting a custom time range for a given animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void SetBluePrintAnimationCustomTimeRange(FString name_in, int32 start_time, int32 end_time);
// Blueprint version of setting a custom time range for a given animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAnimationCustomTimeRange_Name(FName name_in, int32 start_time, int32 end_time);
// Blueprint function that returns the start frame of the animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
int32 GetBluePrintActiveAnimationStartTime(FName name_in);
// Blueprint function that returns the end frame of the animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
int32 GetBluePrintActiveAnimationEndTime(FName name_in);
// Blueprint function to create a point cache for the creature character. This speeds up the playback performance.
// A small amount of time will be spent precomputing the point cache. You can reduce this time by increasing the approximation level.
// name_in is the name of the animation to cache, approximation_level is the approximation level. The higher the approximation level
// the faster the cache generation but lower the quality. 1 means no approximation, with 10 being the maximum value allowed.
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void MakeBluePrintPointCache(FString name_in, int32 approximation_level);
// Blueprint function to create a point cache for the creature character. This speeds up the playback performance.
// A small amount of time will be spent precomputing the point cache. You can reduce this time by increasing the approximation level.
// name_in is the name of the animation to cache, approximation_level is the approximation level. The higher the approximation level
// the faster the cache generation but lower the quality. 1 means no approximation, with 10 being the maximum value allowed.
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void MakeBluePrintPointCache_Name(FName name_in, int32 approximation_level);
// Blueprint function to clear the point cache of a given animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void ClearBluePrintPointCache(FString name_in, int32 approximation_level);
// Blueprint function to clear the point cache of a given animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void ClearBluePrintPointCache_Name(FName name_in, int32 approximation_level);
// Blueprint function to enable/disable the use of all point caching on this mesh
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintUsePointCache(bool flag_in);
// Blueprint function that returns whether this mesh can use point caching or not
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
bool GetBluePrintUsePointCache();
// Blueprint function that returns the transform given a bone name, position_slide_factor
// determines how far left or right the transform is placed. The default value of 0 places it
// in the center of the bone, positve values places it to the right, negative to the left
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
FTransform GetBluePrintBoneXform(FString name_in, bool world_transform, float position_slide_factor);
// Blueprint function that returns the transform given a bone name, position_slide_factor
// determines how far left or right the transform is placed. The default value of 0 places it
// in the center of the bone, positve values places it to the right, negative to the left
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
FTransform GetBluePrintBoneXform_Name(FName name_in, bool world_transform, float position_slide_factor) const;
// Blueprint function that decides whether the animation will loop or not
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAnimationLoop(bool flag_in);
// Blueprint function that returns whether the animation is looping or not
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
bool GetBluePrintAnimationLoop() const;
// Blueprint function that decides whether to play the animation or not
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAnimationPlay(bool flag_in);
// Blueprint function that plays the animation from the start
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAnimationPlayFromStart();
// Blueprint function that resets the animation to the start time
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAnimationResetToStart();
// Blueprint function that returns the current animation frame
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
float GetBluePrintAnimationFrame();
// Blueprint function that set the current animation frame
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAnimationFrame(float time_in);
// Blueprint function that sets the alpha(opacity value) of a region
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void SetBluePrintRegionAlpha(FString region_name_in, uint8 alpha_in);
// Blueprint function that sets the alpha(opacity value) of a region
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintRegionAlpha_Name(FName region_name_in, uint8 alpha_in);
// Blueprint function that removes the custom override alpha(opacity value) of a region
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void RemoveBluePrintRegionAlpha(FString region_name_in);
// Blueprint function that removes the custom override alpha(opacity value) of a region
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void RemoveBluePrintRegionAlpha_Name(FName region_name_in);
// Blueprint function that sets up a custom z order for the various regions
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void SetBluePrintRegionCustomOrder(TArray<FString> order_in);
// Blueprint function that sets up a custom z order for the various regions
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintRegionCustomOrder_Name(TArray<FName> order_in);
// Blueprint function that clears the custom z order for the various regions
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void ClearBluePrintRegionCustomOrder();
// Blueprint function that turns on/turns off internal updates of this object
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetIsDisabled(bool flag_in);
// Blueprint function that sets the active collection clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void SetBluePrintRegionItemSwap(FString region_name_in, int32 tag);
// Blueprint function that sets the active collection clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintRegionItemSwap_Name(FName region_name_in, int32 tag);
// Blueprint function that sets the active collection clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void RemoveBluePrintRegionItemSwap(FString region_name_in);
// Blueprint function that sets the active collection clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void RemoveBluePrintRegionItemSwap_Name(FName region_name_in);
// Blueprint function that sets the active collection clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature", meta=(DeprecatedFunction, DeprecationMessage = "Please replace with _Name version of this function to improve performance"))
void SetBluePrintActiveCollectionClip(FString name_in);
// Blueprint function that sets the active collection clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintActiveCollectionClip_Name(FName name_in);
// Blueprint function that activates/deactivates the usage of anchor points exported into the asset. If active, the character will be translated relative to the anchor point defined for it.
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintUseAnchorPoints(bool flag_in);
// Blueprint function that returns whether anchor points are active for the character
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
bool GetBluePrintUseAnchorPoints() const;
// Blueprint function that sets the list of bones you want to override positions for
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintBonesOverride(const TArray<FCreatureBoneOverride>& bones_list_in);
// Blueprint function that clears the list of bones you want to override positions for
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void ClearBluePrintBonesOverride();
// Sets a 2 bone IK constraint
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintBonesIKConstraint(FCreatureBoneIK ik_data_in);
// Removes a 2 bone IK constraint
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void RemoveBluePrintBonesIKConstraint(FCreatureBoneIK ik_data_in);
// Blueprint function that sets the custom frame callbacks
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintFrameCallbacks(const TArray<FCreatureFrameCallback>& callbacks_in);
// Blueprint function that clears the list of custom frame callbacks
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void ClearBluePrintFrameCallbacks();
// Blueprint function to load custom frame callbacks from the meta asset file authored from the Creature Editor
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void LoadBlueprintFramCallBacksAsset();
// Blueprint function that sets the custom repeated frame callbacks
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintRepeatFrameCallbacks(const TArray<FCreatureRepeatFrameCallback>& callbacks_in);
// Blueprint function that clears the list of custom repeated frame callbacks
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void ClearBluePrintRepeatFrameCallbacks();
// Frees up some memory associated with loading of ALL Creature JSONs. Any loading of additional characters after this call will force a re-parsing of the JSON data. Use this function to free up memory when characters have all been instantiated on the level.
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void FreeBluePrintJSONMemory();
// Blueprint function that allows the character to tick regardless of whether the main thread is active or not
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetBluePrintAlwaysTick(bool flag_in);
// Create live bend physics motors from animation clip
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void CreateBluePrintBendPhysics(FString anim_clip);
// Enable Skin Swap for a particular Skin Swap Name
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void EnableSkinSwap(FString swap_name);
// Turns off Skin Swapping
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void DisableSkinSwap();
// Adds a new Skin Swap
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void AddSkinSwap(FString new_swap_name, TArray<FString> new_swap);
// Enables Region Color Animation
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void EnableRegionColors();
// Enables/Disables Morph Targets defined in the MetaData Asset
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetMorphTargetsActive(bool flag_in);
// Sets the Morph Targets world space point with a reference base pt
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
void SetMorphTargetsWorldPt(FVector pt_in, FVector base_pt, float radius=1.0f, bool z_up=true);
// Returns the world space point of a vertex attachment given its name
UFUNCTION(BlueprintCallable, Category = "Components|Creature")
FVector GetVertexAttachment(FString name_in);
CreatureCore& GetCore();
virtual bool ShouldSkipTick() const;
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
virtual void OnRegister() override;
virtual void RegisterComponentTickFunctions(bool bRegister) override;
void RegisterCoreResultsTickFunction(bool bRegister);
virtual void InitializeComponent() override;
virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
//////////////////////////////////////////////////////////////////////////
///ChangedBy God Of Pen
///存储一系列Clip的数据结构
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Components|Creature")
class UCreatureAnimationClipsStore* ClipStore;
virtual void BeginPlay() override;
UPROPERTY(EditAnywhere, Category = "Components|Creature")
class UCreatureAnimStateMachine* StateMachineAsset;
UPROPERTY(Transient, BlueprintReadOnly, Category = "Components|Creature")
class UCreatureAnimStateMachineInstance* StateMachineInstance;
//////////////////////////////////////////////////////////////////////////
protected:
CreatureCore creature_core;
FName active_collection_clip_name;
FCreatureMeshCollectionClip * active_collection_clip;
bool active_collection_loop;
bool active_collection_play;
TArray<FCreatureBoneOverride> bones_override_list, final_bones_override_list;
TMap<FName, FCreatureBoneIK> internal_ik_map;
TMap<FName, std::pair<glm::vec4, glm::vec4> > internal_ik_bone_pts;
TArray<FCreatureFrameCallback> frame_callbacks;
TArray<FCreatureRepeatFrameCallback> repeat_frame_callbacks;
TSharedPtr<CreaturePhysicsData> physics_data;
FString delay_bendphysics_clip;
void InitStandardValues();
void UpdateCoreValues();
void PrepareRenderData(CreatureCore &forCore);
void RunTick(float DeltaTime);
void RunCollectionTick(float DeltaTime);
void FireStartEndEvents();
bool RunTickProcessing(float DeltaTime, bool markDirty);
/** Update systems */
void ProcessCreatureCoreResult(FCreatureCoreResultTickFunction& ThisTickFunction);
void StandardInit();
void CollectionInit();
void SwitchToCollectionClip(FCreatureMeshCollectionClip * clip_in);
virtual void SetActiveCollectionAnimation(FCreatureMeshCollectionClip * clip_in);
FCreatureMeshCollection *
GetCollectionDataFromClip(FCreatureMeshCollectionClip * clip_in);
int GetCollectionDataIndexFromClip(FCreatureMeshCollectionClip * clip_in);
void DoCreatureMeshUpdate(int render_packet_idx = -1, bool markDirty = true);
void CoreBonesOverride(TMap<FName, meshBone *>& bones_map);
FName GetIkKey(const FName& start_bone_name, const FName& end_bone_name) const;
void
ComputeBonesIK(
const FName& start_bone_name,
const FName& end_bone_name,
TArray<FCreatureBoneOverride>& mod_list);
void ResetFrameCallbacks();
void ProcessFrameCallbacks();
void LoadAnimationFromStore();
void TryCreateBendPhysics();
void TryEnableParticles();
// future used for async creature processing
TFuture<bool> creatureTickResult;
FCreatureCoreResultTickFunction EndPhysicsTickFunction;
friend struct FCreatureCoreResultTickFunction;
};