help with mouse click to move object

Started by
7 comments, last by veeru 19 years ago
I am just learning OpenGL right now and trying to follow the lessons, but i have not gone through each lesson. I am trying to follow the lesson 48 but the author has not explain much in the comments, so i am just not able to follow it properly. if someone can explain me the _mapToSphere function in ArcBall.cpp sourcefile, i would really appreciate.
Advertisement
It would maybe help if you would tell the people of what book you speak... which author?
I probably can't help you but someone will ask for the author and book/tutorial anyway...
Maybe you can even post some code with which you are having problems or the error messages if it won't compile.
Now get down on your hands and knees and start repeating "Open Source Good, M$ Evil", smacking your head against the pavement after each repetition. Once you have completed your training you may change your first name to GNU/, to show that you are free from the slavery of the closed source world. -Michalson
I am refering to lessons 48 on the nehe.gamedev.net webpage. Author name is Terence J. Grant. Thank you so much.
Well start on chapter 1 and not chapter 48.

Quote:Original post by veeru
I am just learning OpenGL right now and trying to follow the lessons, but i have not gone through each lesson. I am trying to follow the lesson 48...
- A momentary maniac with casual delusions.
I am already getting to know GL and i went until lesson 25 and i just wanted to know how can OpenGL get mouse event, so i went to lesson 48 and i am not understanding the function _mapToSphere in ArcBall.cpp file and author for lesson 48 did not comment the need or use of that function so i was wondering if anyone has any idea or knowledge of it.
I have not got response from anyone, does anyone has knowledge of lesson 48 on nehe.gamedev.net website????
Most likely, if it's something simple, you'll just want to move the points of whatever you're drawing around. In the case of OpenGl, glTranslatef() would probably be fine. If you're using Win32 in your program, you could just handle some of the mouse movement functions, and use glTranslatef() accordingly.


float xMove = 0, yMove = 0;POINT oldPoints, newPoints;oldPoints.x = 0; oldPoint.y = 0;............// handle the WM_MOUSEMOVE messagecase WM_MOUSEMOVE:{newPoints.x = HIWORD(lParam);newPoints.y = LOWORD(lParam);/*bassically here you're just checking if the mouse moved in the positive or negative direction for each axis, and add to xMove/yMove accordingly.Although there's probably a simpler way.*/if(newPoints.x > oldPoints.x)    xMove = .5;else if(newPoints.x > oldPoints.x)    xMove = -.5;else    xMove = 0;if(newPoints.y > oldPoints.y)    yMove = .5;else if(newPoints.y < oldPoints.y);    yMove = -.5;else    yMove = 0;glTranslatef(xMove, yMove, 0);break;}


Hope that helps a bit.
Sorry that was a bit messy
Thank you very much, i did found the mapping with pixel and OpenGL point, I was just getting confuse.. Thank you very much for your help.

This topic is closed to new replies.

Advertisement