CrystalSpace

Public API Reference

cstool/mocapparser.h
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2010 Christian Van Brussel, Institute of Information
00003       and Communication Technologies, Electronics and Applied Mathematics
00004       at Universite catholique de Louvain, Belgium
00005       http://www.uclouvain.be/en-icteam.html
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Library General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015   Library General Public License for more details.
00016 
00017   You should have received a copy of the GNU Library General Public
00018   License along with this library; if not, write to the Free
00019   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 #ifndef __CS_CSTOOL_MOCAPREADER_H__
00022 #define __CS_CSTOOL_MOCAPREADER_H__
00023 
00028 #include "csutil/scf_interface.h"
00029 #include "csutil/ref.h"
00030 #include "csutil/csstring.h"
00031 #include "imesh/skeleton2.h"
00032 #include "imesh/animnode/skeleton2anim.h"
00033 #include "iutil/vfs.h"
00034 #include "csutil/objreg.h"
00035 
00036 namespace CS {
00037 namespace Animation {
00038 
00042 struct MocapParserResult
00043 {
00045   bool result;
00046 
00051   CS::Animation::iSkeletonAnimPacketFactory* animPacketFactory;
00052 
00054   CS::Animation::iSkeletonFactory* skeletonFactory;
00055 
00057   size_t frameCount;
00058 
00060   float frameDuration;
00061 };
00062 
00069 class CS_CRYSTALSPACE_EXPORT MocapParser
00070 {
00071 public:
00073   virtual ~MocapParser () {}
00074 
00079   virtual void SetPacketName (const char* name) = 0;
00080 
00085   virtual void SetSkeletonName (const char* name) = 0;
00086 
00091   virtual void SetAnimationName (const char* name) = 0;
00092 
00097   virtual bool SetRessourceFile (const char* filename) = 0;
00098 
00102   virtual void SetStartFrame (size_t frame) = 0;
00103 
00109   virtual void SetEndFrame (size_t frame) = 0;
00110 
00114   virtual void SetGlobalScale (float scale) = 0;
00115 
00119   virtual MocapParserResult ParseData () = 0;
00120 };
00121 
00125 class CS_CRYSTALSPACE_EXPORT BVHMocapParser : public MocapParser
00126 {
00127 public:
00129   BVHMocapParser (iObjectRegistry* object_reg);
00130 
00131   virtual ~BVHMocapParser () { }
00132 
00137   virtual void SetPacketName (const char* name);
00138 
00143   virtual void SetSkeletonName (const char* name);
00144 
00149   virtual void SetAnimationName (const char* name);
00150 
00155   virtual bool SetRessourceFile (const char* filename);
00156 
00160   virtual void SetStartFrame (size_t frame);
00161 
00167   virtual void SetEndFrame (size_t frame);
00168 
00172   virtual void SetGlobalScale (float scale);
00173 
00177   virtual MocapParserResult ParseData ();
00178 
00184   virtual void SetEndSitesAdded (bool added);
00185 
00186  private:
00187   bool ParseSkeletonBone (iFile* file, CS::Animation::BoneID parentBone,
00188                          const char* previousLine = nullptr);
00189   bool ParseVector (const char* txt, csVector3& vector);
00190   bool ParseChannels (const char* txt, CS::Animation::BoneID bone, csVector3 offset);
00191   bool ParseAnimationFrame (iFile* file);
00192   bool Report (int severity, const char* msg, ...) const;
00193 
00194   iObjectRegistry* object_reg;
00195   csRef<iVFS> vfs;
00196   csString packetName;
00197   csString skeletonName;
00198   csString animationName;
00199   csString filename;
00200   csString filenameVFS;
00201   csString mountname;
00202   csRef<CS::Animation::iSkeletonAnimation> animation;
00203 
00204   CS::Animation::MocapParserResult result;
00205 
00206   int frameCount;
00207   float frameDuration;
00208   int currentFrame;
00209   size_t startFrame, endFrame;
00210   float globalScale;
00211   bool endSitesAdded;
00212   int endSitesCount;
00213   CS::Animation::BoneID sampleBone;
00214 
00215   enum DOFChannel
00216   {
00217     XROT = 0,
00218     YROT,
00219     ZROT,
00220     XPOS,
00221     YPOS,
00222     ZPOS,
00223     XSCA,
00224     YSCA,
00225     ZSCA
00226   };
00227 
00228   struct ChannelData
00229   {
00230     CS::Animation::BoneID boneID;
00231     csVector3 offset;
00232     csArray<DOFChannel> dofs;
00233   };
00234 
00235   csArray<ChannelData> channels;
00236   size_t totalChannelCount;
00237 };
00238 
00239 } // namespace Animation
00240 } // namespace CS
00241 
00242 
00243 #endif // __CS_CSTOOL_MOCAPREADER_H__

Generated for Crystal Space 2.0 by doxygen 1.7.6.1