Translate to origin (?)

Hi people! :wink:

It’s me, MatthewL!
I lost my password and the forum wouldn’t mail it to me (or Yahoo ate it thinking it was spam) :stuck_out_tongue:

So anyways, I’m in a pickle.
See, I’ve got these nice models I load from 3DS files, ready to be placed in the scene. The problem I’m having is that some of these models aren’t centered around the origin. :frowning:
So to be able to give them a position in the scene, I’d have to translate them so they are centered around {0,0,0} before giving them their final spacial destination.

I can’t seem to find the algorithm to do this for some reason :frowning:
I tried dividing the largest vertex in a given mesh by 2 and subtracting all of its vertices with that result, but apparantly that didn’t do it. Offcourse the problem seems to be that when you have a mesh centered around the origin, half of its vertices should be negative and half should be positive. The subtraction should become an addition when the vertex it’s being applied to is negative (I think :confused: ).

Does anyone know how to do it? :confused:

do the translating just after u load the model (so u only need to translate it once + not everytime u draw the model)

translateX = -smallestX - (largestX - smallestX) / 2.0

Excellence! :slight_smile: :smiley:

Than you very much, zed!
That’s the one! :wink: