Calculate/rotate real mesh center

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
liberostelios
Posts: 5
Joined: Mon Oct 02, 2006 2:08 pm

Calculate/rotate real mesh center

Post by liberostelios »

Hi,

I am trying to write a f1 game and i am on the beginning. I want to rotate the wheels of the car but there is a problem. Every wheel is a different model but it's center is the is the worlds' 0,0,0 coordinates and not the wheels real center (so that the wheel fits to the rest of the car model)! Do you know any way to calculate the real center so that i can make the right rotation of the wheel?
linkoraclehero
Posts: 81
Joined: Sat Sep 09, 2006 6:46 am

Post by linkoraclehero »

Look in your old math books for a word called average :P
Make sure you don't have any stray vertecies. Irrlicht uses 0,0,0 for rotation, so just relocating the mesh in a 3D editor should work. As for calculating the center, you'd do a for loop on the meshes vertecies, and average all of thier Xs, Ys, and Zs to get the centerpoint.
Post Reply