------------------------------------------------------------------------------------------------
| 283 | |
| 284 | // ------------------------------------------------------------------------------------------------ |
| 285 | void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh *mesh, const aiVector3D &axis, aiVector3D *out) { |
| 286 | ai_real diffu, diffv; |
| 287 | aiVector3D center, min, max; |
| 288 | |
| 289 | // If the axis is one of x,y,z run a faster code path. It's worth the extra effort ... |
| 290 | // currently the mapping axis will always be one of x,y,z, except if the |
| 291 | // PretransformVertices step is used (it transforms the meshes into worldspace, |
| 292 | // thus changing the mapping axis) |
| 293 | if (axis * base_axis_x >= angle_epsilon) { |
| 294 | FindMeshCenter(mesh, center, min, max); |
| 295 | diffu = max.z - min.z; |
| 296 | diffv = max.y - min.y; |
| 297 | |
| 298 | for (unsigned int pnt = 0; pnt < mesh->mNumVertices; ++pnt) { |
| 299 | const aiVector3D &pos = mesh->mVertices[pnt]; |
| 300 | out[pnt].Set((pos.z - min.z) / diffu, (pos.y - min.y) / diffv, 0.0); |
| 301 | } |
| 302 | } else if (axis * base_axis_y >= angle_epsilon) { |
| 303 | FindMeshCenter(mesh, center, min, max); |
| 304 | diffu = max.x - min.x; |
| 305 | diffv = max.z - min.z; |
| 306 | |
| 307 | for (unsigned int pnt = 0; pnt < mesh->mNumVertices; ++pnt) { |
| 308 | const aiVector3D &pos = mesh->mVertices[pnt]; |
| 309 | out[pnt].Set((pos.x - min.x) / diffu, (pos.z - min.z) / diffv, 0.0); |
| 310 | } |
| 311 | } else if (axis * base_axis_z >= angle_epsilon) { |
| 312 | FindMeshCenter(mesh, center, min, max); |
| 313 | diffu = max.x - min.x; |
| 314 | diffv = max.y - min.y; |
| 315 | |
| 316 | for (unsigned int pnt = 0; pnt < mesh->mNumVertices; ++pnt) { |
| 317 | const aiVector3D &pos = mesh->mVertices[pnt]; |
| 318 | out[pnt].Set((pos.x - min.x) / diffu, (pos.y - min.y) / diffv, 0.0); |
| 319 | } |
| 320 | } |
| 321 | // slower code path in case the mapping axis is not one of the coordinate system axes |
| 322 | else { |
| 323 | aiMatrix4x4 mTrafo; |
| 324 | aiMatrix4x4::FromToMatrix(axis, base_axis_y, mTrafo); |
| 325 | FindMeshCenterTransformed(mesh, center, min, max, mTrafo); |
| 326 | diffu = max.x - min.x; |
| 327 | diffv = max.z - min.z; |
| 328 | |
| 329 | // again the same, except we're applying a transformation now |
| 330 | for (unsigned int pnt = 0; pnt < mesh->mNumVertices; ++pnt) { |
| 331 | const aiVector3D pos = mTrafo * mesh->mVertices[pnt]; |
| 332 | out[pnt].Set((pos.x - min.x) / diffu, (pos.z - min.z) / diffv, 0.0); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | // shouldn't be necessary to remove UV seams ... |
| 337 | } |
| 338 | |
| 339 | // ------------------------------------------------------------------------------------------------ |
| 340 | void ComputeUVMappingProcess::ComputeBoxMapping(aiMesh *, aiVector3D *) { |
nothing calls this directly
no test coverage detected