Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenGL Rotation problem? help!!!!!!!!!!!!!!!!!!!!!!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 The Ironduke   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 November 1999 - 08:48 PM

I have created a landscape using GL_QUADS,
I have managed to get the camera to move around the map & zoom in & out.

I now wish to rotate the map at the point the
camera is looking at.

each time I try this using glTranslate & glRotate it is always the camera that is rotated here is the OnDraw function, I am using MFC(filthy heathen!)

please help, I dont want to get into DD7.

void CMapCellClassView::OnDraw(CDC* pDC)
{
CMapCellClassDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

glLoadIdentity() ;

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt(left_right, zoomy, back_forward + zoomz , left_right, 0, back_forward, 0.0, 1.0, 0.0);

glLineWidth(1.0);


glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_FILL);

glBindTexture(GL_TEXTURE_2D, id);

for(int x = 0; x < pDoc->m_MapCellManager.m_MapCellArray.GetUpperBound(); x++)
{

CPoint3D MidPoint = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_MidPoint);

CPoint3D TopLeft = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexTopLeft);

CPoint3D TopMiddle = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexTopMiddle);

CPoint3D TopRight = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexTopRight);

CPoint3D MiddleRight = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexMiddleRight);

CPoint3D BottomRight = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexBottomRight);

CPoint3D BottomMiddle = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexBottomMiddle);

CPoint3D BottomLeft = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexBottomLeft);

CPoint3D MiddleLeft = pDoc->m_MapCellManager.m_MapPointsArray.GetAt(
pDoc->m_MapCellManager.m_MapCellArray.GetAt(x)->m_VertexMiddleLeft);
glColor3f(0.0, 0.5, 0.0);




::glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(TopLeft.x, TopLeft.y, TopLeft.z);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(TopMiddle.x, TopMiddle.y,TopMiddle.z);

glTexCoord2f(1.0f, 1.0f);
glVertex3f(MidPoint.x, MidPoint.y,MidPoint.z);

glTexCoord2f(1.0f, 0.0f);
glVertex3f(MiddleLeft.x, MiddleLeft.y, MiddleLeft.z);

::glEnd();

::glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(TopMiddle.x, TopMiddle.y, TopMiddle.z);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(TopRight.x, TopRight.y, TopRight.z);
glTexCoord2f(1.0f, 1.0f);

glVertex3f(MiddleRight.x, MiddleRight.y, MiddleRight.z);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(MidPoint.x, MidPoint.y, MidPoint.z);
::glEnd();

::glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(MiddleLeft.x, MiddleLeft.y, MiddleLeft.z);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(MidPoint.x, MidPoint.y, MidPoint.z);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(BottomMiddle.x, BottomMiddle.y, BottomMiddle.z);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(BottomLeft.x, BottomLeft.y, BottomLeft.z);
::glEnd();

::glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(MidPoint.x, MidPoint.y, MidPoint.z);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(MiddleRight.x, MiddleRight.y, MiddleRight.z);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(BottomRight.x, BottomRight.y, BottomRight.z);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(BottomMiddle.x, BottomMiddle.y, BottomMiddle.z);
::glEnd();

}

if( FALSE == ::SwapBuffers(m_pDC->GetSafeHdc() ) )
{
::AfxMessageBox("error");
}

}


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS