BVHJoint.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SOFA_HELPER_IO_BVH_BVHJOINT_H
00028 #define SOFA_HELPER_IO_BVH_BVHJOINT_H
00029
00030 #include <sofa/helper/io/bvh/BVHChannels.h>
00031 #include <sofa/helper/io/bvh/BVHOffset.h>
00032 #include <sofa/helper/io/bvh/BVHMotion.h>
00033 #include <cstdio>
00034 #include <string.h>
00035
00036 namespace sofa
00037 {
00038
00039 namespace helper
00040 {
00041
00042 namespace io
00043 {
00044
00045 namespace bvh
00046 {
00047
00055 class BVHJoint
00056 {
00057 public:
00058 BVHJoint(const char *_name, bool _endSite=false, BVHJoint *_parent=NULL);
00059 virtual ~BVHJoint();
00060
00061 void addChild(BVHJoint *j){children.push_back(j);}
00062 std::vector<BVHJoint *> &getChildren(void){return children;}
00063
00064 void setOffset(BVHOffset *o){offset = o;}
00065 BVHOffset *setOffset(void){return offset;}
00066
00067 void setChannels(BVHChannels *c){channels = c;}
00068 BVHChannels *getChannels(void){return channels;}
00069
00070 bool isEndSite(void){return endSite;}
00071 void setEndSite(bool isEndSite){endSite = isEndSite;}
00072
00073 void setMotion(BVHMotion *m){motion = m;}
00074 BVHMotion *getMotion(void)
00075 {
00076 if (motion == NULL)
00077 motion = new BVHMotion();
00078 return motion;
00079 }
00080 void initMotion(double fTime, unsigned int fCount);
00081
00082
00083 void debug(int tab=0);
00084
00085 void display(int);
00086 void displayInGlobalFrame(void);
00087
00088
00089
00090 void dump(char *fName, char *rootJointName=NULL);
00091 void dumpPosition(FILE *f, char *s=NULL);
00092 void dumpSegment(FILE *f, char *s=NULL);
00093 void dumpRotation(FILE *f, char *s=NULL);
00094 void dumpRotationLimit(FILE *f, char *s=NULL);
00095 void dumpRotationStiffness(FILE *f, char *s=NULL);
00096 void dumpPosition(FILE *f, int beginIndex);
00097 void dumpSegment(FILE *f, int &cpt, int beginIndex);
00098 void dumpRotation(FILE *f, int &cpt, int beginIndex);
00099 void dumpRotationLimit(FILE *f, int &cpt);
00100 void dumpRotationStiffness(FILE *f, int &cpt);
00101
00102 int getNumJoints(char *s=NULL);
00103 int accumulateNumJoints(void);
00104 int getNumSegments(char *s=NULL);
00105 int getId();
00106 char* getName();
00107 BVHOffset* getOffset();
00108
00109
00110 private:
00111 BVHOffset *offset;
00112 BVHChannels* channels;
00113 BVHMotion* motion;
00114
00115 BVHJoint* parent;
00116 std::vector<BVHJoint *> children;
00117
00118 char name[128];
00119 bool endSite;
00120 int id;
00121 static int lastId;
00122
00123
00124 double matrix[16];
00125 };
00126
00127 }
00128
00129 }
00130
00131 }
00132
00133 }
00134
00135 #endif