View Full Version : Translate to origin (?)

07-15-2004, 07:59 PM
Hi people! ;)

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) :p

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. :(
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 :(
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:

07-15-2004, 08:40 PM
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

07-15-2004, 09:37 PM
Excellence! :) :D

Than you very much, zed!
That's the one! ;)