ReturnVoid

05-05-2013, 04:04 AM

hi,

Have been trying for a while now to do this, but it doesn't seem to be working as I wish:

I have the following points (as an example);

32,-80,150

-80,32,150

The lower the z value here the more accurate what I'm trying to do becomes. So the coordinates get displayed but on a slight angle, so I'm obviously missing something I just don't know what :sorrow:.

I currently have a top-overview of this (on a different context & have no issue), but I'm trying to get a cross section view, which I thought using Rotate on the X-axis 90degrees would work, but :(....

Following code is an extract of what I'm using, if it isn't enough let me know & I'll have to post more:

//prepare scene

m_ModelMatrix = IDENTITY_MATRIX;

m_ProjectionMatrix = IDENTITY_MATRIX;

m_ViewMatrix = IDENTITY_MATRIX;

RotateAboutX(&m_ModelMatrix,90); //have also tried using this after Translate

ScaleMatrix(&m_ViewMatrix, m_ScaleX, m_ScaleY, m_ScaleZ); //scales cords x,y,z

TranslateMatrix(&m_ViewMatrix, 0, 0, m_TranslateZ); //

//resizing

glViewport(0, 0, (GLsizei)cx, (GLsizei)cy);

//fovy is 60. Have tried others.

m_ProjectionMatrix = CreateProjectionMatrix(m_fovy,(float)CurrentWidth / CurrentHeight,1.0f,100.0f);

//drawing.

//have also tried rotating here.

glUniformMatrix4fv(m_ModelMatrixUniformLocation, 1, GL_FALSE, m_ModelMatrix.m);

glUniformMatrix4fv(m_ViewMatrixUniformLocation, 1, GL_FALSE, m_ViewMatrix.m);

glBindVertexArray(m_vVaoID.at(i));

glDrawArrays(DRAW_TYPE, 0, m_vGLSizeCount.at(i));

//shader

const GLchar* VertexShader =

{

"#version 330\n"\

"layout(location=0) in vec4 in_Position;\n"\

"layout(location=1) in vec4 in_Color;\n"\

"out vec4 ex_Color;\n"\

"uniform mat4 vsModelMatrix;\n"\

"uniform mat4 vsViewMatrix;\n"\

"uniform mat4 vsProjectionMatrix;\n"\

"void main(void)\n"\

"{\n"\

"gl_Position = (vsProjectionMatrix * vsViewMatrix * vsModelMatrix) * in_Position;\n"\

"ex_Color = in_Color;\n"\

"}\n"

};

Any insight would be much appreciated!

Thank you.

Have been trying for a while now to do this, but it doesn't seem to be working as I wish:

I have the following points (as an example);

32,-80,150

-80,32,150

The lower the z value here the more accurate what I'm trying to do becomes. So the coordinates get displayed but on a slight angle, so I'm obviously missing something I just don't know what :sorrow:.

I currently have a top-overview of this (on a different context & have no issue), but I'm trying to get a cross section view, which I thought using Rotate on the X-axis 90degrees would work, but :(....

Following code is an extract of what I'm using, if it isn't enough let me know & I'll have to post more:

//prepare scene

m_ModelMatrix = IDENTITY_MATRIX;

m_ProjectionMatrix = IDENTITY_MATRIX;

m_ViewMatrix = IDENTITY_MATRIX;

RotateAboutX(&m_ModelMatrix,90); //have also tried using this after Translate

ScaleMatrix(&m_ViewMatrix, m_ScaleX, m_ScaleY, m_ScaleZ); //scales cords x,y,z

TranslateMatrix(&m_ViewMatrix, 0, 0, m_TranslateZ); //

//resizing

glViewport(0, 0, (GLsizei)cx, (GLsizei)cy);

//fovy is 60. Have tried others.

m_ProjectionMatrix = CreateProjectionMatrix(m_fovy,(float)CurrentWidth / CurrentHeight,1.0f,100.0f);

//drawing.

//have also tried rotating here.

glUniformMatrix4fv(m_ModelMatrixUniformLocation, 1, GL_FALSE, m_ModelMatrix.m);

glUniformMatrix4fv(m_ViewMatrixUniformLocation, 1, GL_FALSE, m_ViewMatrix.m);

glBindVertexArray(m_vVaoID.at(i));

glDrawArrays(DRAW_TYPE, 0, m_vGLSizeCount.at(i));

//shader

const GLchar* VertexShader =

{

"#version 330\n"\

"layout(location=0) in vec4 in_Position;\n"\

"layout(location=1) in vec4 in_Color;\n"\

"out vec4 ex_Color;\n"\

"uniform mat4 vsModelMatrix;\n"\

"uniform mat4 vsViewMatrix;\n"\

"uniform mat4 vsProjectionMatrix;\n"\

"void main(void)\n"\

"{\n"\

"gl_Position = (vsProjectionMatrix * vsViewMatrix * vsModelMatrix) * in_Position;\n"\

"ex_Color = in_Color;\n"\

"}\n"

};

Any insight would be much appreciated!

Thank you.