------------------------------------------------------------------------------- Scale the asset that it fits perfectly into the viewer window The function calculates the boundaries of the mesh and modifies the global world transformation matrix according to the aset AABB -------------------------------------------------------------------------------
| 360 | // global world transformation matrix according to the aset AABB |
| 361 | //------------------------------------------------------------------------------- |
| 362 | int ScaleAsset() { |
| 363 | aiVector3D aiVecs[2] = { aiVector3D(1e10f, 1e10f, 1e10f), |
| 364 | aiVector3D(-1e10f, -1e10f, -1e10f) }; |
| 365 | |
| 366 | if (g_pcAsset->pcScene->mRootNode) { |
| 367 | aiMatrix4x4 m; |
| 368 | CalculateBounds(g_pcAsset->pcScene->mRootNode, aiVecs, m); |
| 369 | } |
| 370 | |
| 371 | aiVector3D vDelta = aiVecs[1] - aiVecs[0]; |
| 372 | aiVector3D vHalf = aiVecs[0] + (vDelta / 2.0f); |
| 373 | float fScale = 10.0f / vDelta.Length(); |
| 374 | |
| 375 | g_mWorld = aiMatrix4x4( |
| 376 | 1.0f, 0.0f, 0.0f, 0.0f, |
| 377 | 0.0f, 1.0f, 0.0f, 0.0f, |
| 378 | 0.0f, 0.0f, 1.0f, 0.0f, |
| 379 | -vHalf.x, -vHalf.y, -vHalf.z, 1.0f) * |
| 380 | aiMatrix4x4( |
| 381 | fScale, 0.0f, 0.0f, 0.0f, |
| 382 | 0.0f, fScale, 0.0f, 0.0f, |
| 383 | 0.0f, 0.0f, fScale, 0.0f, |
| 384 | 0.0f, 0.0f, 0.0f, 1.0f); |
| 385 | return 1; |
| 386 | } |
| 387 | |
| 388 | //------------------------------------------------------------------------------- |
| 389 | // Generate a vertex buffer which holds the normals of the asset as |
no test coverage detected