2 #ifndef KJY_ANIM_ENGINE_GLTF_SCENE_POPULATOR_HPP_ 3 #define KJY_ANIM_ENGINE_GLTF_SCENE_POPULATOR_HPP_ 5 #include "GltfCommon.h" 6 #include "world/Entities/TypicalEntities.inl" 7 #include <world/Scene.hpp> 14 int original_index = -1;
29 std::vector<GltfPoseKeyframeSequence> channels;
30 bool start_enabled =
true;
31 bool should_loop =
false;
46 void addExtension(
ExtrasExtension* aExtension) {mExtensions.push_back(aExtension);}
48 static bool node_has_pose(
const tinygltf::Node& node);
49 static Pose get_node_pose(
const tinygltf::Node& node);
51 const std::map<int, Entity*>& getGltfnodesToEntites()
const {
return(gltfnodes_to_entites);}
52 const std::map<int, MeshEntity*>& getGltfmeshToMeshes()
const {
return(gltfmesh_to_meshes);}
53 const std::map<int, Skeleton*>& getGltfskinsToSkeletons()
const {
return(gltfskins_to_skeletons);}
54 const std::map<int, Bone*>& getGltfnodeToBones()
const {
return(gltfnode_to_bones);}
55 const std::map<int, GltfMetallicRoughness*>& getGltfmaterialsToMaterials()
const {
return(gltfmaterials_to_materials);}
56 const std::map<int, SimpleTexture2D>& getGltftexturesToTextures()
const {
return(gltftextures_to_textures);}
57 const std::unordered_map<std::string, GltfAnimation>& getGltfanimToAnimations()
const {
return(gltfanim_to_animations);}
58 const std::unordered_map<std::string, GltfAnimation>& getSkeletonIsolatedAnimations()
const {
return(skeleton_isolated_animations);}
66 Entity* traverse_node(
int node_index,
Entity* parent =
nullptr);
70 Skeleton* construct_skeleton_from_skin(
int skin_index);
71 void process_animation(
const tinygltf::Animation& animation);
72 void populate_scene_animators();
73 void process_pose_animation_channel(
const tinygltf::AnimationChannel& channel,
const tinygltf::AnimationSampler& sampler,
GltfPoseKeyframeSequence& output_sequence);
74 GltfPoseKeyframeSequence process_animation_channel(
const tinygltf::AnimationChannel& channel,
const tinygltf::AnimationSampler& sampler);
77 void isolate_bone_animations(
const GltfAnimation& animation,
const std::vector<Bone*>& touched_bones);
80 void printInfo(
const std::string& info);
81 void printWarning(
const std::string& info);
83 std::vector<ExtrasExtension*> mExtensions;
85 Scene* _scene =
nullptr;
87 const tinygltf::Model& _asset;
88 const std::string _source_identifier;
90 std::map<int, Entity*> gltfnodes_to_entites;
91 std::map<int, MeshEntity*> gltfmesh_to_meshes;
92 std::map<int, Skeleton*> gltfskins_to_skeletons;
93 std::map<int, Bone*> gltfnode_to_bones;
94 std::map<int, GltfMetallicRoughness*> gltfmaterials_to_materials;
95 std::map<int, SimpleTexture2D> gltftextures_to_textures;
96 std::unordered_map<std::string, GltfAnimation> gltfanim_to_animations;
97 std::unordered_map<std::string, GltfAnimation> skeleton_isolated_animations;
99 std::map<int, BaseCameraEntity*> gltfcam_to_camera_entity;
105 enum class GltfLoadStep {
108 PROCESS_SKIN_MESH_ENT,
113 _GLTF_LOAD_STEP_TOTAL
116 enum class ExtensionResultHint{
125 virtual ExtensionResultHint preProcessSceneCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Scene& aSceneIn,
Scene* aSceneOut) {
return ExtensionResultHint::CONTINUE;}
126 virtual ExtensionResultHint postProcessSceneCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Scene& aSceneIn,
Scene* aSceneOut) {
return ExtensionResultHint::CONTINUE;}
129 virtual ExtensionResultHint postTraverseNodeCallback(
GltfScenePopulator& aPopulator,
const AugNode& aNode,
Entity* aParent,
Entity*& aResult) {
return ExtensionResultHint::CONTINUE;}
140 virtual ExtensionResultHint preProcessAnimationCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Animation& aAnimIn, std::vector<Bone*>& aTouchedBones,
GltfAnimation& aAnimResult) {
return ExtensionResultHint::CONTINUE;}
141 virtual ExtensionResultHint postProcessAnimationCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Animation& aAnimIn, std::vector<Bone*>& aTouchedBones,
GltfAnimation& aAnimResult) {
return ExtensionResultHint::CONTINUE;}
143 virtual ExtensionResultHint preProcessPbrMaterialCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Material& aMaterialIn,
GltfMetallicRoughness*& aMaterialOut) {
return ExtensionResultHint::CONTINUE;}
144 virtual ExtensionResultHint postProcessPbrMaterialCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Material& aMaterialIn,
GltfMetallicRoughness*& aMaterialOut) {
return ExtensionResultHint::CONTINUE;}
146 virtual ExtensionResultHint preProcessTextureCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Texture& aTexture,
const tinygltf::Image& aImage,
SimpleTexture2D& aTextureOut) {
return ExtensionResultHint::CONTINUE;}
147 virtual ExtensionResultHint postProcessTextureCallback(
GltfScenePopulator& aPopulator,
const tinygltf::Texture& aTexture,
const tinygltf::Image& aImage,
SimpleTexture2D& aTextureOut) {
return ExtensionResultHint::CONTINUE;}
149 virtual ExtensionResultHint preProcessPopulateAnimatorsCallback(
GltfScenePopulator& aPopulator, std::unordered_map<std::string, GltfAnimation>& aAnimationsIn,
Scene* aSceneOut) {
return ExtensionResultHint::CONTINUE;}
150 virtual ExtensionResultHint postProcessPopulateAnimatorsCallback(
GltfScenePopulator& aPopulator, std::unordered_map<std::string, GltfAnimation>& aAnimationsIn,
Scene* aSceneOut) {
return ExtensionResultHint::CONTINUE;}
154 return(aPopulator._asset);
Definition: GltfScenePopulator.hpp:40
Definition: GltfScenePopulator.hpp:27
Definition: Skeleton.hpp:15
Definition: SkinnedMeshEntity.hpp:55
Definition: Texture.hpp:60
Definition: SolidMeshEntity.hpp:31
Definition: GltfScenePopulator.hpp:12
Definition: CameraEntities.hpp:21
Definition: EntitiesBase.hpp:74
Definition: GltfScenePopulator.hpp:20
Definition: EntitiesBase.hpp:18
Definition: CameraEntities.hpp:63
Definition: KeyframeAnimation.hpp:153
Definition: Skeleton.hpp:72