Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, TipmyPip, VoroneTZ, Quad, 1 invisible), 688 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
camera rotation on a planet #372880
06/05/11 14:54
06/05/11 14:54
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
I'm making a game with spherical terrain. So obviously, when walking on this terrain you can't use standard movement and camera code because the down vector is always pointing to the center of the planet relative to your position on the surface.

It's trivial to calculate the "down" vector: just normalize(position.xyz)...and of course simply aligning a model to this is also easy...vec_to_angle(my.pan,downvector).

The problem comes when trying to do this for a camera...when you align a camera angle to the planet surface, pan and tilt can't be used like when the surface is flat.

So does anyone understand the math for this?

Re: camera rotation on a planet [Re: Matt_Aufderheide] #372894
06/05/11 16:30
06/05/11 16:30
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
in principle I'd calculate the normal the camera is pointing to behind the scenes in flat space and then do a coordinate transformation to spherical polar coordinates. The thing is, when you set up the transformation matrix J(phi, theta) (and you know phi and theta from the normal you just calculated in your last post), you simply multiply the camera normal with J and get the vector in spherical coordinates. Then, after that, you have to extract pan, tilt and roll from this vector. The transformation (pan, tilt, roll) <--> (nx, ny, nz) can be found everywhere and since it is in flat space I guess you even know how to do it.

for the coordinate transformation jacobian - see here:
http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations
take the inverse of the "To Cartesian coordinates-From spherical coordinates" thingy.

Last edited by Joey; 06/05/11 16:32.
Re: camera rotation on a planet [Re: Joey] #372913
06/05/11 18:36
06/05/11 18:36
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
Thanks, but I'm not understanding this very well..

1) you calculate a direction vector for the new direction assuming the camera is in flat space.

2) set up what kind of matrix ....what is "J" here?

3) I dont know much trig so what is phi and theta in relation to a normal?

... the rest i don't even begin to understand..

I guess i was hoping this was a common problem with a standard solution in c_script.


Sphere Engine--the premier A6 graphics plugin.
Re: camera rotation on a planet [Re: Matt_Aufderheide] #372920
06/05/11 19:09
06/05/11 19:09
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
You've already tried with camera.c script library?


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: camera rotation on a planet [Re: rojart] #372928
06/05/11 20:14
06/05/11 20:14
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
There is indead an instruction for those problems, and JulzMighty already programed something in this direction.
Here is the instruction from the manual:
http://www.conitec.net/beta/ang_for_axis.htm

Re: camera rotation on a planet [Re: Pappenheimer] #372977
06/06/11 12:41
06/06/11 12:41
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
Ok, that function works perfectly.. thanks a lot


Sphere Engine--the premier A6 graphics plugin.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1