Are there anyone in here with some good math skills?
What i am doing is rotating the speed vector according to the angle between the two portals, both in the 2D axis and the 3D axis.
Here is the code in question, and ill comment along the way. Ask any questions if you dont understand something.
f32 he, rot, rotz,hx,hy,sr,cr,srz,crz,x2,y2,z2;
GetCarSpeedVector(veh, &v, false);
//teleport car to other portal
//speed vect rot, p is portal1 x rot, p is portal2 xrot, p3=port1 z rot, p9=p2 zrot. PIX=pi/180.
//rot = the difference + 180 degrees between the two portals
//z axis rot 2d, works at times, sometimes gives 90 deg wrong, sometimes 180.
//x axis rot, veh is supposed to fly up if the car drives horizontally into a portal on a wall, and the other portal is on the floor(facing upwards).
//it is also supposed to fly horizontally if car falls into portal on floor to portal on wall, in the direction the portal on wall is heading.
//right now, some of that works, ish. if it falls on a portal on floor to another on floor, it correctly flies up again, and if the portal is on a wall it(mostly) flies up (correctly).
// but vertical to horizontal does not work. it goes horizontally, but not in the direction the portal is headed.
//car rotation, which has to be partially rewritten, using quaternion to set the proper rotation of the car after it has been through the portal. (Quaternions are hard!)
ApplyForceToCar(veh, 3, x3, y3, z3, 0, 0, 0, 0, 0, 0, 1);
What am I doing wrong? Do you have any tips on what I can do?
If you are interested and show that you can contribute, I might let you in on the project, and I'll give you credits anyway if you contribute.
Cheers! A nice pic: http://puu.sh/39Lst
Edited by nixolas1, 18 June 2013 - 10:38 PM.