Sign in to follow this  
the dodger uk

could some one have a look at this. local roation to real world

Recommended Posts

// this is only for the Y rotation float matrix[16]; Item->Model->GetMatrix( matrix );// this is an engine that gets the matrix float matrixSinMinus = matrix[2]; float matrixSin = matrix[8]; float matrixCos = matrix[10]; // rotate local corners to there real world position float realWorldX,realWorldZ; struct p { float x,y;} point; realWorldX = (matrixCos * point.x) + (matrixSinMinus * point.z); realWorldZ = (matrixSin * point.x) + (matrixCos * point.z);

Share this post


Link to post
Share on other sites
Quote:
Original post by Zao
If there's something wrong with it, what's wrong?
If there's not, why post it?
Is there any particular reason why you're inlining parts of matrix multiplication instead of just multiplying your matrix with a vector?



i just want to make sure if this is right , its the first time that i have tryed to impliment it .

its done this way cause its 3d engine that get taught in first year off uni

Share this post


Link to post
Share on other sites
It looks like what you are doing is taking a matrix assumed to be of the following form



Ripping out the sin and cos peices, and using them to rotate a vector in the x-z plane. This solution does work, but it only works if you are rotating around the y axis. If this is a special case where you are always going to rotate around the y axis, why not use a 2x2 matrix instead of a 4x4.

If you are looking for a more general solution, why not just do this?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this