Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: 3D Free Rotation of Camera (Arcball?) - Possible without roll?  (Read 1010 times)
roncresswell
Community Member
*
Posts: 6


« on: March 07, 2010, 11:55:06 PM »


I'm trying (for my first delve into TV3D) to create myself a 3D modeller. What I want to be able to do is to keep my mesh fixed in space (because the node coordinates are absolute) and move the camera around to look at the model from different viewpoints.

So, it appears as if this question comes up relatively often, and the Arcball approach is the most intuitive from the users point of view for rotating the view around the model.

That's fine, but any implementation I have seen appears to be for rotating the model rather than the mesh. And applying an arcball rotation to the camera position instead produces an unwanted effect as the viewpoint passes over the "north pole". Namely the camera model seems to have it's own logic to determine which way is "Up", and produces a sudden "roll" at this point. The "roll" angle is unspecified if you simply set the Look-At and Look-From points, which I presume is why the camera seems to control this itself.

However, if I were to rotate the mesh rather than the camera, there would be no unspecified rotations, and because the camera's orientation in world coordinates is fixed, there would be no unexpected roll of the view.

Is there a way, to anyone's knowledge, of doing what I want to do? As far as I can see there are two possible ways of achieving this:

1. Give in and rotate the mesh, but keep a global variable which is the rotation quaternion required to put the mesh back into "real world" coordinates for export;

2. Constantly correct the roll of the camera as it is moved, such as:-
a. Get the basis vectors of the camera,
b. add them to the camera position vector to get their location in global coordinates,
c. apply the arcball rotation to all 4 vectors (camera position, up, right and front vectors)
d. Subtract the new camera position from the transformed basis vectors (to get them back into local coordinates)
e. get the new basis vectors
f. calculate the angle between the transformed "Up" vector and the one returned by the camera
g. rotate the camera by this angle

Does this sound feasible or am I somehow making things hard for myself?
Logged
Mithrandir
Community Member
*
Posts: 325


« Reply #1 on: March 08, 2010, 04:11:07 AM »

Rotating the camera quaternion by another angle defined by qutarnion itsn't gonna do the same thing?
Logged
jviper
Community Member
*
Posts: 2127

Discipline in training


« Reply #2 on: March 08, 2010, 04:58:36 PM »

I would not pick th first option as that will be a pain to deal with later.

Sounds like what you need to do is learn matricies, esspcially what matricies have to do with eular angles and quaterions. This will hopefully help make the trackball stuff make sense, and so you can come up with somthing that better fits your needs. This is better then just simply blindly using methods, then trying to cram them together and find out they do not work together.
Logged

JAbstract.....Don't just imagine, make it happen!
Silver
Community Member
*
Posts: 14


« Reply #3 on: March 08, 2010, 06:18:43 PM »

Here is one idea.
How about ot create another invisivle mesh and fix the camera to that mesh. An then for every time jou need to rotate the camera you just rotate that invisible mesh. And since the camera is fixed to it it would be just as you would have camesra fixed to a car something like that.
Logged
roncresswell
Community Member
*
Posts: 6


« Reply #4 on: March 09, 2010, 06:40:03 PM »


Brilliant.

And it works beautifully - thanks!
Logged
Silver
Community Member
*
Posts: 14


« Reply #5 on: March 10, 2010, 02:27:00 PM »

I'm glad I could help
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks