106 if( !mesh_->get_property_handle(propDefaultPose, DEFAULTPOSE_PROP) )
107 mesh_->add_property(propDefaultPose, DEFAULTPOSE_PROP);
109 if (! mesh_->get_property_handle(propWeights, SKIN_WEIGHTS_PROP))
110 mesh_->add_property(propWeights, SKIN_WEIGHTS_PROP);
113 for(
typename MeshT::VertexIter it = mesh_->vertices_begin(); it != mesh_->vertices_end(); ++it)
114 mesh_->property(propDefaultPose, *it) =
DefaultPose(mesh_->point(*it), mesh_->normal(*it));
162 if(!weightsComputed_) {
166 lastAnimationHandle_ = _hAni;
167 lastmethod_ = _method;
173 if(!mesh_->get_property_handle(propDefaultPose, DEFAULTPOSE_PROP) ||
174 !mesh_->get_property_handle(propWeights, SKIN_WEIGHTS_PROP))
177 Pose* pose = skeleton_->pose(_hAni);
180 int verticesWithoutWeights = 0;
184 typename MeshT::VertexIter it;
186 std::vector< OpenMesh::VertexHandle > vhandles; vhandles.clear(); vhandles.reserve(mesh_->n_vertices());
187 for(it = mesh_->vertices_begin(); it != mesh_->vertices_end(); ++it){vhandles.push_back(*it);}
188 int vhcount = (int) vhandles.size();
189 #pragma omp parallel for
190 for (
int vhindex = 0; vhindex < vhcount; vhindex++)
192 for(it = mesh_->vertices_begin(); it != mesh_->vertices_end(); ++it)
202 OpenMesh::Vec3d default_point = mesh_->property(propDefaultPose, currentVertexH).point,
203 default_normal = mesh_->property(propDefaultPose, currentVertexH).normal;
207 if( _method == Blending::M_LBS ) {
210 SkinWeights &weights = mesh_->property(propWeights, currentVertexH);
213 if (weights.size() == 0)
215 verticesWithoutWeights++;
219 SkinWeights::iterator it_w;
220 for(it_w = weights.begin(); it_w != weights.end(); ++it_w)
228 }
else if( _method == Blending::M_DBS ) {
231 std::vector<double> weightVector;
232 std::vector<DualQuaternion> dualQuaternions;
234 SkinWeights &weights = mesh_->property(propWeights, currentVertexH);
235 SkinWeights::iterator it_w;
237 for(it_w = weights.begin(); it_w != weights.end(); ++it_w){
238 weightVector.push_back( it_w->second );
242 DualQuaternion dq = DualQuaternion::interpolate(weightVector, dualQuaternions);
248 std::cerr <<
"ERROR: Unknown skinning method!" << std::endl;
251 mesh_->set_point(currentVertexH, point);
252 mesh_->set_normal(currentVertexH, normal);
256 if ( verticesWithoutWeights > 0 )
257 std::cerr <<
"Deform skin: " << verticesWithoutWeights <<
" vertices without skin weights." << std::endl;
275 if(mesh_->get_property_handle(propDefaultPose, DEFAULTPOSE_PROP))
277 typename MeshT::VertexIter it;
278 for(it = mesh_->vertices_begin(); it != mesh_->vertices_end(); ++it)
280 mesh_->set_point(*it, mesh_->property(propDefaultPose, *it).point);
281 mesh_->set_normal(*it, mesh_->property(propDefaultPose, *it).normal);
283 mesh_->remove_property(propDefaultPose);
288 mesh_->remove_property(propSkinWeights);
VectorT< T, 3 > transform_vector(const VectorT< T, 3 > &_v) const
transform vector (x',y',z',0) = A * (x,y,z,0)
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)