alihuseyin

12-14-2015, 05:38 AM

I am new in this field and I've searched this subject on the internet. What I found is only about one triangle, but I created many triangles which are related with each others and I can't rotate it. Here is my code:

glPushMatrix();

glRotatef(angle, 0, 1, 0); ///

glColor3f(-1.0, -1.0, -1.0);

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

for (int i = 0; i < 17; i++)

{

for (int j = 0; j < 21; j++)

{

glBegin(GL_TRIANGLES);

glVertex3f(xT, mat[i][j], zT);

glVertex3f(xT + 20, mat[i+1][j], zT);

glVertex3f(xT, mat[i][j+1], zT + 20);

glVertex3f(xT, mat[i][j+1], zT + 20);

glVertex3f(xT + 20, mat[i+1][j], zT);

glVertex3f(xT + 20, mat[i+1][j+1], zT + 20);

glEnd();

zT += 20.0;

}

xT += 20.0;

zT = 0.0;

}

xT = 0.0;

glPopMatrix();

min xT = 0.0 and max xT = 320 and min zT = 0.0 and max zT = 420

It crates a mountainous field and I want to see all area. My questions are:

What should my gluLookAt function be like?

How can I rotate this area by its origin?

glPushMatrix();

glRotatef(angle, 0, 1, 0); ///

glColor3f(-1.0, -1.0, -1.0);

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

for (int i = 0; i < 17; i++)

{

for (int j = 0; j < 21; j++)

{

glBegin(GL_TRIANGLES);

glVertex3f(xT, mat[i][j], zT);

glVertex3f(xT + 20, mat[i+1][j], zT);

glVertex3f(xT, mat[i][j+1], zT + 20);

glVertex3f(xT, mat[i][j+1], zT + 20);

glVertex3f(xT + 20, mat[i+1][j], zT);

glVertex3f(xT + 20, mat[i+1][j+1], zT + 20);

glEnd();

zT += 20.0;

}

xT += 20.0;

zT = 0.0;

}

xT = 0.0;

glPopMatrix();

min xT = 0.0 and max xT = 320 and min zT = 0.0 and max zT = 420

It crates a mountainous field and I want to see all area. My questions are:

What should my gluLookAt function be like?

How can I rotate this area by its origin?