Tagged: khronos, opengl es 2.0, pandaboard, sgx

This topic contains 18 replies, has 3 voices, and was last updated by dgu 4 years, 3 months ago.

- AuthorPosts
- June 25, 2013 at 8:34 am #31310
Hi,

I have a rectangle rendered. I want to move the camera along the line cutting the rectangle into half, say 0.1 units per frame. I went through the IntroducingPOD sample program. The problem is that the program uses

**CPVRTModelPOD**class and hence has functions to get the world matrices etc. I have all the vertex data and index data stored in 2D arrays. I don’t know how to start the navigation of camera. Can someone help ?June 25, 2013 at 9:55 am #37477Hi

everything is in the sample about camera ,did you change the value of

**vFrom**over the time ? (maybe a nice as a plus Lerp function will make it )regards

davidJune 25, 2013 at 9:56 am #37478all the beginner samples are superbe 🙂 i am still looking at it everyday 🙂

June 25, 2013 at 10:10 am #37479some nice easing function for your camera : http://gizma.com/easing/

June 25, 2013 at 10:45 am #37480The function for navigation is not a problem for me. The problem is that I have prepared the “View” and the “Projection” matrices as :

PVRTMat4 ViewMatrix = PVRTMat4::LookAtRH(vFrom, vTo, vUp);

PVRTMat4 ProjectionMatrix = PVRTMat4::PerspectiveFovRH(DEG2RAD(fFOV), AspectRatio, CameraNear, CameraFar, PVRTMat4::OGL, rotate);

PVRTMat4 ViewProjectionMatrix = ProjectionMatrix * ViewMatrix;

But I don’t know what the “Model” matrix means and how should it be prepared.

Additionally, I have passed the matrix as :

int i32Location = glGetUniformLocation(m_uiProgramObject, “myPMVMatrix”);

glUniformMatrix4fv(i32Location, 1, GL_FALSE, ViewProjectionMatrix.ptr());

Is this correct ?

June 25, 2013 at 10:58 am #37481Hi,

View & Projection matrices describe the camera position & how it sees the scene. The Model matrix (a.k.a. World matrix) describes your objects position in the scene, for example if it should be translated from it’s default position (0,0,0).

June 25, 2013 at 11:05 am #37482So, the matrix which is passed through glUniformMatrix4fv() is (P*M*V) or (P*V) ? Where should the model matrix be translated to from its default position ?

June 25, 2013 at 12:01 pm #37483Hello

`mTrans = PVRTMat4::Translation (x,y,z) for instance and`

mMVP = m_mProjection * mTrans * m_mView;of course the view is define by

`m_mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);`

the model-view-projection matrix is pass to the shader to transform the vertices

example :

`glUniformMatrix4fv(Uniforms[j].nLocation, 1, GL_FALSE, mMVP.f);`

regards

davidJune 25, 2013 at 12:28 pm #37484Thanks David, but I can’t understand the idea behind translating the model matrix in the first place. Why is it needed ? Sorry for being so noob.

What is the difference between mMVP.f and mMVP.ptr() ?

June 25, 2013 at 12:45 pm #37485No worry man, from the doc

`f= Array of float`

ptr=pointer to an array of float or element

June 25, 2013 at 1:09 pm #37487define your model view matrix as

PVRTMat4 mMVP;

mMVP = m_mProjection * mTrans * m_mView;The SDK provide a lot of sample about it , i am sure you will find the answer there as well

regards

david

ps

http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#The_Model_matrixJune 25, 2013 at 1:11 pm #37488No, that’s not my question. I asked why is the translation (mTrans = PVRTMat4::Translation (x,y,z)) required ?

June 25, 2013 at 1:21 pm #37489in the demo your were looking at

you saw

// Pass the model-view-projection matrix (MVP) to the shader to transform the vertices`PVRTMat4 mModelView, mMVP;`

mModelView = mView * mWorld;

mMVP = mProjection * mModelView;

glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.f);like is said before as well you could change your view model only by changing the vFrom value depending where you camera should be.

the translation that i introduce was to make life easier to move the camera as you like but it s not mandatory..a simple matrix calculation here