# OpenGL How can I inverse the pitch it only have the viewmatrix (OpenGL)

This topic is 939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How can I inverse the pitch if I only have the viewmatrix in OpenGL, as describe from this video
from 11:19 to 12:19 thanks
Edited by kitman20022002

##### Share on other sites

All you have to do is invert the y-axis (multiply by -1).  If you are using glRotate etc, then you could call glGetFloatv() get the matrix and invert the proper #'s in the matrix.  You could try applying a glScalef(0,-1,0) as the last matrix after your current camera matrix. I believe that will work.

##### Share on other sites

tempCam = inverse(m_viewMatrix);

I assuming you mean this tempCam[1].y *= -1; , am I'm correct? I try this does not work

and also I try these

tempCam[2] = glm::reflect(tempView[2] , glm::vec4(1,0,0,1));
tempCam[2].w = 0.0f;

and also changing the fg shader code to
vec4 tmp = vec4(1.0 / pos.w);
vec4 projCoord = pos * tmp;
projCoord += vec4(1.0);
projCoord *= vec4(0.5);
vec4 reflectColor =texture(reflectionTexture , projCoord.xy);

and
tempCam [0].y *= -1;
tempCam [1].y *= -1;
tempCam [2].y *= -1;

and

tempCam[2] = glm::reflect(tempCam[2] , glm::vec4(1,0,0,1));
tempCam[2].w = 0.0f;
tempCam[1].y *= -1;

glm::mat4 tempView = inverse(tempCam);
drawScene(m_projection , inverse(tempCam ));

but does not work as well?

and also not using glRotate at all becasue my camera is handle by
Utility::freeMovement( m_cameraMatrix, a_deltaTime, static_cast<float>(m_cameraSpeed));
Edited by kitman20022002

##### Share on other sites

Well assuming tempCam matrix stores the matrix as an array of 16 floats:

tempCam[4], tempCam[5], tempCam[6] should be multiplied by -1.

##### Share on other sites

Still didn't work,and by the way tempCam[2] means column2, so tempCam[4], tempCam[5], tempCam[6] will give me column4 , 5, 6 which does not exists, but I forgot I can draw line to help me debug it so the ANSWER is I find out was:

tempCam[2].y *= -1.0f;
tempCam[3].x *= -1.0f;
tempCam[3].z *= -1.0f;


1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633702
• Total Posts
3013448
×