/src/assimp/code/PostProcessing/ArmaturePopulate.h
Line | Count | Source |
1 | | /* |
2 | | Open Asset Import Library (assimp) |
3 | | ---------------------------------------------------------------------- |
4 | | |
5 | | Copyright (c) 2006-2026, assimp team |
6 | | |
7 | | All rights reserved. |
8 | | |
9 | | Redistribution and use of this software in source and binary forms, |
10 | | with or without modification, are permitted provided that the |
11 | | following conditions are met: |
12 | | |
13 | | * Redistributions of source code must retain the above |
14 | | copyright notice, this list of conditions and the |
15 | | following disclaimer. |
16 | | |
17 | | * Redistributions in binary form must reproduce the above |
18 | | copyright notice, this list of conditions and the |
19 | | following disclaimer in the documentation and/or other |
20 | | materials provided with the distribution. |
21 | | |
22 | | * Neither the name of the assimp team, nor the names of its |
23 | | contributors may be used to endorse or promote products |
24 | | derived from this software without specific prior |
25 | | written permission of the assimp team. |
26 | | |
27 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | | |
39 | | ---------------------------------------------------------------------- |
40 | | */ |
41 | | #ifndef ARMATURE_POPULATE_H_ |
42 | | #define ARMATURE_POPULATE_H_ |
43 | | |
44 | | #include "Common/BaseProcess.h" |
45 | | #include <assimp/BaseImporter.h> |
46 | | #include <vector> |
47 | | #include <map> |
48 | | |
49 | | |
50 | | struct aiNode; |
51 | | struct aiBone; |
52 | | |
53 | | namespace Assimp { |
54 | | |
55 | | // --------------------------------------------------------------------------- |
56 | | /** Armature Populate: This is a post process designed |
57 | | * To save you time when importing models into your game engines |
58 | | * This was originally designed only for fbx but will work with other formats |
59 | | * it is intended to auto populate aiBone data with armature and the aiNode |
60 | | * This is very useful when dealing with skinned meshes |
61 | | * or when dealing with many different skeletons |
62 | | * It's off by default but recommend that you try it and use it |
63 | | * It should reduce down any glue code you have in your |
64 | | * importers |
65 | | * You can contact RevoluPowered <gordon@gordonite.tech> |
66 | | * For more info about this |
67 | | */ |
68 | | class ASSIMP_API ArmaturePopulate final : public BaseProcess { |
69 | | public: |
70 | | /// The default class constructor. |
71 | 3.24k | ArmaturePopulate() = default; |
72 | | |
73 | | /// The class destructor. |
74 | | ~ArmaturePopulate() override = default; |
75 | | |
76 | | /// Overwritten, @see BaseProcess |
77 | | bool IsActive( unsigned int pFlags ) const override; |
78 | | |
79 | | /// Overwritten, @see BaseProcess |
80 | | void SetupProperties( const Importer* pImp ) override; |
81 | | |
82 | | /// Overwritten, @see BaseProcess |
83 | | void Execute( aiScene* pScene ) override; |
84 | | |
85 | | static aiNode *GetArmatureRoot(aiNode *bone_node, |
86 | | std::vector<aiBone *> &bone_list); |
87 | | |
88 | | static aiNode *GetNodeFromStack(const aiString &node_name, |
89 | | std::vector<aiNode *> &nodes); |
90 | | |
91 | | static void BuildNodeList(const aiNode *current_node, |
92 | | std::vector<aiNode *> &nodes); |
93 | | |
94 | | static void BuildBoneList(aiNode *current_node, const aiNode *root_node, |
95 | | const aiScene *scene, |
96 | | std::vector<aiBone *> &bones); |
97 | | |
98 | | static void BuildBoneStack(const aiNode *root_node, |
99 | | const aiScene *scene, |
100 | | const std::vector<aiBone *> &bones, |
101 | | std::map<aiBone *, aiNode *> &bone_stack, |
102 | | std::vector<aiNode *> &node_stack); |
103 | | }; |
104 | | |
105 | | } // Namespace Assimp |
106 | | |
107 | | #endif // SCALE_PROCESS_H_ |