GIDForums  

Go Back   GIDForums > Computer Programming Forums > OpenGL Programming
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Apr-2008, 11:37
nora_antonia nora_antonia is offline
New Member
 
Join Date: Apr 2008
Posts: 1
nora_antonia is on a distinguished road

rotating figure in opengl


hello

I implemented a rotating cube in opengl which rotates when the user moves the mouse.
I am a beginner with opengl, so i wanted to ask you a question on rotating.
here is my code for the rotation :

CPP / C++ / C Code:
void CDiplomaView::OnLButtonDown(UINT nFlags, CPoint point) 
{
    // TODO: Add your message handler code here and/or call default
	 m_LeftButtonDown = TRUE;
                 m_LeftDownPos = point;
	CView::OnLButtonDown(nFlags, point);
}

void CDiplomaView::OnMouseMove(UINT nFlags, CPoint point) 
{
  // TODO: Add your message handler code here and/or call default
	if (m_LeftButtonDown)
                {
                     CDiplomaDoc* pDoc = GetDocument();
                     CSize rotate = m_LeftDownPos - point;
                     m_LeftDownPos = point;;
                     pDoc->m_xRotate += rotate.cx/3;
                     pDoc->m_yRotate += rotate.cy/3;
                     InvalidateRect(NULL, FALSE);
                 }
                     CView::OnMouseMove(nFlags, point);
}

void CDiplomaView::OnLButtonDown(UINT nFlags, CPoint point) 
{
    // TODO: Add your message handler code here and/or call default
	 m_LeftButtonDown = TRUE;
                 m_LeftDownPos = point;
	CView::OnLButtonDown(nFlags, point);
}

void CDiplomaView::OnMouseMove(UINT nFlags, CPoint point) 
{
  // TODO: Add your message handler code here and/or call default
	if (m_LeftButtonDown)
                {
                     CDiplomaDoc* pDoc = GetDocument();
                     CSize rotate = m_LeftDownPos - point;
                     m_LeftDownPos = point;;
                     pDoc->m_xRotate += rotate.cx/3;
                     pDoc->m_yRotate += rotate.cy/3;
                     InvalidateRect(NULL, FALSE);
                 }
                     CView::OnMouseMove(nFlags, point);
}


The problem is that i don't know how to make it spin around the z axis when the user moves the mouse. I know that i have to write this function :

glRotated(m_zRotate, 0.0, 0.0, 1.0);

where m_zRotate is the angle of the rotation in my rendering function. But on mouse move function, how can i implement the z rotation taking into consideration the fact that cz doesn't exist ? only cx and cy - Size variables used in OnSize function.

And also my rotation is kind of sudden, not very natural, i don't know why, maybe because it doesn't rotate on the z axis ?

Or can you propose a different code for rotation using the mouse with a more natural rotation ?

Thank you in advance for your help
Last edited by LuciWiz : 11-Apr-2008 at 02:01.
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenGl obduk FLTK Forum 3 06-Apr-2008 05:08
Beginning OpenGL Xeiph OpenGL Programming 4 10-Oct-2007 07:07
C++ with OpenGL BlueFireCO. OpenGL Programming 4 24-May-2007 16:26
C++ game programming OpenGL oozsakarya OpenGL Programming 2 13-Nov-2005 13:50
FLTK and OpenGL bgarisn FLTK Forum 2 27-Jun-2005 06:22

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:57.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.