1/** Helper class to construct a dummy mesh for file formats containing only motion data */
2
3/*
4Open Asset Import Library (assimp)
5----------------------------------------------------------------------
6
7Copyright (c) 2006-2017, assimp team
8
9All rights reserved.
10
11Redistribution and use of this software in source and binary forms,
12with or without modification, are permitted provided that the
13following conditions are met:
14
15* Redistributions of source code must retain the above
16copyright notice, this list of conditions and the
17following disclaimer.
18
19* Redistributions in binary form must reproduce the above
20copyright notice, this list of conditions and the
21following disclaimer in the documentation and/or other
22materials provided with the distribution.
23
24* Neither the name of the assimp team, nor the names of its
25contributors may be used to endorse or promote products
26derived from this software without specific prior
27written permission of the assimp team.
28
29THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41----------------------------------------------------------------------
42*/
43
44/** @file SkeletonMeshBuilder.h
45 * Declares SkeletonMeshBuilder, a tiny utility to build dummy meshes
46 * for animation skeletons.
47 */
48
49#ifndef AI_SKELETONMESHBUILDER_H_INC
50#define AI_SKELETONMESHBUILDER_H_INC
51
52#include <vector>
53#include <assimp/mesh.h>
54
55struct aiMaterial;
56struct aiScene;
57struct aiNode;
58
59namespace Assimp {
60
61// ---------------------------------------------------------------------------
62/**
63 * This little helper class constructs a dummy mesh for a given scene
64 * the resembles the node hierarchy. This is useful for file formats
65 * that don't carry any mesh data but only animation data.
66 */
67class SkeletonMeshBuilder
68{
69public:
70
71 // -------------------------------------------------------------------
72 /** The constructor processes the given scene and adds a mesh there.
73 *
74 * Does nothing if the scene already has mesh data.
75 * @param pScene The scene for which a skeleton mesh should be constructed.
76 * @param root The node to start with. NULL is the scene root
77 * @param bKnobsOnly Set this to true if you don't want the connectors
78 * between the knobs representing the nodes.
79 */
80 SkeletonMeshBuilder( aiScene* pScene, aiNode* root = NULL,
81 bool bKnobsOnly = false);
82
83protected:
84
85 // -------------------------------------------------------------------
86 /** Recursively builds a simple mesh representation for the given node
87 * and also creates a joint for the node that affects this part of
88 * the mesh.
89 * @param pNode The node to build geometry for.
90 */
91 void CreateGeometry( const aiNode* pNode);
92
93 // -------------------------------------------------------------------
94 /** Creates the mesh from the internally accumulated stuff and returns it.
95 */
96 aiMesh* CreateMesh();
97
98 // -------------------------------------------------------------------
99 /** Creates a dummy material and returns it. */
100 aiMaterial* CreateMaterial();
101
102protected:
103 /** space to assemble the mesh data: points */
104 std::vector<aiVector3D> mVertices;
105
106 /** faces */
107 struct Face
108 {
109 unsigned int mIndices[3];
110 Face();
111 Face( unsigned int p0, unsigned int p1, unsigned int p2)
112 { mIndices[0] = p0; mIndices[1] = p1; mIndices[2] = p2; }
113 };
114 std::vector<Face> mFaces;
115
116 /** bones */
117 std::vector<aiBone*> mBones;
118
119 bool mKnobsOnly;
120};
121
122} // end of namespace Assimp
123
124#endif // AI_SKELETONMESHBUILDER_H_INC
125