vrshoot

annotate libs/assimp/BVHLoader.h @ 1:e7ca128b8713

looks nice :)
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Feb 2014 00:35:22 +0200
parents
children
rev   line source
nuclear@0 1 /** Defines the BHV motion capturing loader class */
nuclear@0 2
nuclear@0 3 /*
nuclear@0 4 Open Asset Import Library (assimp)
nuclear@0 5 ----------------------------------------------------------------------
nuclear@0 6
nuclear@0 7 Copyright (c) 2006-2012, assimp team
nuclear@0 8 All rights reserved.
nuclear@0 9
nuclear@0 10 Redistribution and use of this software in source and binary forms,
nuclear@0 11 with or without modification, are permitted provided that the
nuclear@0 12 following conditions are met:
nuclear@0 13
nuclear@0 14 * Redistributions of source code must retain the above
nuclear@0 15 copyright notice, this list of conditions and the
nuclear@0 16 following disclaimer.
nuclear@0 17
nuclear@0 18 * Redistributions in binary form must reproduce the above
nuclear@0 19 copyright notice, this list of conditions and the
nuclear@0 20 following disclaimer in the documentation and/or other
nuclear@0 21 materials provided with the distribution.
nuclear@0 22
nuclear@0 23 * Neither the name of the assimp team, nor the names of its
nuclear@0 24 contributors may be used to endorse or promote products
nuclear@0 25 derived from this software without specific prior
nuclear@0 26 written permission of the assimp team.
nuclear@0 27
nuclear@0 28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0 29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0 30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0 31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0 32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0 33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0 34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0 35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0 36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0 37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0 38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0 39
nuclear@0 40 ----------------------------------------------------------------------
nuclear@0 41 */
nuclear@0 42
nuclear@0 43 /** @file BVHLoader.h
nuclear@0 44 * @brief Biovision BVH import
nuclear@0 45 */
nuclear@0 46
nuclear@0 47 #ifndef AI_BVHLOADER_H_INC
nuclear@0 48 #define AI_BVHLOADER_H_INC
nuclear@0 49
nuclear@0 50 #include "BaseImporter.h"
nuclear@0 51
nuclear@0 52 namespace Assimp
nuclear@0 53 {
nuclear@0 54
nuclear@0 55 // --------------------------------------------------------------------------------
nuclear@0 56 /** Loader class to read Motion Capturing data from a .bvh file.
nuclear@0 57 *
nuclear@0 58 * This format only contains a hierarchy of joints and a series of keyframes for
nuclear@0 59 * the hierarchy. It contains no actual mesh data, but we generate a dummy mesh
nuclear@0 60 * inside the loader just to be able to see something.
nuclear@0 61 */
nuclear@0 62 class BVHLoader : public BaseImporter
nuclear@0 63 {
nuclear@0 64
nuclear@0 65 /** Possible animation channels for which the motion data holds the values */
nuclear@0 66 enum ChannelType
nuclear@0 67 {
nuclear@0 68 Channel_PositionX,
nuclear@0 69 Channel_PositionY,
nuclear@0 70 Channel_PositionZ,
nuclear@0 71 Channel_RotationX,
nuclear@0 72 Channel_RotationY,
nuclear@0 73 Channel_RotationZ
nuclear@0 74 };
nuclear@0 75
nuclear@0 76 /** Collected list of node. Will be bones of the dummy mesh some day, addressed by their array index */
nuclear@0 77 struct Node
nuclear@0 78 {
nuclear@0 79 const aiNode* mNode;
nuclear@0 80 std::vector<ChannelType> mChannels;
nuclear@0 81 std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
nuclear@0 82
nuclear@0 83 Node() { }
nuclear@0 84 Node( const aiNode* pNode) : mNode( pNode) { }
nuclear@0 85 };
nuclear@0 86
nuclear@0 87 public:
nuclear@0 88
nuclear@0 89 BVHLoader();
nuclear@0 90 ~BVHLoader();
nuclear@0 91
nuclear@0 92 public:
nuclear@0 93 /** Returns whether the class can handle the format of the given file.
nuclear@0 94 * See BaseImporter::CanRead() for details. */
nuclear@0 95 bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const;
nuclear@0 96
nuclear@0 97 void SetupProperties(const Importer* pImp);
nuclear@0 98 const aiImporterDesc* GetInfo () const;
nuclear@0 99
nuclear@0 100 protected:
nuclear@0 101
nuclear@0 102
nuclear@0 103 /** Imports the given file into the given scene structure.
nuclear@0 104 * See BaseImporter::InternReadFile() for details
nuclear@0 105 */
nuclear@0 106 void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
nuclear@0 107
nuclear@0 108 protected:
nuclear@0 109 /** Reads the file */
nuclear@0 110 void ReadStructure( aiScene* pScene);
nuclear@0 111
nuclear@0 112 /** Reads the hierarchy */
nuclear@0 113 void ReadHierarchy( aiScene* pScene);
nuclear@0 114
nuclear@0 115 /** Reads a node and recursively its childs and returns the created node. */
nuclear@0 116 aiNode* ReadNode();
nuclear@0 117
nuclear@0 118 /** Reads an end node and returns the created node. */
nuclear@0 119 aiNode* ReadEndSite( const std::string& pParentName);
nuclear@0 120
nuclear@0 121 /** Reads a node offset for the given node */
nuclear@0 122 void ReadNodeOffset( aiNode* pNode);
nuclear@0 123
nuclear@0 124 /** Reads the animation channels into the given node */
nuclear@0 125 void ReadNodeChannels( BVHLoader::Node& pNode);
nuclear@0 126
nuclear@0 127 /** Reads the motion data */
nuclear@0 128 void ReadMotion( aiScene* pScene);
nuclear@0 129
nuclear@0 130 /** Retrieves the next token */
nuclear@0 131 std::string GetNextToken();
nuclear@0 132
nuclear@0 133 /** Reads the next token as a float */
nuclear@0 134 float GetNextTokenAsFloat();
nuclear@0 135
nuclear@0 136 /** Aborts the file reading with an exception */
nuclear@0 137 void ThrowException( const std::string& pError);
nuclear@0 138
nuclear@0 139 /** Constructs an animation for the motion data and stores it in the given scene */
nuclear@0 140 void CreateAnimation( aiScene* pScene);
nuclear@0 141
nuclear@0 142 protected:
nuclear@0 143 /** Filename, for a verbose error message */
nuclear@0 144 std::string mFileName;
nuclear@0 145
nuclear@0 146 /** Buffer to hold the loaded file */
nuclear@0 147 std::vector<char> mBuffer;
nuclear@0 148
nuclear@0 149 /** Next char to read from the buffer */
nuclear@0 150 std::vector<char>::const_iterator mReader;
nuclear@0 151
nuclear@0 152 /** Current line, for error messages */
nuclear@0 153 unsigned int mLine;
nuclear@0 154
nuclear@0 155 /** Collected list of nodes. Will be bones of the dummy mesh some day, addressed by their array index.
nuclear@0 156 * Also contain the motion data for the node's channels
nuclear@0 157 */
nuclear@0 158 std::vector<Node> mNodes;
nuclear@0 159
nuclear@0 160 /** basic Animation parameters */
nuclear@0 161 float mAnimTickDuration;
nuclear@0 162 unsigned int mAnimNumFrames;
nuclear@0 163
nuclear@0 164 bool noSkeletonMesh;
nuclear@0 165 };
nuclear@0 166
nuclear@0 167 } // end of namespace Assimp
nuclear@0 168
nuclear@0 169 #endif // AI_BVHLOADER_H_INC