1 /*
2  *  Copyright (C) 2005-2007  MakeHuman Project
3  *
4  *  This program is free software; you  can  redistribute  it  and/or
5  *  modify  it  under  the terms of the GNU General Public License as
6  *  published by the Free Software Foundation; either  version  3  of
7  *  the License, or (at your option) any later version.
8  *
9  *  This  program  is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the  implied  warranty  of
11  *  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  *  General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software Foun-
16  *  dation, Inc., 59 Temple Place, Suite 330, Boston,  MA  02111-1307
17  *  USA
18  *
19  *  File: PoseTranslation.h
20  *  Project: MakeHuman <info@makehuman.org>, http://www.makehuman.org/
21  *  Library: ANIMORPH
22  *
23  *  For individual developers look into the AUTHORS file.
24  *
25  */
26 
27 #ifndef POSETRANSLATION_H
28 #define POSETRANSLATION_H 1
29 
30 #ifdef HAVE_CONFIG_H
31   #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <vector>
36 #include <set>
37 
38 #include <sstream>
39 #include <iostream>
40 #include <fstream>
41 
42 #include "util.h"
43 #include "FileReader.h"
44 #include "Matrix.h"
45 #include "Target.h"
46 
47 using std::string;
48 using std::set;
49 using std::vector;
50 
51 namespace Animorph {
52 
53 /*! \brief Represents the translational data of a PoseTarget
54 
55 This class is used like a PoseTarget to deform the base mesh before applying
56 PoseRotations.
57 
58 This class can be loaded from files.
59 
60 The format of PoseTranslation file is the same like for Target.
61 
62 The filenames of these files end in ".target".
63 
64 The format of PoseTranslation info file:
65 \verbatim
66 <int>
67 <int>
68 <float>
69 <float>,<float>
70 \endverbatim
71 
72 The first line contains the startVertexNumbers.
73 The second line contains the endVertexNumbers.
74 The third line indicates the originalSize.
75 The fourth line indicates minAngle and maxAngle.
76 
77 The filenames of these files end in ".target.info".
78 
79  */
80 class PoseTranslation
81 {
82 private:
83   Target *target;
84   float originalSize[3];
85   Vector3f formFactor;
86   float minAngle;
87   float maxAngle;
88   /// flag
89   bool normalize;
90   //string inFilename;
91   /// Can be used to influence the order of application of rotations and translations
92   string cat;
93 
94   bool mbLimb;
95 public:
96   PoseTranslation();
97   /*!
98    * \param filename the file with PoseTarget data to load
99    * \return true if file is found
100    * \return false if file isn't found
101    */
102   bool load (const string& filename);
103 
104 //  const vector<int> &getCenterVertexNumbers () {return centerVertexNumbers;}
getModVertex()105   UnsortedUsedVertex &getModVertex () {return target->getModVertex();}
106 /*
107   const RotateAxis& getAxis () const {return axis;}
108 
109   bool getHasCenter() const {return hasCenter;}
110   void setHasCenter(bool c) {hasCenter = c;}
111 
112   const Vector3f &getCenter() const {return center;}
113   void setCenter(const Vector3f& c) {center = c;}
114 */
115 
116   /// The distance between startVertexNumbers and endVertexNumbers, divided by originalSize
117   void calcFormFactor(const VertexVector& vertexvector);
getTarget()118   Target &getTarget () {return *target;}
getFormFactor()119   Vector3f &getFormFactor() {return formFactor;}
getMinAngle()120   const float getMinAngle() const {return minAngle;}
getMaxAngle()121   const float getMaxAngle() const {return maxAngle;}
getNormalize()122   const bool getNormalize() const {return normalize;}
setNormalize(bool inNormalize)123   void setNormalize(bool inNormalize) {normalize = inNormalize;}
124   //const string &getFilename() const {return inFilename;}
getCat()125   const string &getCat() const {return cat;}
setCat(string inCat)126   void setCat(string inCat) {cat = inCat;}
127 
setLimb(bool limb)128   void setLimb(bool limb) { mbLimb = limb;}
getLimb()129   bool getLimb(){return mbLimb;}
130 };
131 
132 }
133 
134 #endif	// POSETRANSLATION_H
135 
136