vrshoot

view libs/assimp/SkeletonMeshBuilder.h @ 0:b2f14e535253

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