kdepirate

11-15-2016, 02:28 AM

Code i want to write is posted on below site.

http://nehe.gamedev.net/article/camera_class_tutorial/18010/

There are two modes.

First mode is that Camera's target is rotated.

Second mode is an Orbit mode.

I found recently GLM which is very good library written by C++.

you may already know....

Well... I have obtained two rotations that are x-axis and y-axis from mouse event(OnMouseMove) in MFC.

Among the two mode i mentioned above, I want to know orbit mode.

I usually use below code for 3D space.

glMatrixMode(GL_PROJECTION);

glPushMatrix();

{

glLoadIdentity();

float fAspect = float(m_win_w)/m_win_h;

gluPerspective(80.0f, fAspect, 1.0, 1000.0);

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

{

const float DISTANCE = 100.f;

glLoadIdentity();

gluLookAt( eye.x, eye.y, eye.z,

0.f, 0.f, 0.f,

0.f, 1.f, 0.f);

DrawSomeObject();

}

}

I think the function, gluLookAt(), is the key.

For orbit mode, I should know how to handle eye's parameters and I should apply rotations of matrix and vector to those.

However, I can't grasp these concepts with glm.

I have tried to make orbit mode camera with below code.

glm::mat4 mat = glm::mat4();

glm::vec4 pos(0.f, 0.f, 100.f, 0.f);

glm::vec4 target(0.f, 0.f, 0.f, 0.f);

glm::vec4 up(0.f, 1.f, 0.f, 0.f);

mat[0] = pos;

mat = glm::rotate(mat, glm::radians(m_fRotYaw), glm::vec3(1.f, 0.f, 0.f));

mat = glm::rotate(mat, glm::radians(m_fRotPitch), glm::vec3(0.f, 1.f, 0.f));

gluLookAt(

mat[0].x, mat[0].y, mat[0].z,

target.x, target.y, target.z,

up.x, up.y, up.z);

But, I don't know where i have to fix.

May you think that I don't understand both matrix and vector.

That's right. My knowledge on these is not enough.

So, Can't anybody help me understand concepts and what i misunderstand.

I wish to grasp these concept, then I could write and complete this program with Euler and Quaternion.

Any reference site/URL would help me.

Thank you in advance.

http://nehe.gamedev.net/article/camera_class_tutorial/18010/

There are two modes.

First mode is that Camera's target is rotated.

Second mode is an Orbit mode.

I found recently GLM which is very good library written by C++.

you may already know....

Well... I have obtained two rotations that are x-axis and y-axis from mouse event(OnMouseMove) in MFC.

Among the two mode i mentioned above, I want to know orbit mode.

I usually use below code for 3D space.

glMatrixMode(GL_PROJECTION);

glPushMatrix();

{

glLoadIdentity();

float fAspect = float(m_win_w)/m_win_h;

gluPerspective(80.0f, fAspect, 1.0, 1000.0);

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

{

const float DISTANCE = 100.f;

glLoadIdentity();

gluLookAt( eye.x, eye.y, eye.z,

0.f, 0.f, 0.f,

0.f, 1.f, 0.f);

DrawSomeObject();

}

}

I think the function, gluLookAt(), is the key.

For orbit mode, I should know how to handle eye's parameters and I should apply rotations of matrix and vector to those.

However, I can't grasp these concepts with glm.

I have tried to make orbit mode camera with below code.

glm::mat4 mat = glm::mat4();

glm::vec4 pos(0.f, 0.f, 100.f, 0.f);

glm::vec4 target(0.f, 0.f, 0.f, 0.f);

glm::vec4 up(0.f, 1.f, 0.f, 0.f);

mat[0] = pos;

mat = glm::rotate(mat, glm::radians(m_fRotYaw), glm::vec3(1.f, 0.f, 0.f));

mat = glm::rotate(mat, glm::radians(m_fRotPitch), glm::vec3(0.f, 1.f, 0.f));

gluLookAt(

mat[0].x, mat[0].y, mat[0].z,

target.x, target.y, target.z,

up.x, up.y, up.z);

But, I don't know where i have to fix.

May you think that I don't understand both matrix and vector.

That's right. My knowledge on these is not enough.

So, Can't anybody help me understand concepts and what i misunderstand.

I wish to grasp these concept, then I could write and complete this program with Euler and Quaternion.

Any reference site/URL would help me.

Thank you in advance.