October 19, 2021, 09:59:27

Author Topic: [bb] CenterMesh () by BlitzSupport [ 1+ years ago ]  (Read 633 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] CenterMesh () by BlitzSupport [ 1+ years ago ]
« on: June 29, 2017, 00:28:41 »
Title : CenterMesh ()
Author : BlitzSupport
Posted : 1+ years ago

Description : UPDATED

Sometimes models are offset when exported from editors, with the effect that rather than rotate around the mesh's centre, they rotate around some weird offset point way outside the mesh. This function will reposition the mesh at world co-ordinates 0, 0, 0 and centre it properly on its pivot.

Use this *before* trying to position a weird-offset mesh, as it will place the pivot on 0, 0, 0!

Now you can use those weirdo-offset models as you'd expect to!

(Note that the code inside the function should all be on one line, whereas it may not appear that way here!)


Code :
Code: BlitzBasic
  1. Function CenterMesh (entity)
  2.         FitMesh entity, -(MeshWidth (entity) / 2), -(MeshHeight (entity) / 2), -(MeshDepth (entity) / 2), MeshWidth (entity), MeshHeight (entity), MeshDepth (entity)
  3. End Function
  4.  
  5. ; Example usage (don't try to run this!)...
  6.  
  7. planeModel = LoadMesh ("747.x")
  8. CenterMesh (planeModel)
  9. PositionEntity planeModel, 50, 100, 50
  10.  


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal