MCPcopy Create free account
hub / github.com/assimp/assimp / ScaleAsset

Function ScaleAsset

tools/assimp_view/assimp_view.cpp:362–386  ·  view source on GitHub ↗

------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

360// global world transformation matrix according to the aset AABB
361//-------------------------------------------------------------------------------
362int 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

Callers 1

LoadAssetFunction · 0.85

Calls 4

aiVector3DClass · 0.85
CalculateBoundsFunction · 0.85
aiMatrix4x4Class · 0.85
LengthMethod · 0.45

Tested by

no test coverage detected