26 if(all_value)
delete[] all_value;
27 if(all_value_dot)
delete[] all_value_dot;
28 if(all_vel)
delete[] all_vel;
29 if(all_vel_dot)
delete[] all_vel_dot;
30 if(j_acc_p[0])
delete[] j_acc_p[0];
31 if(j_acc_p[1])
delete[] j_acc_p[1];
32 if(j_acc_p[2])
delete[] j_acc_p[2];
33 if(j_acc_p[3])
delete[] j_acc_p[3];
34 if(j_value_dot[0])
delete[] j_value_dot[0];
35 if(j_value_dot[1])
delete[] j_value_dot[1];
36 if(j_value_dot[2])
delete[] j_value_dot[2];
37 if(j_value_dot[3])
delete[] j_value_dot[3];
38 if(init_value)
delete[] init_value;
39 if(init_vel)
delete[] init_vel;
48 j_acc_p[0] = j_acc_p[1] = j_acc_p[2] = j_acc_p[3] = 0;
49 j_value_dot[0] = j_value_dot[1] = j_value_dot[2] = j_value_dot[3] = 0;
55 if(sg) set_relative_positions(sg);
60 all_value =
new double* [n_value];
61 all_value_dot =
new double* [n_value];
62 j_value_dot[0] =
new double [n_value];
63 j_value_dot[1] =
new double [n_value];
64 j_value_dot[2] =
new double [n_value];
65 j_value_dot[3] =
new double [n_value];
66 init_value =
new double [n_value];
70 all_vel =
new double* [n_dof];
71 all_vel_dot =
new double* [n_dof];
72 j_acc_p[0] =
new double [n_dof];
73 j_acc_p[1] =
new double [n_dof];
74 j_acc_p[2] =
new double [n_dof];
75 j_acc_p[3] =
new double [n_dof];
76 init_vel =
new double [n_dof];
101 if(node->isTransformNode() && (name = node->getName()) && strstr(name, ScaleString))
103 char* jointname = name + strlen(ScaleString);
105 ((TransformNode*)node)->getScale(scale);
123 TransformNode* mytrans = sg->findTransformNode(cur->
name);
139 if(parent) n_root_dof = parent->n_root_dof;
142 i_value = chain->n_value;
143 i_dof = chain->n_dof;
151 i_thrust = chain->n_thrust;
154 i_joint = chain->n_joint;
178 chain->n_thrust += 3;
189 chain->n_thrust += 6;
195 cerr <<
"warning: joint type not set for " <<
name << endl;
216 chain->all_value[i_value] = &q;
217 chain->all_value_dot[i_value] = &qd;
218 chain->all_vel[i_dof] = &qd;
219 chain->all_vel_dot[i_dof] = &qdd;
227 chain->all_value[i_value+
i] = &rel_ep(i);
228 chain->all_value_dot[i_value+
i] = &p_ep_dot(i);
232 chain->all_vel[i_dof+
i] = &p_ang_vel(i);
233 chain->all_vel_dot[i_dof+
i] = &p_ang_acc(i);
242 chain->all_value[i_value+
i] = &rel_pos(i);
243 chain->all_value_dot[i_value+
i] = &p_lin_vel(i);
247 chain->all_value[i_value+3+
i] = &rel_ep(i);
248 chain->all_value_dot[i_value+3+
i] = &p_ep_dot(i);
252 chain->all_vel[i_dof+
i] = &p_lin_vel(i);
253 chain->all_vel_dot[i_dof+
i] = &p_lin_acc(i);
257 chain->all_vel[i_dof+3+
i] = &p_ang_vel(i);
258 chain->all_vel_dot[i_dof+3+
i] = &p_ang_acc(i);
267 child->init_arrays();
268 brother->init_arrays();
274 brother->init_virtual();
275 child->init_virtual();
280 if(!realname)
return;
281 real = chain->FindJoint(realname);
284 cerr <<
"warning: could not find real joint " << realname <<
" of " <<
name << endl;
289 cerr <<
"error: real joint " << realname <<
" of " <<
name <<
" is also virtual" << endl;
296 Rt.
tran(real->abs_att);
297 pp.
sub(abs_pos, real->abs_pos);
298 rpos_real.mul(Rt, pp);
299 ratt_real.mul(Rt, abs_att);
302 pp.
sub(real->loc_com, rpos_real);
303 loc_com.mul(pp, ratt_real);
304 IR.
mul(real->inertia, ratt_real);
305 inertia.mul(
tran(ratt_real), IR);
307 cerr <<
"-- " <<
name << endl;
308 cerr <<
"rpos_real = " << rpos_real << endl;
309 cerr <<
"ratt_real = " << ratt_real << endl;
310 cerr <<
"mass = " << mass << endl;
311 cerr <<
"loc_com = " << loc_com << endl;
312 cerr <<
"inertia = " << inertia << endl;
#define IR(x)
Integer representation of a floating-point value.
virtual int init(SceneGraph *sg)
Initialize the parameters.
Joint * child
pointer to the child joint
void init_scale_sub(Node *node)
void mul(const fMat33 &mat1, const fMat33 &mat2)
friend fMat33 tran(const fMat33 &m)
Returns the transpose.
png_infop png_charpp name
Joint * root
Chain information.
int n_thrust
total DOF of the joints with t_given = false
void ApplyGeomScale(SceneGraph *sg)
char * name
joint name (including the character name)
void apply_geom_scale(SceneGraph *sg, Joint *cur)
void init_scale(SceneGraph *sg)
Joint * brother
pointer to the brother joint
Classes for defining open/closed kinematic chains.
fMat tran(const fMat &mat)
void sub(const fVec3 &vec1, const fVec3 &vec2)
void set_joint_name(const char *_joint_name, const char *_char_name)
The class for representing a joint.
void add_scale_object(const scale_object &_s)