Joint Class Reference

#include <Joint.h>

Collaboration diagram for Joint:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Joint ()
 Joint (const Joint &)
 ~Joint ()
int set_name (const char *_name)
int set_name (const std::string &name)
char * get_name ()
int set_position (double x, double y, double z)
int add_position (double x, double y, double z)
int add_position (double *translation)
int get_position (double *_position)
double * get_position ()
int set_orientation (double t1, double t2, double t3)
int set_orientation (double *t)
int get_orientation (double *_orientation)
double * get_orientation ()
int multiply_matrix (Matrix R)
int set_matrix (Matrix M)
Matrix get_matrix ()
int get_matrix (Matrix *_M)
int set_father (Joint *_father)
Jointget_father ()
int add_son ()
Jointget_son (int k)
int get_N_son ()
int add_rotation (double *v, double theta)
int add_rotation (double v0, double v1, double v2, double theta)
int scale (double *s)
int scale (double s0, double s1, double s2)
int set_bind_pose (Matrix D)
int set_position_bind (double x, double y, double z)
int set_position_bind (double *t)
Matrix get_bind_pose ()
int get_bind_pose (Matrix *_M)
int set_access_number (int _access_number)
int get_access_number ()
int set_son (int k, Joint *new_joint)
int set_world_matrix (Matrix _world_matrix)
Matrix get_world_matrix ()
int set_T (Matrix _T)
Matrix get_T ()
Jointoperator= (const Joint &J)
double get_min_distance_to_bone (V_3D vertex)
int get_level ()
int set_level (int _level)
int set_weight_name (const char *weight_name)
const char * get_weight_name () const

Private Member Functions

int destroy ()

Private Attributes

Jointfather
int N_son
std::list< Joint * > son
char name [MAX_NAME]
std::string weight_name
Matrix M
double orientation [3]
Matrix bind_pose
Matrix world_matrix
Matrix T
int access_number
int level

Friends

ostream & operator<< (ostream &flux, Joint *joint)


Detailed Description

Definition at line 36 of file Joint.h.


Constructor & Destructor Documentation

Joint::Joint (  ) 

Definition at line 7 of file Joint.cpp.

References access_number, father, level, N_son, name, and orientation.

Referenced by add_son().

00008 {
00009   N_son=0;
00010   father = this;
00011   strcpy(name,"NO_NAME");
00012   for(int k=0;k<3;orientation[k]=0,k++);
00013 
00014   access_number = -1;
00015   level=0;
00016 }

Here is the caller graph for this function:

Joint::Joint ( const Joint _j  ) 

Definition at line 364 of file Joint.cpp.

References access_number, father, level, N_son, name, and orientation.

00365 {
00366   N_son=0;
00367   father = this;
00368   strcpy(name,"NO_NAME");
00369   for(int k=0;k<3;orientation[k]=0,k++);
00370 
00371   access_number = -1;
00372   level=_j.level;
00373 }

Joint::~Joint (  ) 

Definition at line 18 of file Joint.cpp.

References destroy().

00019 {
00020   destroy();
00021 }

Here is the call graph for this function:


Member Function Documentation

int Joint::set_name ( const char *  _name  ) 

Definition at line 31 of file Joint.cpp.

References name.

Referenced by Skeleton::copy_reccursive_joint(), File_parser::load_collada_skeleton(), Skeleton::reccursive_set_name_access_number(), and File_parser::reccursive_skeleton_collada_reading_node().

00032 {
00033   strcpy(name,_name);
00034   return 0;
00035 }

Here is the caller graph for this function:

int Joint::set_name ( const std::string &  name  ) 

Definition at line 37 of file Joint.cpp.

References name.

00038 {
00039   strcpy(name,_name.data());
00040   return 0;
00041 }

char * Joint::get_name (  ) 

Definition at line 43 of file Joint.cpp.

References name.

Referenced by Skeleton::copy_reccursive_joint(), Skeleton::cout_reccursive_joint(), Skeleton::get_access_number_of_joint_named(), File_parser::reccursive_skeleton_collada_reading_node(), and File_parser::save_skeleton_sk().

00044 {
00045   return name;
00046 }

Here is the caller graph for this function:

int Joint::set_position ( double  x,
double  y,
double  z 
)

Definition at line 48 of file Joint.cpp.

References M, and Matrix::set_translation().

Referenced by Skeleton::new_father().

00049 {
00050   M.set_translation(x,y,z);
00051   return 0;
00052 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Joint::add_position ( double  x,
double  y,
double  z 
)

Definition at line 54 of file Joint.cpp.

References Matrix::add_translation(), and M.

Referenced by File_parser::reccursive_skeleton_collada_reading_node().

00055 {
00056   M.add_translation(x,y,z);
00057   return 0;
00058 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Joint::add_position ( double *  translation  ) 

Definition at line 59 of file Joint.cpp.

References Matrix::add_translation(), and M.

00060 {
00061   M.add_translation(translation);
00062   return 0;
00063 }

Here is the call graph for this function:

int Joint::get_position ( double *  _position  ) 

Definition at line 65 of file Joint.cpp.

References M, and Matrix::value().

00066 {
00067   for(int k_dim=0;k_dim<3;k_dim++)
00068     _position[k_dim]=M.value(3,k_dim);
00069   return 0;
00070 }

Here is the call graph for this function:

double * Joint::get_position (  ) 

Definition at line 72 of file Joint.cpp.

00073 {
00074 
00075   double *position=NULL;
00076   position = new double[3];
00077   if(position==NULL)
00078     {
00079       cout<<"ERROR allocation position in joint get_position\n"<<endl;
00080       exit(-1);
00081     }
00082 
00083   get_position(position);
00084 
00085 
00086   return position;
00087 }

int Joint::set_orientation ( double  t1,
double  t2,
double  t3 
)

Definition at line 89 of file Joint.cpp.

References M, orientation, and Matrix::set_euler_angle().

Referenced by Skeleton::copy_reccursive_joint().

00090 {
00091   double t[3]={t1,t2,t3};
00092   
00093   M.set_euler_angle(t);
00094   orientation[0]=t1;
00095   orientation[1]=t2;
00096   orientation[2]=t3;
00097 
00098   return 0;
00099 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Joint::set_orientation ( double *  t  ) 

Definition at line 101 of file Joint.cpp.

References M, orientation, and Matrix::set_euler_angle().

00102 {
00103   M.set_euler_angle(t);
00104   for(int k_dim=0;k_dim<3;k_dim++)
00105     orientation[k_dim]=t[k_dim];
00106   return 0;
00107 }

Here is the call graph for this function:

int Joint::get_orientation ( double *  _orientation  ) 

Definition at line 123 of file Joint.cpp.

References orientation.

Referenced by Skeleton::copy_reccursive_joint().

00124 {
00125   for(int k_dim=0;k_dim<3;_orientation[k_dim]=orientation[k_dim],k_dim++);
00126   return 0;
00127 }

Here is the caller graph for this function:

double * Joint::get_orientation (  ) 

Definition at line 128 of file Joint.cpp.

References orientation.

00129 {
00130   return orientation;
00131 }

int Joint::multiply_matrix ( Matrix  R  ) 

Definition at line 219 of file Joint.cpp.

References M.

00220 {
00221   M = M*R;
00222   return 0;
00223 }

int Joint::set_matrix ( Matrix  M  ) 

Matrix Joint::get_matrix (  ) 

int Joint::get_matrix ( Matrix _M  ) 

Definition at line 256 of file Joint.cpp.

References M, Matrix::set_value(), and Matrix::value().

00257 {
00258   int k_1=0;
00259   int k_2=0;
00260   for(k_1=0;k_1<4;k_1++)
00261     for(k_2=0;k_2<4;k_2++)
00262       _M->set_value(M.value(k_1,k_2),k_1,k_2);
00263 
00264   return 0;
00265 }

Here is the call graph for this function:

int Joint::set_father ( Joint _father  ) 

Definition at line 133 of file Joint.cpp.

References father.

Referenced by add_son(), Skeleton::copy_reccursive_joint(), and Skeleton::reccursive_subsample_skeleton().

00134 {
00135   father = _father;
00136   return 0;
00137 }

Here is the caller graph for this function:

Joint * Joint::get_father (  ) 

Definition at line 139 of file Joint.cpp.

References father.

Referenced by Skeleton::change_father(), Skeleton::copy_reccursive_joint(), Skeleton::cout_reccursive_joint(), File_parser::load_old_sk_skeleton(), and File_parser::save_skeleton_sk().

00140 {
00141   return father;
00142 }

Here is the caller graph for this function:

int Joint::add_son (  ) 

Definition at line 175 of file Joint.cpp.

References Joint(), N_son, set_father(), and son.

Referenced by Skeleton::add_new_joint(), Skeleton::add_reccursive_child(), Skeleton::change_father(), Skeleton::copy_reccursive_joint(), File_parser::load_old_sk_skeleton(), and File_parser::reccursive_skeleton_collada_reading_node().

00176 {
00177   int ok=0;
00178 
00179   N_son++;
00180   Joint *new_son = new Joint();
00181   new_son->set_father(this);
00182   son.push_front(new_son);
00183 
00184   return ok;
00185 }

Here is the call graph for this function:

Here is the caller graph for this function:

Joint * Joint::get_son ( int  k  ) 

int Joint::get_N_son (  ) 

int Joint::add_rotation ( double *  v,
double  theta 
)

Definition at line 109 of file Joint.cpp.

References M, Matrix::multiply_vector_rotation(), and PI.

Referenced by File_parser::reccursive_skeleton_collada_reading_node().

00110 {
00111   if(theta>2*PI)
00112     printf("\n\n<<WARNING in add rotation, theta >2*PI, are you sure that you are sending radians angles ?>>\n\n");
00113 
00114   return M.multiply_vector_rotation(v,theta);
00115 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Joint::add_rotation ( double  v0,
double  v1,
double  v2,
double  theta 
)

Definition at line 117 of file Joint.cpp.

References M, and Matrix::multiply_vector_rotation().

00118 {
00119   double v[3]={v0,v1,v2};
00120   return M.multiply_vector_rotation(v,theta);
00121 }

Here is the call graph for this function:

int Joint::scale ( double *  s  ) 

Definition at line 197 of file Joint.cpp.

References M, and Matrix::scale().

Referenced by File_parser::reccursive_skeleton_collada_reading_node(), and scale().

00198 {
00199   return M.scale(s);
00200 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Joint::scale ( double  s0,
double  s1,
double  s2 
)

Definition at line 201 of file Joint.cpp.

References scale().

00202 {
00203   double s[3]={s0,s1,s2};
00204   return scale(s);
00205 }

Here is the call graph for this function:

int Joint::set_bind_pose ( Matrix  D  ) 

Definition at line 207 of file Joint.cpp.

References bind_pose.

Referenced by Skeleton::copy_reccursive_joint(), File_parser::load_collada_skining_attribute(), File_parser::load_old_sk_skeleton(), and Skeleton::recursive_bind_pose_fixing().

00208 {
00209   bind_pose = D;
00210   return 0;
00211 }

Here is the caller graph for this function:

int Joint::set_position_bind ( double  x,
double  y,
double  z 
)

Definition at line 232 of file Joint.cpp.

00233 {
00234   double t[3]={x,y,z};
00235   return set_position_bind(t);
00236 }

int Joint::set_position_bind ( double *  t  ) 

Definition at line 238 of file Joint.cpp.

References bind_pose, and Matrix::set_value().

00239 {
00240   for(int k_dim=0;k_dim<3;k_dim++)
00241     bind_pose.set_value(t[k_dim],3,k_dim);
00242   return 0;
00243 }

Here is the call graph for this function:

Matrix Joint::get_bind_pose (  ) 

Definition at line 213 of file Joint.cpp.

References bind_pose.

Referenced by Skeleton::copy_reccursive_joint(), and Skeleton::reccursive_matrix_precalculation().

00214 {
00215   return bind_pose;
00216 }

Here is the caller graph for this function:

int Joint::get_bind_pose ( Matrix _M  ) 

Definition at line 287 of file Joint.cpp.

References bind_pose.

00288 {
00289   *_M = bind_pose;
00290   return 0;
00291 }

int Joint::set_access_number ( int  _access_number  ) 

Definition at line 245 of file Joint.cpp.

References access_number.

Referenced by Skeleton::copy_reccursive_joint(), and Skeleton::read_reccursive_joint_cout().

00246 {
00247   access_number = _access_number;
00248   return 0;
00249 }

Here is the caller graph for this function:

int Joint::get_access_number (  ) 

int Joint::set_son ( int  k,
Joint new_joint 
)

Definition at line 144 of file Joint.cpp.

References access_number, N_son, name, and son.

00145 {
00146   int count=0;
00147   if(k>=0 && k<N_son)
00148     {
00149       std::list <Joint*>::iterator it_joint;
00150       for(it_joint=son.begin(),count=0;count<k;count++,it_joint++);
00151       *it_joint = new_joint;
00152       return 0;
00153     }
00154   
00155   cout<<"WARNING TRY TO SET INCORRECT SON n."<<k<<" with only "<<N_son<<" in memory for "<<name<<"("<<access_number<<")"<<endl;
00156 
00157   return -1;
00158 }

int Joint::set_world_matrix ( Matrix  _world_matrix  ) 

Definition at line 268 of file Joint.cpp.

References world_matrix.

Referenced by Skeleton::reccursive_matrix_precalculation().

00269 {
00270   world_matrix = _world_matrix;
00271   return 0;
00272 }

Here is the caller graph for this function:

Matrix Joint::get_world_matrix (  ) 

Definition at line 273 of file Joint.cpp.

References world_matrix.

Referenced by Skeleton::add_new_joint(), Skeleton::find_closest_joint(), get_min_distance_to_bone(), and Skeleton::get_world_position_of_bone().

00274 {
00275   return world_matrix;
00276 }

Here is the caller graph for this function:

int Joint::set_T ( Matrix  _T  ) 

Definition at line 277 of file Joint.cpp.

References T.

Referenced by Skeleton::reccursive_matrix_precalculation().

00278 {
00279   T = _T;
00280   return 0;
00281 }

Here is the caller graph for this function:

Matrix Joint::get_T (  ) 

Definition at line 282 of file Joint.cpp.

References T.

Referenced by Skinned::skinning().

00283 {
00284   return T;
00285 }

Here is the caller graph for this function:

Joint & Joint::operator= ( const Joint J  ) 

Definition at line 293 of file Joint.cpp.

References access_number, bind_pose, level, M, N_son, name, orientation, T, and world_matrix.

00294 {
00295   N_son = 0;
00296   strcpy(name,J.name);
00297   M = J.M;
00298   for(int k=0;k<3;k++)
00299     orientation[k] = J.orientation[k];
00300   bind_pose = J.bind_pose;
00301   world_matrix = J.world_matrix;
00302   T = J.T;
00303   access_number = J.access_number;
00304   level = J.level;
00305 
00306   return *this;
00307 }

double Joint::get_min_distance_to_bone ( V_3D  vertex  ) 

Definition at line 311 of file Joint.cpp.

References V_3D::dot(), get_N_son(), Matrix::get_position(), get_son(), get_world_matrix(), and world_matrix.

00312 {
00313   double distance_min=999.9f;
00314   double current_distance = 0.0f;
00315 
00316   V_3D P1 = world_matrix.get_position();
00317   V_3D P2;
00318   V_3D closest;
00319 
00320   V_3D u1,u2;
00321   double projection=0.0f;
00322 
00323   Joint *_son=0;
00324   if(get_N_son()==0) //case no son
00325     {
00326       distance_min = 9999.99f;
00327     }
00328   else
00329     {
00330       int k_son=0;
00331       for(k_son=0;k_son<get_N_son();k_son++)
00332         {
00333           _son = get_son(k_son);
00334           P2 = _son->get_world_matrix().get_position();
00335           
00336           u1 = vertex-P1;
00337           u2 = P2-P1;
00338 
00339           projection = u1.dot(u2)/u2.dot(u2); // (u1.u2)/||u2||^2
00340           if(projection<0)
00341             closest = P1;
00342           else if(projection>1)
00343             closest = P2;
00344           else
00345             closest = P1 + projection*u2;
00346 
00347           current_distance = (vertex-closest).norm(); //distance to
00348                                                       //closest bone
00349           if(current_distance<distance_min)
00350             distance_min=current_distance;
00351         }
00352     }
00353 
00354   return distance_min;
00355 }

Here is the call graph for this function:

int Joint::get_level (  ) 

Definition at line 358 of file Joint.cpp.

References level.

Referenced by File_parser::save_skeleton_sk().

00359 {return level;}

Here is the caller graph for this function:

int Joint::set_level ( int  _level  ) 

Definition at line 361 of file Joint.cpp.

References level.

Referenced by Skeleton::read_reccursive_joint_cout().

00362 {level = _level;return 0;}

Here is the caller graph for this function:

int Joint::set_weight_name ( const char *  weight_name  ) 

Definition at line 375 of file Joint.cpp.

References weight_name.

Referenced by File_parser::load_collada_skeleton(), and File_parser::reccursive_skeleton_collada_reading_node().

00376 {weight_name=_weight_name;return 0;}

Here is the caller graph for this function:

const char * Joint::get_weight_name (  )  const

Definition at line 377 of file Joint.cpp.

References weight_name.

Referenced by Skeleton::get_access_number_of_joint_named().

00378 {return weight_name.data();}

Here is the caller graph for this function:

int Joint::destroy (  )  [private]

Definition at line 25 of file Joint.cpp.

References access_number.

Referenced by ~Joint().

00026 {
00027   access_number = -1;
00028   return 0;
00029 }

Here is the caller graph for this function:


Friends And Related Function Documentation

ostream& operator<< ( ostream &  flux,
Joint joint 
) [friend]

Definition at line 97 of file Joint.h.

00098     {flux<<joint->get_name();return flux;}


Member Data Documentation

Joint* Joint::father [private]

Definition at line 116 of file Joint.h.

Referenced by get_father(), Joint(), and set_father().

int Joint::N_son [private]

Definition at line 117 of file Joint.h.

Referenced by add_son(), get_N_son(), get_son(), Joint(), operator=(), and set_son().

std::list<Joint*> Joint::son [private]

Definition at line 118 of file Joint.h.

Referenced by add_son(), get_son(), and set_son().

char Joint::name[MAX_NAME] [private]

Definition at line 120 of file Joint.h.

Referenced by get_name(), get_son(), Joint(), operator=(), set_name(), and set_son().

std::string Joint::weight_name [private]

Definition at line 121 of file Joint.h.

Referenced by get_weight_name(), and set_weight_name().

Matrix Joint::M [private]

double Joint::orientation[3] [private]

Definition at line 123 of file Joint.h.

Referenced by get_orientation(), Joint(), operator=(), and set_orientation().

Definition at line 124 of file Joint.h.

Referenced by get_bind_pose(), operator=(), set_bind_pose(), and set_position_bind().

Definition at line 125 of file Joint.h.

Referenced by get_min_distance_to_bone(), get_world_matrix(), operator=(), and set_world_matrix().

Matrix Joint::T [private]

Definition at line 126 of file Joint.h.

Referenced by get_T(), operator=(), and set_T().

int Joint::access_number [private]

Definition at line 128 of file Joint.h.

Referenced by destroy(), get_access_number(), get_son(), Joint(), operator=(), set_access_number(), and set_son().

int Joint::level [private]

Definition at line 129 of file Joint.h.

Referenced by get_level(), Joint(), operator=(), and set_level().


The documentation for this class was generated from the following files:

Generated on Mon Mar 30 16:56:54 2009 by  doxygen 1.5.6