View previous topic :: View next topic |
Author |
Message |
fik Member
Joined: 11 Oct 2006 Posts: 303
|
Posted: Thu Jan 21, 2010 10:39 pm Post subject: |
|
|
This is a nice welcome update |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Thu Jan 21, 2010 10:40 pm Post subject: |
|
|
chronozphere wrote: |
It works great paul! Thanks you for this.
You could improve the feature by letting the user go "all around" the model instead of moving in a fixed circle. You could utilize the Y-coordinate of the mouse to achieve vertical movement (this would be a rotation about the X-axis in screen space). I did exactly the same for the first versions of my UV-plugin (now It has a free camera).
About the docs. I'm one of the programmers who is willing to write his own documentation (It will be simple and to the point, so I can concentrate on code). |
Glad I could improve your 'user experience' LOL
I already had tried putting in vertical mouse movement on top of the horizontal one, but it rotated the view all strange (something to do with x-axis+ y-axis rotations or something), so I have commented out those bits till I work out something else better
My x-axis rotation wasn't in screenspace, but in world space I think which was the problem...
If I could figure out how to rotate around the camera x-axis instead, perhaps I could fix it.
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
chronozphere DeleD PRO user
Joined: 20 Jun 2006 Posts: 1010 Location: Netherlands
|
Posted: Thu Jan 21, 2010 11:08 pm Post subject: |
|
|
The key to good camera-about-center behaviour is "spherical coordinates".
Just take a look over here:
http://en.wikipedia.org/wiki/Spherical_coordinate_system
I must map the change in X/Y of the mouse to a change in Theta/Phi (where Theta is the horizontal rotation which you have now, and Phi is the vertical rotation which is constrained to the -90..90 range).
Just combine some trigoniometry to compute the camera position from these values:
Code: |
//Compute Camera position from center
fCamera_Pos.x := cos(fCamera_theta)*sin(fCamera_phi)*Distance;
fCamera_Pos.y := cos(fCamera_phi)*Distance;
fCamera_Pos.z := sin(fCamera_theta)*sin(fCamera_phi)*Distance;
|
You will probably need to modify this code a bit. You also need to figure out how to compute the camera lookat vector.
Hope this helps. |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Thu Jan 21, 2010 11:29 pm Post subject: |
|
|
chronozphere wrote: |
The key to good camera-about-center behaviour is "spherical coordinates".
Just take a look over here:
http://en.wikipedia.org/wiki/Spherical_coordinate_system
I must map the change in X/Y of the mouse to a change in Theta/Phi (where Theta is the horizontal rotation which you have now, and Phi is the vertical rotation which is constrained to the -90..90 range).
Just combine some trigoniometry to compute the camera position from these values:
Code: |
//Compute Camera position from center
fCamera_Pos.x := cos(fCamera_theta)*sin(fCamera_phi)*Distance;
fCamera_Pos.y := cos(fCamera_phi)*Distance;
fCamera_Pos.z := sin(fCamera_theta)*sin(fCamera_phi)*Distance;
|
You will probably need to modify this code a bit. You also need to figure out how to compute the camera lookat vector.
Hope this helps. |
Thanks for the info chief
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Fri Jan 22, 2010 3:01 pm Post subject: |
|
|
As a bit of nitpicking, could you try to remove all hints (and warnings of course) from the code before checking it in?
You don't have to worry about it too much, but be warned that I'll gripe and whine about sloppiness every time someone does this. |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Fri Jan 22, 2010 8:58 pm Post subject: |
|
|
Paul-Jan wrote: |
As a bit of nitpicking, could you try to remove all hints (and warnings of course) from the code before checking it in?
You don't have to worry about it too much, but be warned that I'll gripe and whine about sloppiness every time someone does this. |
No problem PJ, and sorry about that
I will fix it shortly!
EDIT: Oh, it was already fixed...ok
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
|