Skip to main content
added 1 characters in body
Source Link
Notabene
  • 6.1k
  • 1
  • 33
  • 40

In openGl matrices are transposed in memory. So transpose the matrix is OK. But youyour code doesn't look correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it

In openGl matrices are transposed in memory. So transpose the matrix is OK. But you code doesn't look correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it

In openGl matrices are transposed in memory. So transpose the matrix is OK. But your code doesn't look correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it

deleted 79 characters in body
Source Link
Notabene
  • 6.1k
  • 1
  • 33
  • 40

In openGl matrices are transposed in memory. So transpose the matrix is OK. And also why areBut you doing that vec4f(-zAxis.x_, -zAxis.y_, -zAxis.z_, -dot(zAxis,eye))? That is notcode doesn't look correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it

In openGl matrices are transposed in memory. So transpose the matrix is OK. And also why are you doing that vec4f(-zAxis.x_, -zAxis.y_, -zAxis.z_, -dot(zAxis,eye))? That is not correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it

In openGl matrices are transposed in memory. So transpose the matrix is OK. But you code doesn't look correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it

Source Link
Notabene
  • 6.1k
  • 1
  • 33
  • 40

In openGl matrices are transposed in memory. So transpose the matrix is OK. And also why are you doing that vec4f(-zAxis.x_, -zAxis.y_, -zAxis.z_, -dot(zAxis,eye))? That is not correct.

So you are in OpenGl. OpenGl uses right handed coordinate system. And for RH is lookat function defined like this:

zaxis = normal(cameraPosition - cameraTarget)
xaxis = normal(cross(cameraUpVector, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, cameraPosition)  -dot(yaxis, cameraPosition)  -dot(zaxis, cameraPosition)  1

Especialy take care about zaxis = normal(cameraPosition - cameraTarget) because it is the only difference between RH and LH system.

Save it transposed and that's it