Hi, I'm not sure if this is a hard problem or not but I've been trying to get the direction my PhysX car is pointing, the reason I want this is to set the rotation of a 2D representation of the 3D car's direction, I've tried Actor->getGlobalOriantationQuat().z but that does nothing.
Thanks.
Ageia get actor direction
You car just has a matrix representing its transformation, not a defined direction that it's facing in.
To find a direction vector you can take a unit vector of your car's initial direction (when you created it, say 1,0,0, facing towards +X) and then you multiply the vector by the car's transformation matrix to get its current direction it's facing.
To find a direction vector you can take a unit vector of your car's initial direction (when you created it, say 1,0,0, facing towards +X) and then you multiply the vector by the car's transformation matrix to get its current direction it's facing.
Ay? How do I do that, your explanation is a bit cryptic This bit was the most confusing.JP wrote:You car just has a matrix representing its transformation, not a defined direction that it's facing in.
To find a direction vector you can take a unit vector of your car's initial direction (when you created it, say 1,0,0, facing towards +X) and then you multiply the vector by the car's transformation matrix to get its current direction it's facing.
Code: Select all
multiply the vector by the car's transformation matrix
Okay thanks I'll have a look, trouble is I'm not experienced with Quats, Matricies, Euler rotations etc., so I'm a bit baffled on how to extract the infoJP wrote:How's that cryptic? Do vector * matrix :p
i think that's the way it's done... in Irrlicht the matrices have a nice function called transformVect which may actually be different to a multiplication, not sure...
but you could look at the irrlicht source for transformVect if it doesn't work.
You're gonna need to know about matrices for a lot of things in game programming, especially when combining physics engines with rendering so have a bit of a google for a tutorial. Matrices are very scary at first but they're not particularly complicated and all the bits that are are generally hidden away from you by engines so you just have to use a function to extract the required info from the matrix rather than accessing the matrices elements to do it yourself