/usr/include/crystalspace-2.0/cstool/mocapparser.h is in libcrystalspace-dev 2.0+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | /*
Copyright (C) 2010 Christian Van Brussel, Institute of Information
and Communication Technologies, Electronics and Applied Mathematics
at Universite catholique de Louvain, Belgium
http://www.uclouvain.be/en-icteam.html
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CS_CSTOOL_MOCAPREADER_H__
#define __CS_CSTOOL_MOCAPREADER_H__
/**\file
* Parsing of motion capture data files
*/
#include "csutil/scf_interface.h"
#include "csutil/ref.h"
#include "csutil/csstring.h"
#include "imesh/skeleton2.h"
#include "imesh/animnode/skeleton2anim.h"
#include "iutil/vfs.h"
#include "csutil/objreg.h"
namespace CS {
namespace Animation {
/**
* Return structure for CS::Animation::MocapParser::ParseData()
*/
struct MocapParserResult
{
/// Whether the parsing has been successful or not
bool result;
/**
* The newly created animation packet factory, if the parsing is successful, nullptr otherwise.
* This animation packet will contain the animations imported from the parsing.
*/
CS::Animation::iSkeletonAnimPacketFactory* animPacketFactory;
/// The newly created skeleton factory, if the parsing is successful, nullptr otherwise
CS::Animation::iSkeletonFactory* skeletonFactory;
/// The count of animation frames that have been imported
size_t frameCount;
/// The duration of each frames, in second
float frameDuration;
};
/**
* Tool for parsing motion capture ressource files and importing them into an animation
* data suitable for the CS::Mesh::iAnimatedMesh.
*
* You should be able to parse successively more than one ressource with the same parser.
*/
class CS_CRYSTALSPACE_EXPORT MocapParser
{
public:
///Destructor
virtual ~MocapParser () {}
/**
* Set the name of the animation packet that will be created. The default value is the
* name of the ressource file plus "_packet".
*/
virtual void SetPacketName (const char* name) = 0;
/**
* Set the name of the skeleton that will be created. The default value is the
* name of the ressource file plus "_skel".
*/
virtual void SetSkeletonName (const char* name) = 0;
/**
* Set the name of the animation that will be created. The default value is the
* name of the ressource file plus "_anim".
*/
virtual void SetAnimationName (const char* name) = 0;
/**
* Set the VFS path of the ressource file containing the motion capture data. You may have
* to add more than one ressource depending on the motion capture file format.
*/
virtual bool SetRessourceFile (const char* filename) = 0;
/**
* Set the frame where to start importing the animation data. The default value is 0.
*/
virtual void SetStartFrame (size_t frame) = 0;
/**
* Set the frame where to stop importing the animation data. A value of 0 means that
* all the animations until the end of the ressource file have to be imported. The
* default value is 0.
*/
virtual void SetEndFrame (size_t frame) = 0;
/**
* Set the global scale to be applied on all dimensions. The default value is 0.01.
*/
virtual void SetGlobalScale (float scale) = 0;
/**
* Parse the ressource files containing the motion capture data
*/
virtual MocapParserResult ParseData () = 0;
};
/**
* Tool for parsing BVH (BioVision Hierarchical data) motion capture ressource files.
*/
class CS_CRYSTALSPACE_EXPORT BVHMocapParser : public MocapParser
{
public:
/// Constructor
BVHMocapParser (iObjectRegistry* object_reg);
virtual ~BVHMocapParser () { }
/**
* Set the name of the animation packet that will be created. The default value is the
* name of the ressource file plus "_packet".
*/
virtual void SetPacketName (const char* name);
/**
* Set the name of the skeleton that will be created. The default value is the
* name of the ressource file plus "_skel".
*/
virtual void SetSkeletonName (const char* name);
/**
* Set the name of the animation that will be created. The default value is the
* name of the ressource file plus "_anim".
*/
virtual void SetAnimationName (const char* name);
/**
* Set the VFS path of the ressource file containing the motion capture data. For the
* BVH file format there may be only one ressource file at a time.
*/
virtual bool SetRessourceFile (const char* filename);
/**
* Set the frame where to start importing the animation data. The default value is 0.
*/
virtual void SetStartFrame (size_t frame);
/**
* Set the frame where to stop importing the animation data. A value of 0 means that
* all the animations until the end of the ressource file have to be imported. The
* default value is 0.
*/
virtual void SetEndFrame (size_t frame);
/**
* Set the global scale to be applied on all dimensions. The default value is 0.01.
*/
virtual void SetGlobalScale (float scale);
/**
* Parse the file containing the motion capture data
*/
virtual MocapParserResult ParseData ();
/**
* Set whether or not the "EndSite" leaf bones of the skeleton must be added. This
* can be useful in order to have some information on the orientation of the last bone.
* The default value is true.
*/
virtual void SetEndSitesAdded (bool added);
private:
bool ParseSkeletonBone (iFile* file, CS::Animation::BoneID parentBone,
const char* previousLine = nullptr);
bool ParseVector (const char* txt, csVector3& vector);
bool ParseChannels (const char* txt, CS::Animation::BoneID bone, csVector3 offset);
bool ParseAnimationFrame (iFile* file);
bool Report (int severity, const char* msg, ...) const;
iObjectRegistry* object_reg;
csRef<iVFS> vfs;
csString packetName;
csString skeletonName;
csString animationName;
csString filename;
csString filenameVFS;
csString mountname;
csRef<CS::Animation::iSkeletonAnimation> animation;
CS::Animation::MocapParserResult result;
int frameCount;
float frameDuration;
int currentFrame;
size_t startFrame, endFrame;
float globalScale;
bool endSitesAdded;
int endSitesCount;
CS::Animation::BoneID sampleBone;
enum DOFChannel
{
XROT = 0,
YROT,
ZROT,
XPOS,
YPOS,
ZPOS,
XSCA,
YSCA,
ZSCA
};
struct ChannelData
{
CS::Animation::BoneID boneID;
csVector3 offset;
csArray<DOFChannel> dofs;
};
csArray<ChannelData> channels;
size_t totalChannelCount;
};
} // namespace Animation
} // namespace CS
#endif // __CS_CSTOOL_MOCAPREADER_H__
|