- Bresenham or any other?? ]]>

I know that gluLookAt is handy for using it from another object's perspective to look at you and then copying that matrix, inverting it, and using it to multiply against the GL_MODELVIEW matrix to make an object track you, but doing it this way makes it rotate toward you instantly, which is fine for a FPS game where the enemy just needs to turn and look at you. But this isn't ideal for a drone ship in space flying around in 3D that needs to rotate at it's own limited maximum rotate speed and slowly turn toward you in a smooth and realistic manner.

I tried the code on a few sites which teach how to convert a rotation matrix to a quaternion so that I can use the quaternion instead of the inverted gluLookAt matrix copy to do the orientation but it's not duplicating what the inverted matrix does. The code is identical on two different sites that I checked so it "supposedly" has to be right. My gut feeling is that I'm either making an assumption that those sites didn't explain, or that by some fluke, those formulas work for DirectX or some other GL other than OpenGL.

Has anyone here been able to create a rotation quaternion from a rotation matrix that duplicates what the matrix does perfectly? If so, would you be kind enough to show me the code that you use to get it to work? This is what I'm using now: The rmq_x, rmq_y, rmq_z, rmq_w variables are global GLfloat variables because the function can't return an array or multiple values. I pass it the rotation matrix that I inverted from the gluLookAt matrix to try and create the quaternion:

Code :

void Ship::rotationMatrixToQuaternion(GLfloat inp_mat[16])
{
GLfloat t = 1 + inp_mat[0] + inp_mat[5] + inp_mat[10];
GLfloat s = 0.0;
if (t > 0.0)
{
s = sqrt(t) * 2;
rmq_x = (inp_mat[6] - inp_mat[9]) / s;
rmq_y = (inp_mat[8] - inp_mat[2]) / s;
rmq_z = (inp_mat[1] - inp_mat[4]) / s;
rmq_w = 0.25 * s;
}
else if ((inp_mat[0] > inp_mat[5]) && (inp_mat[0] > inp_mat[10]))
{
s = sqrt(1.0 + inp_mat[0] - inp_mat[5] - inp_mat[10]) * 2;
rmq_x = 0.25 * s;
rmq_y = (inp_mat[1] + inp_mat[4] ) / s;
rmq_z = (inp_mat[8] + inp_mat[2] ) / s;
rmq_w = (inp_mat[6] - inp_mat[9] ) / s;
}
else if (inp_mat[5] > inp_mat[10])
{
s = sqrt(1.0 + inp_mat[5] - inp_mat[0] - inp_mat[10]) * 2;
rmq_x = (inp_mat[1] + inp_mat[4]) / s;
rmq_y = 0.25 * s;
rmq_z = (inp_mat[6] + inp_mat[9]) / s;
rmq_w = (inp_mat[8] - inp_mat[2]) / s;
}
else
{
s = sqrt(1.0 + inp_mat[10] - inp_mat[0] - inp_mat[5]) * 2;
rmq_x = (inp_mat[8] + inp_mat[2]) / s;
rmq_y = (inp_mat[6] + inp_mat[9]) / s;
rmq_z = 0.25 * s;
rmq_w = (inp_mat[1] - inp_mat[4]) / s;
}
}

Any help anyone can give me would be very much appreciated. ]]>

i hope you can help me understand this issue;

i really have no clue of how to do this.

i am working on monogame/xna

i have browsed tons of articles on this and still it's not more clear than before. i am not even completely sure of what the W in the xyzw components does, nor do i know what clip space even is.. it seems i am way over my head but that's never stopped me before.

if you could help me understand what to do here?

i know there is more than one way to do this; if i could understand just one way to do it that would set me in the right path i think

i thank you guys in advance, and sorry if i post in the wrong place ]]>

For e.g. in Blender 3D editor there are two subdivide actions smooth and non-smooth. I want to implement similar in my OpenGL program.

As I have viewed other frameworks where the non-smooth algorithm exists, it's like some kind of linear simple function, but I want to use well-known practice.

So, do exist some well-known algorithms for the non-smooth subdivision with a good asymptote? Because, Google shows only results for the smooth algos exactly. ]]>