Skip to main content
added 579 characters in body
Source Link
Theraot
  • 28.2k
  • 4
  • 55
  • 83

The lookAt matrix is like this:

RightX RightY RightZ 0 UpX UpY UpZ 0 LookX LookY LookZ 0 PosX PosY PosZ 1 

Or in your code

normal[0] normal[1] normal[2] 0 newAxe[0] newAxe[1] newAxe[2] 0 -forward[0] -forward[1] -forward[2] 0 eyeX eyeY eyeZ 1 

With the indexes in the matrix as follows:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 

As you can see, you should be reading the indexes 12, 13 and 14:

d.X = _view[12]; d.Y = _view[13]; d.Z = _view[14]; 

This is quote from the OpenGL FAQ on Transformations:

For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory. The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix, where indices are numbered from 1 to 16 as described in section 2.11.2 of the OpenGL 2.1 Specification.

Of course, we are using 0 based indexes, so the 13th, 14th, and 15th elements are the indexes 12, 13 and 14.

The lookAt matrix is like this:

RightX RightY RightZ 0 UpX UpY UpZ 0 LookX LookY LookZ 0 PosX PosY PosZ 1 

Or in your code

normal[0] normal[1] normal[2] 0 newAxe[0] newAxe[1] newAxe[2] 0 -forward[0] -forward[1] -forward[2] 0 eyeX eyeY eyeZ 1 

With the indexes in the matrix as follows:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 

As you can see, you should be reading the indexes 12, 13 and 14:

d.X = _view[12]; d.Y = _view[13]; d.Z = _view[14]; 

The lookAt matrix is like this:

RightX RightY RightZ 0 UpX UpY UpZ 0 LookX LookY LookZ 0 PosX PosY PosZ 1 

Or in your code

normal[0] normal[1] normal[2] 0 newAxe[0] newAxe[1] newAxe[2] 0 -forward[0] -forward[1] -forward[2] 0 eyeX eyeY eyeZ 1 

With the indexes in the matrix as follows:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 

As you can see, you should be reading the indexes 12, 13 and 14:

d.X = _view[12]; d.Y = _view[13]; d.Z = _view[14]; 

This is quote from the OpenGL FAQ on Transformations:

For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory. The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix, where indices are numbered from 1 to 16 as described in section 2.11.2 of the OpenGL 2.1 Specification.

Of course, we are using 0 based indexes, so the 13th, 14th, and 15th elements are the indexes 12, 13 and 14.

Source Link
Theraot
  • 28.2k
  • 4
  • 55
  • 83

The lookAt matrix is like this:

RightX RightY RightZ 0 UpX UpY UpZ 0 LookX LookY LookZ 0 PosX PosY PosZ 1 

Or in your code

normal[0] normal[1] normal[2] 0 newAxe[0] newAxe[1] newAxe[2] 0 -forward[0] -forward[1] -forward[2] 0 eyeX eyeY eyeZ 1 

With the indexes in the matrix as follows:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 

As you can see, you should be reading the indexes 12, 13 and 14:

d.X = _view[12]; d.Y = _view[13]; d.Z = _view[14];