Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LibGdx] How to get camera rotation?  (Read 1923 times)
0 Members and 1 Guest are viewing this topic.
Offline Longarmx
« Posted 2013-08-25 02:17:14 »

So I'm trying to implement a rotation system similar to Daedalus where you move the mouse and the camera rotates. Although, I need to find out what the rotation of my OrthographicCamera is. Is there any way to do this?

Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2013-08-25 02:24:55 »

Simple: rotate the entire world based on the horizontal movements of the mouse. +dx = -rotation, -dx = +rotation

Offline Longarmx
« Reply #2 - Posted 2013-08-25 02:31:41 »

Simple: rotate the entire world based on the horizontal movements of the mouse. +dx = -rotation, -dx = +rotation

I am doing that already to rotate my character, but how to I get the actual camera rotation value? I can rotate with
camera.rotate()
, but I need something like this
camera.getRotation()

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2013-08-25 03:42:57 »

You store the rotation variable yourself. Modify that rotation variable with the Mouse's delta-x, and call rotate(rot....)

Offline Longarmx
« Reply #4 - Posted 2013-08-25 15:17:25 »

You store the rotation variable yourself. Modify that rotation variable with the Mouse's delta-x, and call rotate(rot....)

Thank you. I thought I might have to do this but I thought I could ask.

Out of curiosity, is there a specific reason why LibGdx doesn't have a method like this where you can get the rotation along any axis?

Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2013-08-25 19:15:46 »

Well the camera stores the transformations in a 4x4 matrix as usual, with the vec3 in the first, second, and third columns being the X, Y, and Z rotations respectively. The vec3 in the fourth column is the translation. You could probably get the angle from those....somehow.

A visual example:


However, you shouldn't be doing transformations cumulatively. You should be rebuilding the matrix from identity every frame, requiring you to store your own rotations and translations. This is to avoid accumulating rounding errors.

Offline Longarmx
« Reply #6 - Posted 2013-08-25 20:21:21 »

Well the camera stores the transformations in a 4x4 matrix as usual, with the vec3 in the first, second, and third columns being the X, Y, and Z rotations respectively. The vec3 in the fourth column is the translation. You could probably get the angle from those....somehow.

A visual example:


However, you shouldn't be doing transformations cumulatively. You should be rebuilding the matrix from identity every frame, requiring you to store your own rotations and translations. This is to avoid accumulating rounding errors.

Thank you. I'll look into using the camera matrix to acquire the camera rotation.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (22 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!